mix fixes
fix wifi assert by increasing number of nodes to correct 16. enable tracingmain
parent
f3ce08f0f8
commit
ba5e194d23
|
@ -17,7 +17,6 @@ using namespace ns3;
|
|||
|
||||
NS_LOG_COMPONENT_DEFINE("Task_2001600");
|
||||
|
||||
NetDeviceContainer createP2P(NodeContainer nodes, StringValue DataRate, StringValue Delay);
|
||||
NetDeviceContainer createCSMA(NodeContainer nodes, StringValue DataRate, StringValue Delay);
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -55,7 +54,7 @@ int main(int argc, char* argv[])
|
|||
cmd.Parse(argc, argv);
|
||||
|
||||
// Se studentId vuoto, la simulazione non deve partire
|
||||
if (studentId.empty() > 18)
|
||||
if (studentId.empty())
|
||||
{
|
||||
std::cout << "studentId is empty, simulation will not start. exiting." << std::endl;
|
||||
return 1;
|
||||
|
@ -64,7 +63,7 @@ int main(int argc, char* argv[])
|
|||
// All the nodes, each subnet uses a subset of these.
|
||||
// A node can belong to multiple subnets
|
||||
NodeContainer allNodes;
|
||||
allNodes.Create(15);
|
||||
allNodes.Create(16);
|
||||
|
||||
/* Topologia della Rete*/
|
||||
|
||||
|
@ -73,89 +72,121 @@ int main(int argc, char* argv[])
|
|||
NodeContainer nodes02;
|
||||
nodes02.Add(allNodes.Get(0));
|
||||
nodes02.Add(allNodes.Get(2));
|
||||
NetDeviceContainer ptp02 = createP2P(nodes02, StringValue("10Mbps"), StringValue("200ms"));
|
||||
PointToPointHelper ptph02;
|
||||
ptph02.SetDeviceAttribute("DataRate", StringValue("00Mbps"));
|
||||
ptph02.SetChannelAttribute("Delay", StringValue("200ms"));
|
||||
NetDeviceContainer ptp02 = ptph02.Install(nodes02);
|
||||
/* SOTTORETE PTP Node 1,2 */
|
||||
NodeContainer nodes12;
|
||||
nodes12.Add(allNodes.Get(1));
|
||||
nodes12.Add(allNodes.Get(2));
|
||||
NetDeviceContainer ptp12 = createP2P(nodes12, StringValue("10Mbps"), StringValue("200ms"));
|
||||
PointToPointHelper ptph12;
|
||||
ptph12.SetDeviceAttribute("DataRate", StringValue("10Mbps"));
|
||||
ptph12.SetChannelAttribute("Delay", StringValue("200ms"));
|
||||
NetDeviceContainer ptp12 = ptph12.Install(nodes12);
|
||||
/* SOTTORETE PTP Node 2,4 */
|
||||
NodeContainer nodes24;
|
||||
nodes24.Add(allNodes.Get(2));
|
||||
nodes24.Add(allNodes.Get(4));
|
||||
NetDeviceContainer ptp24 = createP2P(nodes24, StringValue("100Mbps"), StringValue("20ms"));
|
||||
PointToPointHelper ptph24;
|
||||
ptph24.SetDeviceAttribute("DataRate", StringValue("100Mbps"));
|
||||
ptph24.SetChannelAttribute("Delay", StringValue("20ms"));
|
||||
NetDeviceContainer ptp24 = ptph24.Install(nodes24);
|
||||
/* SOTTORETE PTP Node 3,5 */
|
||||
NodeContainer nodes35;
|
||||
nodes35.Add(allNodes.Get(3));
|
||||
nodes35.Add(allNodes.Get(5));
|
||||
NetDeviceContainer ptp35 = createP2P(nodes35, StringValue("100Mbps"), StringValue("20ms"));
|
||||
PointToPointHelper ptph35;
|
||||
ptph35.SetDeviceAttribute("DataRate", StringValue("100Mbps"));
|
||||
ptph35.SetChannelAttribute("Delay", StringValue("20ms"));
|
||||
NetDeviceContainer ptp35 = ptph35.Install(nodes35);
|
||||
/* SOTTORETE PTP Node 4,5 */
|
||||
NodeContainer nodes45;
|
||||
nodes45.Add(allNodes.Get(4));
|
||||
nodes45.Add(allNodes.Get(5));
|
||||
NetDeviceContainer ptp45 = createP2P(nodes45, StringValue("100Mbps"), StringValue("20ms"));
|
||||
PointToPointHelper ptph45;
|
||||
ptph45.SetDeviceAttribute("DataRate", StringValue("100Mbps"));
|
||||
ptph45.SetChannelAttribute("Delay", StringValue("20ms"));
|
||||
NetDeviceContainer ptp45 = ptph45.Install(nodes45);
|
||||
/* SOTTORETE PTP Node 3,9 */
|
||||
NodeContainer nodes39;
|
||||
nodes39.Add(allNodes.Get(3));
|
||||
nodes39.Add(allNodes.Get(9));
|
||||
NetDeviceContainer ptp39 = createP2P(nodes39, StringValue("100Mbps"), StringValue("20ms"));
|
||||
PointToPointHelper ptph39;
|
||||
ptph39.SetDeviceAttribute("DataRate", StringValue("100Mbps"));
|
||||
ptph39.SetChannelAttribute("Delay", StringValue("20ms"));
|
||||
NetDeviceContainer ptp39 = ptph39.Install(nodes39);
|
||||
/* SOTTORETE PTP Node 4,9 */
|
||||
NodeContainer nodes49;
|
||||
nodes49.Add(allNodes.Get(4));
|
||||
nodes49.Add(allNodes.Get(9));
|
||||
NetDeviceContainer ptp49 = createP2P(nodes49, StringValue("100Mbps"), StringValue("20ms"));
|
||||
PointToPointHelper ptph49;
|
||||
ptph49.SetDeviceAttribute("DataRate", StringValue("100Mbps"));
|
||||
ptph49.SetChannelAttribute("Delay", StringValue("20ms"));
|
||||
NetDeviceContainer ptp49 = ptph49.Install(nodes49);
|
||||
|
||||
// Reti CSMA
|
||||
/* SOTTORETE CSMA Nodi 3,4 */
|
||||
NodeContainer nodes34;
|
||||
nodes34.Add(allNodes.Get(3));
|
||||
nodes34.Add(allNodes.Get(4));
|
||||
NetDeviceContainer csma34 = createCSMA(nodes34, StringValue("10Mbps"), StringValue("200ms"));
|
||||
CsmaHelper csmah34;
|
||||
csmah34.SetChannelAttribute("DataRate", StringValue("10Mbps"));
|
||||
csmah34.SetChannelAttribute("Delay", TimeValue(MicroSeconds(200)));
|
||||
NetDeviceContainer csma34 = csmah34.Install(nodes34);
|
||||
|
||||
/* SOTTORETE CSMA Nodi 5,6,7,8 */
|
||||
NodeContainer nodes5678;
|
||||
nodes5678.Add(allNodes.Get(5));
|
||||
nodes5678.Add(allNodes.Get(6));
|
||||
nodes5678.Add(allNodes.Get(7));
|
||||
nodes5678.Add(allNodes.Get(8));
|
||||
NetDeviceContainer csma5678 = createCSMA(nodes5678, StringValue("5Mbps"), StringValue("20ms"));
|
||||
CsmaHelper csmah5678;
|
||||
csmah5678.SetChannelAttribute("DataRate", StringValue("5Mbps"));
|
||||
csmah5678.SetChannelAttribute("Delay", TimeValue(MicroSeconds(20)));
|
||||
NetDeviceContainer csma5678 = csmah5678.Install(nodes5678);
|
||||
|
||||
|
||||
// Rete Wi-Fi AARF 802.11g
|
||||
/*
|
||||
Wi-Fi operating in Infrastructure mode, AP is stationary, Stations nodes move with random walk mobility pattern over a bounded square of 30 meters for each side
|
||||
*/
|
||||
// Channel
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
|
||||
YansWifiPhyHelper phy;
|
||||
phy.SetChannel(channel.Create());
|
||||
|
||||
// AP
|
||||
NodeContainer wifiApNode;
|
||||
wifiApNode.Add(allNodes.Get(9));
|
||||
|
||||
// Station devices
|
||||
NodeContainer wifiStationNodes;
|
||||
wifiStationNodes.Add(allNodes.Get(10));
|
||||
wifiStationNodes.Add(allNodes.Get(11));
|
||||
wifiStationNodes.Add(allNodes.Get(12));
|
||||
wifiStationNodes.Add(allNodes.Get(13));
|
||||
wifiStationNodes.Add(allNodes.Get(14));
|
||||
wifiStationNodes.Add(allNodes.Get(15));
|
||||
NodeContainer wifiStaNodes;
|
||||
wifiStaNodes.Add(allNodes.Get(10));
|
||||
wifiStaNodes.Add(allNodes.Get(11));
|
||||
wifiStaNodes.Add(allNodes.Get(12));
|
||||
wifiStaNodes.Add(allNodes.Get(13));
|
||||
wifiStaNodes.Add(allNodes.Get(14));
|
||||
wifiStaNodes.Add(allNodes.Get(15));
|
||||
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
|
||||
YansWifiPhyHelper phy;
|
||||
phy.SetChannel(channel.Create());
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_STANDARD_80211g);
|
||||
wifi.SetRemoteStationManager("ns3::AarfWifiManager");
|
||||
// you can do in this way if you want to set a constant data rate
|
||||
//wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode", StringValue("OfdmRate6Mbps"));
|
||||
|
||||
WifiMacHelper mac;
|
||||
Ssid ssid = Ssid("2001600"); // Ssid matricola regerent
|
||||
|
||||
// Stations
|
||||
NetDeviceContainer staDevice;
|
||||
// Infrastructure Mode
|
||||
Ssid ssid = Ssid("2001600");
|
||||
|
||||
NetDeviceContainer staDevices;
|
||||
mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid), "ActiveProbing", BooleanValue(false));
|
||||
staDevice = wifi.Install(phy, mac, wifiStationNodes);
|
||||
staDevices = wifi.Install(phy, mac, wifiStaNodes);
|
||||
|
||||
// AccessPoint
|
||||
NetDeviceContainer apDevices;
|
||||
mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
|
||||
staDevice = wifi.Install(phy, mac, wifiApNode);
|
||||
apDevices = wifi.Install(phy, mac, wifiApNode);
|
||||
|
||||
// Mobility helper
|
||||
MobilityHelper mobility;
|
||||
|
@ -179,13 +210,14 @@ int main(int argc, char* argv[])
|
|||
// Stations move with random walk over a square of 30 meters each side
|
||||
mobility.SetMobilityModel("ns3::RandomWalk2dMobilityModel",
|
||||
"Bounds",
|
||||
RectangleValue(Rectangle(-30, 30, -30, 30)));
|
||||
mobility.Install(wifiStationNodes);
|
||||
RectangleValue(Rectangle(-15, 15, -15, 15)));
|
||||
mobility.Install(wifiStaNodes);
|
||||
|
||||
// AP is stationary
|
||||
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install(wifiApNode);
|
||||
|
||||
// TODO: enableRtsCts
|
||||
|
||||
/* ######################################################## */
|
||||
/* IP Addresses*/
|
||||
|
@ -199,10 +231,15 @@ int main(int argc, char* argv[])
|
|||
// TODO: applications (Tcp burst, udp echo)
|
||||
// TCP Burst
|
||||
// UDP Echo server
|
||||
// UDP Echo client
|
||||
|
||||
/* ######################################################## */
|
||||
/* Pcap tracing*/
|
||||
// TODO: enable pcap tracing
|
||||
/* PCAP Tracing */
|
||||
if(tracing){
|
||||
ptph24.EnablePcapAll("ptp24", true);
|
||||
ptph45.EnablePcapAll("ptp45", true);
|
||||
ptph49.EnablePcapAll("ptp49", true);
|
||||
}
|
||||
|
||||
/* ######################################################## */
|
||||
Simulator::Run();
|
||||
|
@ -212,13 +249,6 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
|
||||
NetDeviceContainer createP2P(NodeContainer nodes, StringValue DataRate, StringValue Delay){
|
||||
PointToPointHelper pointToPoint;
|
||||
pointToPoint.SetDeviceAttribute("DataRate", DataRate);
|
||||
pointToPoint.SetChannelAttribute("Delay", Delay);
|
||||
return pointToPoint.Install(nodes);
|
||||
}
|
||||
|
||||
NetDeviceContainer createCSMA(NodeContainer nodes, StringValue DataRate, StringValue Delay){
|
||||
CsmaHelper csma;
|
||||
csma.SetDeviceAttribute("DataRate", DataRate);
|
||||
|
|
Loading…
Reference in New Issue