examples: Clean up wireless examples
This commit is contained in:
@@ -72,10 +72,10 @@ int main (int argc, char *argv[])
|
||||
cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
NodeContainer wifiStaNode;
|
||||
wifiStaNode.Create (4);
|
||||
NodeContainer wifiApNode;
|
||||
wifiApNode.Create (4);
|
||||
NodeContainer wifiStaNodes;
|
||||
wifiStaNodes.Create (4);
|
||||
NodeContainer wifiApNodes;
|
||||
wifiApNodes.Create (4);
|
||||
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
|
||||
@@ -95,13 +95,13 @@ int main (int argc, char *argv[])
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
staDeviceA = wifi.Install (phy, mac, wifiStaNode.Get (0));
|
||||
staDeviceA = wifi.Install (phy, mac, wifiStaNodes.Get (0));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceA = wifi.Install (phy, mac, wifiApNode.Get (0));
|
||||
apDeviceA = wifi.Install (phy, mac, wifiApNodes.Get (0));
|
||||
|
||||
//Network B
|
||||
ssid = Ssid ("network-B");
|
||||
@@ -110,16 +110,16 @@ int main (int argc, char *argv[])
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNode.Get (1));
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNodes.Get (1));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceB = wifi.Install (phy, mac, wifiApNode.Get (1));
|
||||
apDeviceB = wifi.Install (phy, mac, wifiApNodes.Get (1));
|
||||
|
||||
//Modify EDCA configuration (TXOP limit) for AC_BE
|
||||
Ptr<NetDevice> dev = wifiApNode.Get (1)->GetDevice (0);
|
||||
Ptr<NetDevice> dev = wifiApNodes.Get (1)->GetDevice (0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
|
||||
PointerValue ptr;
|
||||
@@ -135,13 +135,13 @@ int main (int argc, char *argv[])
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
staDeviceC = wifi.Install (phy, mac, wifiStaNode.Get (2));
|
||||
staDeviceC = wifi.Install (phy, mac, wifiStaNodes.Get (2));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceC = wifi.Install (phy, mac, wifiApNode.Get (2));
|
||||
apDeviceC = wifi.Install (phy, mac, wifiApNodes.Get (2));
|
||||
|
||||
//Network D
|
||||
ssid = Ssid ("network-D");
|
||||
@@ -150,16 +150,16 @@ int main (int argc, char *argv[])
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
staDeviceD = wifi.Install (phy, mac, wifiStaNode.Get (3));
|
||||
staDeviceD = wifi.Install (phy, mac, wifiStaNodes.Get (3));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceD = wifi.Install (phy, mac, wifiApNode.Get (3));
|
||||
apDeviceD = wifi.Install (phy, mac, wifiApNodes.Get (3));
|
||||
|
||||
//Modify EDCA configuration (TXOP limit) for AC_VO
|
||||
dev = wifiApNode.Get (3)->GetDevice (0);
|
||||
dev = wifiApNodes.Get (3)->GetDevice (0);
|
||||
wifi_dev = DynamicCast<WifiNetDevice> (dev);
|
||||
wifi_mac = wifi_dev->GetMac ();
|
||||
wifi_mac->GetAttribute ("VI_EdcaTxopN", ptr);
|
||||
@@ -185,16 +185,15 @@ int main (int argc, char *argv[])
|
||||
//and the only variable that affects transmission performance is the distance.
|
||||
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.Install (wifiApNode);
|
||||
mobility.Install (wifiStaNode);
|
||||
mobility.Install (wifiApNodes);
|
||||
mobility.Install (wifiStaNodes);
|
||||
|
||||
/* Internet stack */
|
||||
InternetStackHelper stack;
|
||||
stack.Install (wifiApNode);
|
||||
stack.Install (wifiStaNode);
|
||||
stack.Install (wifiApNodes);
|
||||
stack.Install (wifiStaNodes);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceA;
|
||||
StaInterfaceA = address.Assign (staDeviceA);
|
||||
@@ -220,75 +219,76 @@ int main (int argc, char *argv[])
|
||||
ApInterfaceD = address.Assign (apDeviceD);
|
||||
|
||||
/* Setting applications */
|
||||
UdpServerHelper myServerA (5001);
|
||||
ApplicationContainer serverAppA = myServerA.Install (wifiApNode.Get (0));
|
||||
uint16_t port = 5001;
|
||||
UdpServerHelper serverA (port);
|
||||
ApplicationContainer serverAppA = serverA.Install (wifiApNodes.Get (0));
|
||||
serverAppA.Start (Seconds (0.0));
|
||||
serverAppA.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
InetSocketAddress destA (ApInterfaceA.GetAddress (0), 5001);
|
||||
InetSocketAddress destA (ApInterfaceA.GetAddress (0), port);
|
||||
destA.SetTos (0x70); //AC_BE
|
||||
|
||||
OnOffHelper myClientA ("ns3::UdpSocketFactory", destA);
|
||||
myClientA.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
myClientA.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
myClientA.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientA.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
OnOffHelper clientA ("ns3::UdpSocketFactory", destA);
|
||||
clientA.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
clientA.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
clientA.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
clientA.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppA = myClientA.Install (wifiStaNode.Get (0));
|
||||
ApplicationContainer clientAppA = clientA.Install (wifiStaNodes.Get (0));
|
||||
clientAppA.Start (Seconds (1.0));
|
||||
clientAppA.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpServerHelper myServerB (5001);
|
||||
ApplicationContainer serverAppB = myServerB.Install (wifiApNode.Get (1));
|
||||
UdpServerHelper serverB (port);
|
||||
ApplicationContainer serverAppB = serverB.Install (wifiApNodes.Get (1));
|
||||
serverAppB.Start (Seconds (0.0));
|
||||
serverAppB.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
InetSocketAddress destB (ApInterfaceB.GetAddress (0), 5001);
|
||||
InetSocketAddress destB (ApInterfaceB.GetAddress (0), port);
|
||||
destB.SetTos (0x70); //AC_BE
|
||||
|
||||
OnOffHelper myClientB ("ns3::UdpSocketFactory", destB);
|
||||
myClientB.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
myClientB.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
myClientB.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientB.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
OnOffHelper clientB ("ns3::UdpSocketFactory", destB);
|
||||
clientB.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
clientB.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
clientB.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
clientB.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppB = myClientB.Install (wifiStaNode.Get (1));
|
||||
ApplicationContainer clientAppB = clientB.Install (wifiStaNodes.Get (1));
|
||||
clientAppB.Start (Seconds (1.0));
|
||||
clientAppB.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpServerHelper myServerC (5001);
|
||||
ApplicationContainer serverAppC = myServerC.Install (wifiApNode.Get (2));
|
||||
UdpServerHelper serverC (port);
|
||||
ApplicationContainer serverAppC = serverC.Install (wifiApNodes.Get (2));
|
||||
serverAppC.Start (Seconds (0.0));
|
||||
serverAppC.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
InetSocketAddress destC (ApInterfaceC.GetAddress (0), 5001);
|
||||
InetSocketAddress destC (ApInterfaceC.GetAddress (0), port);
|
||||
destC.SetTos (0xb8); //AC_VI
|
||||
|
||||
OnOffHelper myClientC ("ns3::UdpSocketFactory", destC);
|
||||
myClientC.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
myClientC.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
myClientC.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientC.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
OnOffHelper clientC ("ns3::UdpSocketFactory", destC);
|
||||
clientC.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
clientC.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
clientC.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
clientC.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppC = myClientC.Install (wifiStaNode.Get (2));
|
||||
ApplicationContainer clientAppC = clientC.Install (wifiStaNodes.Get (2));
|
||||
clientAppC.Start (Seconds (1.0));
|
||||
clientAppC.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpServerHelper myServerD (5001);
|
||||
ApplicationContainer serverAppD = myServerD.Install (wifiApNode.Get (3));
|
||||
UdpServerHelper serverD (port);
|
||||
ApplicationContainer serverAppD = serverD.Install (wifiApNodes.Get (3));
|
||||
serverAppD.Start (Seconds (0.0));
|
||||
serverAppD.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
InetSocketAddress destD (ApInterfaceD.GetAddress (0), 5001);
|
||||
InetSocketAddress destD (ApInterfaceD.GetAddress (0), port);
|
||||
destD.SetTos (0xb8); //AC_VI
|
||||
|
||||
OnOffHelper myClientD ("ns3::UdpSocketFactory", destD);
|
||||
myClientD.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
myClientD.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
myClientD.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientD.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
OnOffHelper clientD ("ns3::UdpSocketFactory", destD);
|
||||
clientD.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
clientD.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
clientD.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
clientD.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppD = myClientD.Install (wifiStaNode.Get (3));
|
||||
ApplicationContainer clientAppD = clientD.Install (wifiStaNodes.Get (3));
|
||||
clientAppD.Start (Seconds (1.0));
|
||||
clientAppD.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
@@ -190,7 +190,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNode);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
@@ -199,21 +198,21 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
/* Setting applications */
|
||||
ApplicationContainer serverApp, sinkApp;
|
||||
ApplicationContainer serverApp;
|
||||
if (udp)
|
||||
{
|
||||
//UDP flow
|
||||
UdpServerHelper myServer (9);
|
||||
serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
@@ -221,25 +220,22 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
//TCP flow
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
sinkApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
|
||||
serverApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ());
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
|
||||
ApplicationContainer apps;
|
||||
|
||||
AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
apps.Add (onoff.Install (wifiApNode.Get (0)));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
@@ -252,13 +248,13 @@ int main (int argc, char *argv[])
|
||||
if (udp)
|
||||
{
|
||||
//UDP
|
||||
uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
|
||||
uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
|
||||
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); //Mbit/s
|
||||
}
|
||||
else
|
||||
{
|
||||
//TCP
|
||||
uint32_t totalPacketsThrough = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
|
||||
throughput = totalPacketsThrough * 8 / (simulationTime * 1000000.0); //Mbit/s
|
||||
}
|
||||
dataset.Add (d, throughput);
|
||||
|
||||
@@ -152,7 +152,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNode);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
@@ -161,45 +160,44 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
/* Setting applications */
|
||||
ApplicationContainer serverApp, sinkApp;
|
||||
ApplicationContainer serverApp;
|
||||
if (udp)
|
||||
{
|
||||
UdpServerHelper myServer (9);
|
||||
serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
//UDP flow
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
//TCP flow
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
sinkApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
|
||||
serverApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ());
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
|
||||
ApplicationContainer apps;
|
||||
|
||||
AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
apps.Add (onoff.Install (wifiApNode.Get (0)));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
@@ -215,7 +213,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
rxBytes = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
rxBytes = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
|
||||
}
|
||||
double throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
|
||||
std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << gi << " ns\t\t\t" << throughput << " Mbit/s" << std::endl;
|
||||
|
||||
@@ -168,7 +168,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNode);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
@@ -177,21 +176,21 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
/* Setting applications */
|
||||
ApplicationContainer serverApp, sinkApp;
|
||||
ApplicationContainer serverApp;
|
||||
if (udp)
|
||||
{
|
||||
//UDP flow
|
||||
UdpServerHelper myServer (9);
|
||||
serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
@@ -199,25 +198,22 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
//TCP flow
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
sinkApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
|
||||
serverApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ());
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
|
||||
ApplicationContainer apps;
|
||||
|
||||
AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
apps.Add (onoff.Install (wifiApNode.Get (0)));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
@@ -233,7 +229,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
rxBytes = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
rxBytes = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
|
||||
}
|
||||
double throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
|
||||
std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << sgi << "\t\t\t" << throughput << " Mbit/s" << std::endl;
|
||||
|
||||
@@ -125,7 +125,6 @@ Experiment::Run (Parameters params)
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::ErpProtectionMode", StringValue (params.erpProtectionMode));
|
||||
|
||||
double throughput = 0;
|
||||
uint32_t totalPacketsThrough = 0;
|
||||
uint32_t nWifiB = params.nWifiB;
|
||||
uint32_t nWifiG = params.nWifiG;
|
||||
uint32_t nWifiNNGF = params.nWifiNNonGreenfield;
|
||||
@@ -275,7 +274,6 @@ Experiment::Run (Parameters params)
|
||||
stack.Install (wifiNGFStaNodes);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer bStaInterface;
|
||||
bStaInterface = address.Assign (bStaDevice);
|
||||
@@ -291,62 +289,55 @@ Experiment::Run (Parameters params)
|
||||
// Setting applications
|
||||
if (params.isUdp)
|
||||
{
|
||||
UdpServerHelper myServer (9);
|
||||
ApplicationContainer serverApp = myServer.Install (wifiApNode);
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
ApplicationContainer serverApp = server.Install (wifiApNode);
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (ApInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Time ("0.0002"))); //packets/s
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
UdpClientHelper client (ApInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.0002"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApps;
|
||||
if (params.bHasTraffic)
|
||||
{
|
||||
ApplicationContainer clientAppB = myClient.Install (wifiBStaNodes);
|
||||
clientAppB.Start (Seconds (1.0));
|
||||
clientAppB.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (client.Install (wifiBStaNodes));
|
||||
}
|
||||
|
||||
if (params.gHasTraffic)
|
||||
{
|
||||
ApplicationContainer clientAppG = myClient.Install (wifiGStaNodes);
|
||||
clientAppG.Start (Seconds (1.0));
|
||||
clientAppG.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (client.Install (wifiGStaNodes));
|
||||
}
|
||||
|
||||
if (params.nNonGreenfieldHasTraffic)
|
||||
{
|
||||
ApplicationContainer clientAppNNGF = myClient.Install (wifiNNGFStaNodes);
|
||||
clientAppNNGF.Start (Seconds (1.0));
|
||||
clientAppNNGF.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (client.Install (wifiNNGFStaNodes));
|
||||
}
|
||||
|
||||
if (params.nGreenfieldHasTraffic)
|
||||
{
|
||||
ApplicationContainer clientAppNGF = myClient.Install (wifiNGFStaNodes);
|
||||
clientAppNGF.Start (Seconds (1.0));
|
||||
clientAppNGF.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (client.Install (wifiNGFStaNodes));
|
||||
}
|
||||
clientApps.Start (Seconds (1.0));
|
||||
clientApps.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
Simulator::Stop (Seconds (simulationTime + 1));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
|
||||
uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
|
||||
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
|
||||
|
||||
ApplicationContainer sinkApp = packetSinkHelper.Install (wifiApNode.Get (0));
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
ApplicationContainer serverApp = packetSinkHelper.Install (wifiApNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ());
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
@@ -355,40 +346,33 @@ Experiment::Run (Parameters params)
|
||||
AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
|
||||
ApplicationContainer apps;
|
||||
ApplicationContainer clientApps;
|
||||
if (params.bHasTraffic)
|
||||
{
|
||||
apps.Add (onoff.Install (wifiBStaNodes));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (onoff.Install (wifiBStaNodes));
|
||||
}
|
||||
if (params.gHasTraffic)
|
||||
{
|
||||
apps.Add (onoff.Install (wifiGStaNodes));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (onoff.Install (wifiGStaNodes));
|
||||
}
|
||||
if (params.nNonGreenfieldHasTraffic)
|
||||
{
|
||||
apps.Add (onoff.Install (wifiNNGFStaNodes));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (onoff.Install (wifiNNGFStaNodes));
|
||||
}
|
||||
if (params.nGreenfieldHasTraffic)
|
||||
{
|
||||
apps.Add (onoff.Install (wifiNGFStaNodes));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
clientApps.Add (onoff.Install (wifiNGFStaNodes));
|
||||
}
|
||||
clientApps.Start (Seconds (1.0));
|
||||
clientApps.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
Simulator::Stop (Seconds (simulationTime + 1));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
totalPacketsThrough = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
|
||||
throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
|
||||
}
|
||||
|
||||
return throughput;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,6 @@ class NodeStatistics
|
||||
public:
|
||||
NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas);
|
||||
|
||||
void CheckStatistics (double time);
|
||||
|
||||
void PhyCallback (std::string path, Ptr<const Packet> packet);
|
||||
void RxCallback (std::string path, Ptr<const Packet> packet, const Address &from);
|
||||
void PowerCallback (std::string path, uint8_t power, Mac48Address dest);
|
||||
@@ -230,12 +228,6 @@ NodeStatistics::RxCallback (std::string path, Ptr<const Packet> packet, const Ad
|
||||
m_bytesTotal += packet->GetSize ();
|
||||
}
|
||||
|
||||
void
|
||||
NodeStatistics::CheckStatistics (double time)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
NodeStatistics::SetPosition (Ptr<Node> node, Vector position)
|
||||
{
|
||||
|
||||
@@ -135,7 +135,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNodes);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterface;
|
||||
StaInterface = address.Assign (staDevices);
|
||||
@@ -143,18 +142,19 @@ int main (int argc, char *argv[])
|
||||
ApInterface = address.Assign (apDevice);
|
||||
|
||||
// Setting applications
|
||||
UdpServerHelper myServer (9);
|
||||
ApplicationContainer serverApp = myServer.Install (wifiApNode);
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
ApplicationContainer serverApp = server.Install (wifiApNode);
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (ApInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
UdpClientHelper client (ApInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
// Saturated UDP traffic from stations to AP
|
||||
ApplicationContainer clientApp1 = myClient.Install (wifiStaNodes);
|
||||
ApplicationContainer clientApp1 = client.Install (wifiStaNodes);
|
||||
clientApp1.Start (Seconds (1.0));
|
||||
clientApp1.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
@@ -157,7 +157,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNode);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
@@ -166,45 +165,44 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
/* Setting applications */
|
||||
ApplicationContainer serverApp, sinkApp;
|
||||
ApplicationContainer serverApp;
|
||||
if (udp)
|
||||
{
|
||||
UdpServerHelper myServer (9);
|
||||
serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
//UDP flow
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
//TCP flow
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
sinkApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
|
||||
serverApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ());
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
|
||||
ApplicationContainer apps;
|
||||
|
||||
AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
apps.Add (onoff.Install (wifiApNode.Get (0)));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
@@ -220,7 +218,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
rxBytes = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
rxBytes = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
|
||||
}
|
||||
double throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
|
||||
std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << sgi << "\t\t\t" << throughput << " Mbit/s" << std::endl;
|
||||
|
||||
@@ -237,11 +237,9 @@ int main (int argc, char *argv[])
|
||||
|
||||
gnuplot.GenerateOutput (std::cout);
|
||||
|
||||
|
||||
gnuplot = Gnuplot ("rate-control.png");
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_holland);
|
||||
|
||||
|
||||
NS_LOG_DEBUG ("arf");
|
||||
experiment = Experiment ("arf");
|
||||
wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
|
||||
|
||||
@@ -82,10 +82,10 @@ int main (int argc, char *argv[])
|
||||
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", enableRts ? StringValue ("0") : StringValue ("999999"));
|
||||
|
||||
NodeContainer wifiStaNode;
|
||||
wifiStaNode.Create (4);
|
||||
NodeContainer wifiApNode;
|
||||
wifiApNode.Create (4);
|
||||
NodeContainer wifiStaNodes;
|
||||
wifiStaNodes.Create (4);
|
||||
NodeContainer wifiApNodes;
|
||||
wifiApNodes.Create (4);
|
||||
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
|
||||
@@ -105,12 +105,12 @@ int main (int argc, char *argv[])
|
||||
phy.Set ("ChannelNumber", UintegerValue (36));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
staDeviceA = wifi.Install (phy, mac, wifiStaNode.Get (0));
|
||||
staDeviceA = wifi.Install (phy, mac, wifiStaNodes.Get (0));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceA = wifi.Install (phy, mac, wifiApNode.Get (0));
|
||||
apDeviceA = wifi.Install (phy, mac, wifiApNodes.Get (0));
|
||||
|
||||
//Network B
|
||||
ssid = Ssid ("network-B");
|
||||
@@ -119,12 +119,12 @@ int main (int argc, char *argv[])
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BE_MaxAmpduSize", UintegerValue (0)); //Disable A-MPDU
|
||||
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNode.Get (1));
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNodes.Get (1));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceB = wifi.Install (phy, mac, wifiApNode.Get (1));
|
||||
apDeviceB = wifi.Install (phy, mac, wifiApNodes.Get (1));
|
||||
|
||||
//Network C
|
||||
ssid = Ssid ("network-C");
|
||||
@@ -134,12 +134,12 @@ int main (int argc, char *argv[])
|
||||
"BE_MaxAmpduSize", UintegerValue (0), //Disable A-MPDU
|
||||
"BE_MaxAmsduSize", UintegerValue (7935)); //Enable A-MSDU with the highest maximum size allowed by the standard (7935 bytes)
|
||||
|
||||
staDeviceC = wifi.Install (phy, mac, wifiStaNode.Get (2));
|
||||
staDeviceC = wifi.Install (phy, mac, wifiStaNodes.Get (2));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceC = wifi.Install (phy, mac, wifiApNode.Get (2));
|
||||
apDeviceC = wifi.Install (phy, mac, wifiApNodes.Get (2));
|
||||
|
||||
//Network D
|
||||
ssid = Ssid ("network-D");
|
||||
@@ -149,12 +149,12 @@ int main (int argc, char *argv[])
|
||||
"BE_MaxAmpduSize", UintegerValue (32768), //Enable A-MPDU with a smaller size than the default one
|
||||
"BE_MaxAmsduSize", UintegerValue (3839)); //Enable A-MSDU with the smallest maximum size allowed by the standard (3839 bytes)
|
||||
|
||||
staDeviceD = wifi.Install (phy, mac, wifiStaNode.Get (3));
|
||||
staDeviceD = wifi.Install (phy, mac, wifiStaNodes.Get (3));
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
apDeviceD = wifi.Install (phy, mac, wifiApNode.Get (3));
|
||||
apDeviceD = wifi.Install (phy, mac, wifiApNodes.Get (3));
|
||||
|
||||
/* Setting mobility model */
|
||||
MobilityHelper mobility;
|
||||
@@ -173,16 +173,15 @@ int main (int argc, char *argv[])
|
||||
positionAlloc->Add (Vector (30 + distance, 0.0, 0.0));
|
||||
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.Install (wifiApNode);
|
||||
mobility.Install (wifiStaNode);
|
||||
mobility.Install (wifiApNodes);
|
||||
mobility.Install (wifiStaNodes);
|
||||
|
||||
/* Internet stack */
|
||||
InternetStackHelper stack;
|
||||
stack.Install (wifiApNode);
|
||||
stack.Install (wifiStaNode);
|
||||
stack.Install (wifiApNodes);
|
||||
stack.Install (wifiStaNodes);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceA;
|
||||
StaInterfaceA = address.Assign (staDeviceA);
|
||||
@@ -208,59 +207,60 @@ int main (int argc, char *argv[])
|
||||
ApInterfaceD = address.Assign (apDeviceD);
|
||||
|
||||
/* Setting applications */
|
||||
UdpServerHelper myServerA (9);
|
||||
ApplicationContainer serverAppA = myServerA.Install (wifiStaNode.Get (0));
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper serverA (port);
|
||||
ApplicationContainer serverAppA = serverA.Install (wifiStaNodes.Get (0));
|
||||
serverAppA.Start (Seconds (0.0));
|
||||
serverAppA.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClientA (StaInterfaceA.GetAddress (0), 9);
|
||||
myClientA.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClientA.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
myClientA.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
UdpClientHelper clientA (StaInterfaceA.GetAddress (0), port);
|
||||
clientA.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
clientA.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
clientA.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppA = myClientA.Install (wifiApNode.Get (0));
|
||||
ApplicationContainer clientAppA = clientA.Install (wifiApNodes.Get (0));
|
||||
clientAppA.Start (Seconds (1.0));
|
||||
clientAppA.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpServerHelper myServerB (9);
|
||||
ApplicationContainer serverAppB = myServerB.Install (wifiStaNode.Get (1));
|
||||
UdpServerHelper serverB (port);
|
||||
ApplicationContainer serverAppB = serverB.Install (wifiStaNodes.Get (1));
|
||||
serverAppB.Start (Seconds (0.0));
|
||||
serverAppB.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClientB (StaInterfaceB.GetAddress (0), 9);
|
||||
myClientB.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClientB.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
myClientB.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
UdpClientHelper clientB (StaInterfaceB.GetAddress (0), port);
|
||||
clientB.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
clientB.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
clientB.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppB = myClientB.Install (wifiApNode.Get (1));
|
||||
ApplicationContainer clientAppB = clientB.Install (wifiApNodes.Get (1));
|
||||
clientAppB.Start (Seconds (1.0));
|
||||
clientAppB.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpServerHelper myServerC (9);
|
||||
ApplicationContainer serverAppC = myServerC.Install (wifiStaNode.Get (2));
|
||||
UdpServerHelper serverC (port);
|
||||
ApplicationContainer serverAppC = serverC.Install (wifiStaNodes.Get (2));
|
||||
serverAppC.Start (Seconds (0.0));
|
||||
serverAppC.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClientC (StaInterfaceC.GetAddress (0), 9);
|
||||
myClientC.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClientC.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
myClientC.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
UdpClientHelper clientC (StaInterfaceC.GetAddress (0), port);
|
||||
clientC.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
clientC.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
clientC.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppC = myClientC.Install (wifiApNode.Get (2));
|
||||
ApplicationContainer clientAppC = clientC.Install (wifiApNodes.Get (2));
|
||||
clientAppC.Start (Seconds (1.0));
|
||||
clientAppC.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpServerHelper myServerD (9);
|
||||
ApplicationContainer serverAppD = myServerD.Install (wifiStaNode.Get (3));
|
||||
UdpServerHelper serverD (port);
|
||||
ApplicationContainer serverAppD = serverD.Install (wifiStaNodes.Get (3));
|
||||
serverAppD.Start (Seconds (0.0));
|
||||
serverAppD.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClientD (StaInterfaceD.GetAddress (0), 9);
|
||||
myClientD.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClientD.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
myClientD.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
UdpClientHelper clientD (StaInterfaceD.GetAddress (0), port);
|
||||
clientD.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
clientD.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
clientD.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppD = myClientD.Install (wifiApNode.Get (3));
|
||||
ApplicationContainer clientAppD = clientD.Install (wifiApNodes.Get (3));
|
||||
clientAppD.Start (Seconds (1.0));
|
||||
clientAppD.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
@@ -281,7 +281,7 @@ int main (int argc, char *argv[])
|
||||
Simulator::Destroy ();
|
||||
|
||||
/* Show results */
|
||||
uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverAppA.Get (0))->GetReceived ();
|
||||
uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverAppA.Get (0))->GetReceived ();
|
||||
double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
|
||||
std::cout << "Throughput with default configuration (A-MPDU aggregation enabled, 65kB): " << throughput << " Mbit/s" << '\n';
|
||||
if (verifyResults && (throughput < 59.5 || throughput > 60.5))
|
||||
|
||||
@@ -122,7 +122,6 @@ int main (int argc, char * argv[])
|
||||
/* Setting applications */
|
||||
|
||||
uint16_t port = 9;
|
||||
|
||||
DataRate dataRate ("1Mb/s");
|
||||
OnOffHelper onOff ("ns3::UdpSocketFactory", Address (InetSocketAddress (apIf.GetAddress (0), port)));
|
||||
onOff.SetAttribute ("DataRate", DataRateValue (dataRate));
|
||||
|
||||
@@ -135,9 +135,6 @@ void experiment (bool enableCtsRts)
|
||||
echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (0.006)));
|
||||
pingApps.Add (echoClientHelper.Install (nodes.Get (2)));
|
||||
|
||||
|
||||
|
||||
|
||||
// 8. Install FlowMonitor on all nodes
|
||||
FlowMonitorHelper flowmon;
|
||||
Ptr<FlowMonitor> monitor = flowmon.InstallAll ();
|
||||
|
||||
@@ -156,7 +156,7 @@ int main (int argc, char *argv[])
|
||||
double throughput = 0;
|
||||
for (unsigned index = 0; index < sinkApplications.GetN (); ++index)
|
||||
{
|
||||
uint32_t totalPacketsThrough = DynamicCast<PacketSink> (sinkApplications.Get (index))->GetTotalRx ();
|
||||
uint64_t totalPacketsThrough = DynamicCast<PacketSink> (sinkApplications.Get (index))->GetTotalRx ();
|
||||
throughput += ((totalPacketsThrough * 8) / (simulationTime * 1000000.0)); //Mbit/s
|
||||
}
|
||||
if (throughput > 0)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This script configures two nodes on an 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000
|
||||
// (application) bytes to the other node. The physical layer is configured
|
||||
@@ -83,7 +82,6 @@ static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::string phyMode ("DsssRate1Mbps");
|
||||
@@ -192,4 +190,3 @@ int main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This script configures two nodes on an 802.11b physical layer, with
|
||||
// 802.11b NICs in infrastructure mode, and by default, the station sends
|
||||
// one packet of 1000 (application) bytes to the access point. The
|
||||
@@ -84,7 +83,6 @@ static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::string phyMode ("DsssRate1Mbps");
|
||||
@@ -204,4 +202,3 @@ int main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This script configures three nodes on an 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode. There is a transmitter, receiver, and
|
||||
// interferer. The transmitter sends one packet to the receiver and
|
||||
@@ -126,7 +125,6 @@ static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
// LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL);
|
||||
@@ -265,4 +263,3 @@ int main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This script configures two nodes on an 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode. One of the nodes generates on-off traffic
|
||||
// destined to the other node.
|
||||
@@ -45,7 +44,6 @@
|
||||
// When you are done, you will notice four trace files in your directory:
|
||||
// two for the remaining energy on each node and two for the state transitions
|
||||
// of each node.
|
||||
//
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
@@ -80,8 +78,6 @@ void PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy
|
||||
f << Simulator::Now ().GetSeconds () << " state=" << state << " start=" << start << " duration=" << duration << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::string dataRate = "1Mbps";
|
||||
@@ -97,9 +93,7 @@ int main (int argc, char *argv[])
|
||||
double txCurrent = 0.380; // Ampere
|
||||
bool verbose = false;
|
||||
|
||||
|
||||
CommandLine cmd;
|
||||
|
||||
cmd.AddValue ("dataRate", "Data rate", dataRate);
|
||||
cmd.AddValue ("packetSize", "size of application packet sent", packetSize);
|
||||
cmd.AddValue ("duration", "duration (seconds) of the experiment", duration);
|
||||
@@ -112,10 +106,8 @@ int main (int argc, char *argv[])
|
||||
cmd.AddValue ("idleCurrent", "The radio Idle current in Ampere", idleCurrent);
|
||||
cmd.AddValue ("txCurrent", "The radio Tx current in Ampere", txCurrent);
|
||||
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (2);
|
||||
|
||||
@@ -236,4 +228,3 @@ int main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -454,7 +454,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNode);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
@@ -463,21 +462,21 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
/* Setting applications */
|
||||
ApplicationContainer serverApp, sinkApp;
|
||||
ApplicationContainer serverApp;
|
||||
if (udp)
|
||||
{
|
||||
//UDP flow
|
||||
UdpServerHelper myServer (9);
|
||||
serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (1000));
|
||||
myClient.SetAttribute ("Interval", TimeValue (MilliSeconds (5)));
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
@@ -485,25 +484,22 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
//TCP flow
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
sinkApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
|
||||
serverApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ());
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
|
||||
ApplicationContainer apps;
|
||||
|
||||
AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
apps.Add (onoff.Install (wifiApNode.Get (0)));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
Config::ConnectWithoutContext ("/NodeList/0/DeviceList/*/Phy/MonitorSnifferRx", MakeCallback (&MonitorSniffRx));
|
||||
@@ -522,7 +518,7 @@ int main (int argc, char *argv[])
|
||||
Simulator::Run ();
|
||||
|
||||
double throughput = 0;
|
||||
uint32_t totalPacketsThrough = 0;
|
||||
uint64_t totalPacketsThrough = 0;
|
||||
if (udp)
|
||||
{
|
||||
//UDP
|
||||
@@ -532,7 +528,7 @@ int main (int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
//TCP
|
||||
uint32_t totalBytesRx = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
uint32_t totalBytesRx = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
|
||||
totalPacketsThrough = totalBytesRx / tcpPacketSize;
|
||||
throughput = totalBytesRx * 8 / (simulationTime * 1000000.0); //Mbit/s
|
||||
}
|
||||
|
||||
@@ -266,7 +266,6 @@ int main (int argc, char *argv[])
|
||||
NS_FATAL_ERROR ("Unsupported WiFi type " << wifiType);
|
||||
}
|
||||
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
WifiMacHelper mac;
|
||||
@@ -485,7 +484,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNode);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
@@ -494,21 +492,21 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
/* Setting applications */
|
||||
ApplicationContainer serverApp, sinkApp;
|
||||
ApplicationContainer serverApp;
|
||||
if (udp)
|
||||
{
|
||||
//UDP flow
|
||||
UdpServerHelper myServer (9);
|
||||
serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (1000));
|
||||
myClient.SetAttribute ("Interval", TimeValue (MilliSeconds (5)));
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
@@ -516,28 +514,25 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
//TCP flow
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
sinkApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
|
||||
serverApp = packetSinkHelper.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ());
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
|
||||
ApplicationContainer apps;
|
||||
|
||||
AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
apps.Add (onoff.Install (wifiApNode.Get (0)));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (simulationTime + 1));
|
||||
ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
// Configure waveform generator
|
||||
|
||||
// Configure waveform generator
|
||||
Ptr<SpectrumValue> wgPsd = Create<SpectrumValue> (SpectrumModelWifi5180MHz);
|
||||
*wgPsd = waveformPower / (100 * 180000);
|
||||
NS_LOG_INFO ("wgPsd : " << *wgPsd << " integrated power: " << Integral (*(GetPointer (wgPsd))));
|
||||
@@ -593,7 +588,7 @@ int main (int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
//TCP
|
||||
uint32_t totalBytesRx = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
uint32_t totalBytesRx = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
|
||||
totalPacketsThrough = totalBytesRx / tcpPacketSize;
|
||||
throughput = totalBytesRx * 8 / (simulationTime * 1000000.0); //Mbit/s
|
||||
}
|
||||
|
||||
@@ -272,7 +272,6 @@ int main (int argc, char *argv[])
|
||||
NS_FATAL_ERROR ("Unsupported WiFi type " << wifiType);
|
||||
}
|
||||
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
WifiMacHelper mac;
|
||||
@@ -657,7 +656,6 @@ int main (int argc, char *argv[])
|
||||
stack.Install (wifiStaNode);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
@@ -666,19 +664,17 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
/* Setting applications */
|
||||
ApplicationContainer serverApp, sinkApp;
|
||||
//UDP flow
|
||||
UdpServerHelper myServer (9);
|
||||
serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
ApplicationContainer serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
// * *
|
||||
// | |
|
||||
// n1 n2
|
||||
//
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -139,12 +138,13 @@ int main (int argc, char *argv[])
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
//Setting applications
|
||||
UdpServerHelper myServer (9);
|
||||
ApplicationContainer serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
uint16_t port = 9;
|
||||
UdpServerHelper server (port);
|
||||
ApplicationContainer serverApp = server.Install (wifiStaNode.Get (0));
|
||||
serverApp.Start (Seconds (0.0));
|
||||
serverApp.Stop (Seconds (simulationTime));
|
||||
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), 9);
|
||||
UdpClientHelper client (staNodeInterface.GetAddress (0), port);
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (1472)); //bytes
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//
|
||||
// Default network topology includes some number of AP nodes specified by
|
||||
// the variable nWifis (defaults to two). Off of each AP node, there are some
|
||||
// number of STA nodes specified by the variable nStas (defaults to two).
|
||||
@@ -41,7 +40,6 @@
|
||||
// +---------+ +---------+
|
||||
// | AP Node | | AP Node |
|
||||
// +---------+ +---------+
|
||||
//
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
@@ -120,7 +118,6 @@ int main (int argc, char *argv[])
|
||||
"GridWidth", UintegerValue (1),
|
||||
"LayoutType", StringValue ("RowFirst"));
|
||||
|
||||
|
||||
// setup the AP.
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (backboneNodes.Get (i));
|
||||
|
||||
Reference in New Issue
Block a user