examples: Clean wireless examples
This commit is contained in:
@@ -85,85 +85,85 @@ int main (int argc, char *argv[])
|
||||
WifiHelper wifi; //the default standard of 802.11a will be selected by this helper since the program doesn't specify another one
|
||||
wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
|
||||
WifiMacHelper mac;
|
||||
|
||||
|
||||
NetDeviceContainer staDeviceA, staDeviceB, staDeviceC, staDeviceD, apDeviceA, apDeviceB, apDeviceC, apDeviceD;
|
||||
Ssid ssid;
|
||||
|
||||
//Network A
|
||||
ssid = Ssid ("network-A");
|
||||
phy.Set ("ChannelNumber", UintegerValue(36));
|
||||
phy.Set ("ChannelNumber", UintegerValue (36));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
staDeviceA = wifi.Install (phy, mac, wifiStaNode.Get(0));
|
||||
staDeviceA = wifi.Install (phy, mac, wifiStaNode.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, wifiApNode.Get (0));
|
||||
|
||||
//Network B
|
||||
ssid = Ssid ("network-B");
|
||||
phy.Set ("ChannelNumber", UintegerValue(40));
|
||||
phy.Set ("ChannelNumber", UintegerValue (40));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNode.Get(1));
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNode.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, wifiApNode.Get (1));
|
||||
|
||||
//Modify EDCA configuration (TXOP limit) for AC_BE
|
||||
Ptr<NetDevice> dev = wifiApNode.Get(1)->GetDevice(0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice>(dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac();
|
||||
Ptr<NetDevice> dev = wifiApNode.Get (1)->GetDevice (0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
|
||||
PointerValue ptr;
|
||||
Ptr<EdcaTxopN> edca;
|
||||
wifi_mac->GetAttribute("BE_EdcaTxopN", ptr);
|
||||
edca = ptr.Get<EdcaTxopN>();
|
||||
wifi_mac->GetAttribute ("BE_EdcaTxopN", ptr);
|
||||
edca = ptr.Get<EdcaTxopN> ();
|
||||
edca->SetTxopLimit (MicroSeconds (3008));
|
||||
|
||||
|
||||
//Network C
|
||||
ssid = Ssid ("network-C");
|
||||
phy.Set ("ChannelNumber", UintegerValue(44));
|
||||
phy.Set ("ChannelNumber", UintegerValue (44));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
staDeviceC = wifi.Install (phy, mac, wifiStaNode.Get(2));
|
||||
staDeviceC = wifi.Install (phy, mac, wifiStaNode.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, wifiApNode.Get (2));
|
||||
|
||||
//Network D
|
||||
ssid = Ssid ("network-D");
|
||||
phy.Set ("ChannelNumber", UintegerValue(48));
|
||||
phy.Set ("ChannelNumber", UintegerValue (48));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
staDeviceD = wifi.Install (phy, mac, wifiStaNode.Get(3));
|
||||
staDeviceD = wifi.Install (phy, mac, wifiStaNode.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, wifiApNode.Get (3));
|
||||
|
||||
//Modify EDCA configuration (TXOP limit) for AC_VO
|
||||
dev = wifiApNode.Get(3)->GetDevice(0);
|
||||
wifi_dev = DynamicCast<WifiNetDevice>(dev);
|
||||
wifi_mac = wifi_dev->GetMac();
|
||||
wifi_mac->GetAttribute("VI_EdcaTxopN", ptr);
|
||||
edca = ptr.Get<EdcaTxopN>();
|
||||
dev = wifiApNode.Get (3)->GetDevice (0);
|
||||
wifi_dev = DynamicCast<WifiNetDevice> (dev);
|
||||
wifi_mac = wifi_dev->GetMac ();
|
||||
wifi_mac->GetAttribute ("VI_EdcaTxopN", ptr);
|
||||
edca = ptr.Get<EdcaTxopN> ();
|
||||
edca->SetTxopLimit (MicroSeconds (0));
|
||||
|
||||
/* Setting mobility model */
|
||||
@@ -183,7 +183,7 @@ int main (int argc, char *argv[])
|
||||
positionAlloc->Add (Vector (30 + distance, 0.0, 0.0));
|
||||
//Remark: while we set these positions 10 meters apart, the networks do not interact
|
||||
//and the only variable that affects transmission performance is the distance.
|
||||
|
||||
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.Install (wifiApNode);
|
||||
mobility.Install (wifiStaNode);
|
||||
@@ -200,19 +200,19 @@ int main (int argc, char *argv[])
|
||||
StaInterfaceA = address.Assign (staDeviceA);
|
||||
Ipv4InterfaceContainer ApInterfaceA;
|
||||
ApInterfaceA = address.Assign (apDeviceA);
|
||||
|
||||
|
||||
address.SetBase ("192.168.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceB;
|
||||
StaInterfaceB = address.Assign (staDeviceB);
|
||||
Ipv4InterfaceContainer ApInterfaceB;
|
||||
ApInterfaceB = address.Assign (apDeviceB);
|
||||
|
||||
|
||||
address.SetBase ("192.168.3.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceC;
|
||||
StaInterfaceC = address.Assign (staDeviceC);
|
||||
Ipv4InterfaceContainer ApInterfaceC;
|
||||
ApInterfaceC = address.Assign (apDeviceC);
|
||||
|
||||
|
||||
address.SetBase ("192.168.4.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceD;
|
||||
StaInterfaceD = address.Assign (staDeviceD);
|
||||
@@ -224,20 +224,20 @@ int main (int argc, char *argv[])
|
||||
ApplicationContainer serverAppA = myServerA.Install (wifiApNode.Get (0));
|
||||
serverAppA.Start (Seconds (0.0));
|
||||
serverAppA.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
InetSocketAddress destA (ApInterfaceA.GetAddress (0), 5001);
|
||||
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));
|
||||
myClientA.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientA.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppA = myClientA.Install (wifiStaNode.Get (0));
|
||||
clientAppA.Start (Seconds (1.0));
|
||||
clientAppA.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
UdpServerHelper myServerB (5001);
|
||||
ApplicationContainer serverAppB = myServerB.Install (wifiApNode.Get (1));
|
||||
serverAppB.Start (Seconds (0.0));
|
||||
@@ -249,13 +249,13 @@ int main (int argc, char *argv[])
|
||||
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));
|
||||
myClientB.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientB.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppB = myClientB.Install (wifiStaNode.Get (1));
|
||||
clientAppB.Start (Seconds (1.0));
|
||||
clientAppB.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
UdpServerHelper myServerC (5001);
|
||||
ApplicationContainer serverAppC = myServerC.Install (wifiApNode.Get (2));
|
||||
serverAppC.Start (Seconds (0.0));
|
||||
@@ -267,13 +267,13 @@ int main (int argc, char *argv[])
|
||||
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));
|
||||
myClientC.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientC.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppC = myClientC.Install (wifiStaNode.Get (2));
|
||||
clientAppC.Start (Seconds (1.0));
|
||||
clientAppC.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
UdpServerHelper myServerD (5001);
|
||||
ApplicationContainer serverAppD = myServerD.Install (wifiApNode.Get (3));
|
||||
serverAppD.Start (Seconds (0.0));
|
||||
@@ -285,13 +285,13 @@ int main (int argc, char *argv[])
|
||||
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));
|
||||
myClientD.SetAttribute ("DataRate", StringValue ("100000kb/s"));
|
||||
myClientD.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
|
||||
ApplicationContainer clientAppD = myClientD.Install (wifiStaNode.Get (3));
|
||||
clientAppD.Start (Seconds (1.0));
|
||||
clientAppD.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
if (enablePcap)
|
||||
{
|
||||
phy.EnablePcap ("AP_A", apDeviceA.Get (0));
|
||||
|
||||
@@ -43,7 +43,7 @@ using namespace ns3;
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::ofstream file ("80211n-mimo-throughput.plt");
|
||||
|
||||
|
||||
std::vector <std::string> modes;
|
||||
modes.push_back ("HtMcs0");
|
||||
modes.push_back ("HtMcs1");
|
||||
@@ -77,7 +77,7 @@ int main (int argc, char *argv[])
|
||||
modes.push_back ("HtMcs29");
|
||||
modes.push_back ("HtMcs30");
|
||||
modes.push_back ("HtMcs31");
|
||||
|
||||
|
||||
bool udp = true;
|
||||
double simulationTime = 5; //seconds
|
||||
double frequency = 5.0; //whether 2.4 or 5.0 GHz
|
||||
@@ -101,7 +101,7 @@ int main (int argc, char *argv[])
|
||||
Gnuplot2dDataset dataset (modes[i]);
|
||||
for (int d = 0; d <= 100; ) //distance
|
||||
{
|
||||
std::cout << "Distance = " << d << "m: "<< std::endl;
|
||||
std::cout << "Distance = " << d << "m: " << std::endl;
|
||||
uint32_t payloadSize; //1500 byte IP packet
|
||||
if (udp)
|
||||
{
|
||||
@@ -112,7 +112,7 @@ int main (int argc, char *argv[])
|
||||
payloadSize = 1448; //bytes
|
||||
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (payloadSize));
|
||||
}
|
||||
|
||||
|
||||
uint8_t nStreams = 1 + (i / 8); //number of MIMO streams
|
||||
|
||||
NodeContainer wifiStaNode;
|
||||
@@ -144,13 +144,13 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Wrong frequency value!"<<std::endl;
|
||||
std::cout << "Wrong frequency value!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue (modes[i]),
|
||||
"ControlMode", StringValue (modes[i]));
|
||||
|
||||
|
||||
Ssid ssid = Ssid ("ns3-80211n");
|
||||
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
@@ -194,7 +194,7 @@ int main (int argc, char *argv[])
|
||||
address.SetBase ("192.168.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer staNodeInterface;
|
||||
Ipv4InterfaceContainer apNodeInterface;
|
||||
|
||||
|
||||
staNodeInterface = address.Assign (staDevice);
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
@@ -243,7 +243,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
|
||||
|
||||
Simulator::Stop (Seconds (simulationTime + 1));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
@@ -262,7 +262,7 @@ int main (int argc, char *argv[])
|
||||
throughput = totalPacketsThrough * 8 / (simulationTime * 1000000.0); //Mbit/s
|
||||
}
|
||||
dataset.Add (d, throughput);
|
||||
std::cout << throughput << " Mbit/s" <<std::endl;
|
||||
std::cout << throughput << " Mbit/s" << std::endl;
|
||||
d += step;
|
||||
}
|
||||
plot.AddDataset (dataset);
|
||||
|
||||
@@ -83,7 +83,7 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
uint8_t index = 0;
|
||||
double previous = 0;
|
||||
for (int channelWidth = 20; channelWidth <= 40;)
|
||||
for (int channelWidth = 20; channelWidth <= 40; )
|
||||
{
|
||||
for (int sgi = 0; sgi < 2; sgi++)
|
||||
{
|
||||
@@ -123,7 +123,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Wrong frequency value!"<<std::endl;
|
||||
std::cout << "Wrong frequency value!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ int main (int argc, char *argv[])
|
||||
oss << "HtMcs" << mcs;
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue (oss.str ()),
|
||||
"ControlMode", StringValue (oss.str ()));
|
||||
|
||||
|
||||
Ssid ssid = Ssid ("ns3-80211n");
|
||||
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
|
||||
@@ -95,14 +95,14 @@ Experiment::Run (Parameters params)
|
||||
{
|
||||
std::string apTypeString;
|
||||
if (params.apType == WIFI_PHY_STANDARD_80211g)
|
||||
{
|
||||
apTypeString = "WIFI_PHY_STANDARD_80211g";
|
||||
}
|
||||
{
|
||||
apTypeString = "WIFI_PHY_STANDARD_80211g";
|
||||
}
|
||||
else if (params.apType == WIFI_PHY_STANDARD_80211n_2_4GHZ)
|
||||
{
|
||||
apTypeString = "WIFI_PHY_STANDARD_80211n_2_4GHZ";
|
||||
}
|
||||
|
||||
{
|
||||
apTypeString = "WIFI_PHY_STANDARD_80211n_2_4GHZ";
|
||||
}
|
||||
|
||||
std::cout << "Run: " << params.testName
|
||||
<< "\n\t enableErpProtection=" << params.enableErpProtection
|
||||
<< "\n\t erpProtectionMode=" << params.erpProtectionMode
|
||||
@@ -121,7 +121,7 @@ Experiment::Run (Parameters params)
|
||||
<< "\n\t nWifiNGreenfield=" << params.nWifiNGreenfield
|
||||
<< "\n\t nGreenfieldHasTraffic=" << params.nGreenfieldHasTraffic
|
||||
<< std::endl;
|
||||
|
||||
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::ErpProtectionMode", StringValue (params.erpProtectionMode));
|
||||
|
||||
double throughput = 0;
|
||||
@@ -163,18 +163,18 @@ Experiment::Run (Parameters params)
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
|
||||
|
||||
|
||||
// Configure the PLCP preamble type: long or short
|
||||
phy.Set ("ShortPlcpPreambleSupported", BooleanValue (params.enableShortPlcpPreamble));
|
||||
|
||||
NetDeviceContainer bStaDevice;
|
||||
bStaDevice = wifi.Install (phy, mac, wifiBStaNodes);
|
||||
|
||||
|
||||
// 802.11b/g STA
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
|
||||
NetDeviceContainer gStaDevice;
|
||||
gStaDevice = wifi.Install (phy, mac, wifiGStaNodes);
|
||||
|
||||
|
||||
// 802.11b/g/n STA
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ);
|
||||
NetDeviceContainer nNGFStaDevice, nGFStaDevice;
|
||||
@@ -188,7 +188,7 @@ Experiment::Run (Parameters params)
|
||||
nNGFStaDevice = wifi.Install (phy, mac, wifiNNGFStaNodes);
|
||||
phy.Set ("GreenfieldEnabled", BooleanValue (true));
|
||||
nGFStaDevice = wifi.Install (phy, mac, wifiNGFStaNodes);
|
||||
|
||||
|
||||
// AP
|
||||
NetDeviceContainer apDevice;
|
||||
wifi.SetStandard (params.apType);
|
||||
@@ -206,57 +206,57 @@ Experiment::Run (Parameters params)
|
||||
|
||||
// Set TXOP limit
|
||||
if (params.apType == WIFI_PHY_STANDARD_80211n_2_4GHZ)
|
||||
{
|
||||
Ptr<NetDevice> dev = wifiApNode.Get(0)->GetDevice(0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice>(dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac();
|
||||
PointerValue ptr;
|
||||
wifi_mac->GetAttribute("BE_EdcaTxopN", ptr);
|
||||
Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN>();
|
||||
edca->SetTxopLimit (MicroSeconds (3008));
|
||||
}
|
||||
{
|
||||
Ptr<NetDevice> dev = wifiApNode.Get (0)->GetDevice (0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
|
||||
PointerValue ptr;
|
||||
wifi_mac->GetAttribute ("BE_EdcaTxopN", ptr);
|
||||
Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
|
||||
edca->SetTxopLimit (MicroSeconds (3008));
|
||||
}
|
||||
if (nWifiNNGF > 0)
|
||||
{
|
||||
Ptr<NetDevice> dev = wifiNNGFStaNodes.Get(0)->GetDevice(0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice>(dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac();
|
||||
PointerValue ptr;
|
||||
wifi_mac->GetAttribute("BE_EdcaTxopN", ptr);
|
||||
Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN>();
|
||||
edca->SetTxopLimit (MicroSeconds (3008));
|
||||
}
|
||||
{
|
||||
Ptr<NetDevice> dev = wifiNNGFStaNodes.Get (0)->GetDevice (0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
|
||||
PointerValue ptr;
|
||||
wifi_mac->GetAttribute ("BE_EdcaTxopN", ptr);
|
||||
Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
|
||||
edca->SetTxopLimit (MicroSeconds (3008));
|
||||
}
|
||||
if (nWifiNGF > 0)
|
||||
{
|
||||
Ptr<NetDevice> dev = wifiNGFStaNodes.Get(0)->GetDevice(0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice>(dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac();
|
||||
PointerValue ptr;
|
||||
wifi_mac->GetAttribute("BE_EdcaTxopN", ptr);
|
||||
Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN>();
|
||||
edca->SetTxopLimit (MicroSeconds (3008));
|
||||
}
|
||||
{
|
||||
Ptr<NetDevice> dev = wifiNGFStaNodes.Get (0)->GetDevice (0);
|
||||
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
|
||||
Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
|
||||
PointerValue ptr;
|
||||
wifi_mac->GetAttribute ("BE_EdcaTxopN", ptr);
|
||||
Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
|
||||
edca->SetTxopLimit (MicroSeconds (3008));
|
||||
}
|
||||
|
||||
// Define mobility model
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
|
||||
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
for (uint32_t i = 0; i < nWifiB; i++)
|
||||
{
|
||||
positionAlloc->Add (Vector (5.0, 0.0, 0.0));
|
||||
}
|
||||
{
|
||||
positionAlloc->Add (Vector (5.0, 0.0, 0.0));
|
||||
}
|
||||
for (uint32_t i = 0; i < nWifiG; i++)
|
||||
{
|
||||
positionAlloc->Add (Vector (0.0, 5.0, 0.0));
|
||||
}
|
||||
{
|
||||
positionAlloc->Add (Vector (0.0, 5.0, 0.0));
|
||||
}
|
||||
for (uint32_t i = 0; i < nWifiNNGF; i++)
|
||||
{
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 5.0));
|
||||
}
|
||||
{
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 5.0));
|
||||
}
|
||||
for (uint32_t i = 0; i < nWifiNGF; i++)
|
||||
{
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 5.0));
|
||||
}
|
||||
{
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 5.0));
|
||||
}
|
||||
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
@@ -314,25 +314,25 @@ Experiment::Run (Parameters params)
|
||||
clientAppG.Start (Seconds (1.0));
|
||||
clientAppG.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
|
||||
if (params.nNonGreenfieldHasTraffic)
|
||||
{
|
||||
ApplicationContainer clientAppNNGF = myClient.Install (wifiNNGFStaNodes);
|
||||
clientAppNNGF.Start (Seconds (1.0));
|
||||
clientAppNNGF.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
|
||||
if (params.nGreenfieldHasTraffic)
|
||||
{
|
||||
ApplicationContainer clientAppNGF = myClient.Install (wifiNGFStaNodes);
|
||||
clientAppNGF.Start (Seconds (1.0));
|
||||
clientAppNGF.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
|
||||
Simulator::Stop (Seconds (simulationTime + 1));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
|
||||
totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
|
||||
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
|
||||
}
|
||||
@@ -341,7 +341,7 @@ Experiment::Run (Parameters params)
|
||||
uint16_t port = 50000;
|
||||
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress);
|
||||
|
||||
|
||||
ApplicationContainer sinkApp = packetSinkHelper.Install (wifiApNode.Get (0));
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (simulationTime + 1));
|
||||
@@ -351,10 +351,10 @@ Experiment::Run (Parameters params)
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (150000000)); //bit/s
|
||||
|
||||
|
||||
AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), port));
|
||||
onoff.SetAttribute ("Remote", remoteAddress);
|
||||
|
||||
|
||||
ApplicationContainer apps;
|
||||
if (params.bHasTraffic)
|
||||
{
|
||||
@@ -384,11 +384,11 @@ Experiment::Run (Parameters params)
|
||||
Simulator::Stop (Seconds (simulationTime + 1));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
|
||||
totalPacketsThrough = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
|
||||
throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
|
||||
}
|
||||
|
||||
|
||||
return throughput;
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ int main (int argc, char *argv[])
|
||||
params.simulationTime = 10; //seconds
|
||||
|
||||
bool verifyResults = 0; //used for regression
|
||||
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("payloadSize", "Payload size in bytes", params.payloadSize);
|
||||
cmd.AddValue ("simulationTime", "Simulation time in seconds", params.simulationTime);
|
||||
@@ -516,7 +516,7 @@ int main (int argc, char *argv[])
|
||||
exit (1);
|
||||
}
|
||||
std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
|
||||
|
||||
|
||||
params.testName = "Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
|
||||
params.enableErpProtection = true;
|
||||
params.enableShortSlotTime = false;
|
||||
@@ -663,7 +663,7 @@ int main (int argc, char *argv[])
|
||||
exit (1);
|
||||
}
|
||||
std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
|
||||
|
||||
|
||||
params.testName = "Mixed HT/non-HT with RIFS enabled but not forbidden";
|
||||
params.enableErpProtection = false;
|
||||
params.enableShortSlotTime = false;
|
||||
@@ -687,7 +687,7 @@ int main (int argc, char *argv[])
|
||||
exit (1);
|
||||
}
|
||||
std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
|
||||
|
||||
|
||||
params.testName = "Mixed HT/non-HT with RIFS enabled but forbidden";
|
||||
params.enableErpProtection = false;
|
||||
params.enableShortSlotTime = false;
|
||||
@@ -711,6 +711,6 @@ int main (int argc, char *argv[])
|
||||
exit (1);
|
||||
}
|
||||
std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
//
|
||||
// This ns-3 example demonstrates the use of helper functions to ease
|
||||
// This ns-3 example demonstrates the use of helper functions to ease
|
||||
// the construction of simulation scenarios.
|
||||
//
|
||||
//
|
||||
// The simulation topology consists of a mixed wired and wireless
|
||||
// scenario in which a hierarchical mobility model is used.
|
||||
//
|
||||
@@ -36,7 +36,7 @@
|
||||
//
|
||||
// +--------------------------------------------------------+
|
||||
// | |
|
||||
// | 802.11 ad hoc, ns-2 mobility |
|
||||
// | 802.11 ad hoc, ns-2 mobility |
|
||||
// | |
|
||||
// +--------------------------------------------------------+
|
||||
// | o o o (N backbone routers) |
|
||||
@@ -54,9 +54,9 @@
|
||||
// We'll send data from the first wired LAN node on the first wired LAN
|
||||
// to the last wireless STA on the last infrastructure net, thereby
|
||||
// causing packets to traverse CSMA to adhoc to infrastructure links
|
||||
//
|
||||
//
|
||||
// Note that certain mobility patterns may cause packet forwarding
|
||||
// to fail (if nodes become disconnected)
|
||||
// to fail (if nodes become disconnected)
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/applications-module.h"
|
||||
@@ -77,7 +77,7 @@ NS_LOG_COMPONENT_DEFINE ("MixedWireless");
|
||||
//
|
||||
// This function will be used below as a trace sink, if the command-line
|
||||
// argument or default value "useCourseChangeCallback" is set to true
|
||||
//
|
||||
//
|
||||
static void
|
||||
CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
|
||||
{
|
||||
@@ -85,11 +85,11 @@ CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
|
||||
std::cout << "CourseChange " << path << " x=" << position.x << ", y=" << position.y << ", z=" << position.z << std::endl;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
//
|
||||
// First, we declare and initialize a few local variables that control some
|
||||
// First, we declare and initialize a few local variables that control some
|
||||
// simulation parameters.
|
||||
//
|
||||
uint32_t backboneNodes = 10;
|
||||
@@ -107,7 +107,7 @@ main (int argc, char *argv[])
|
||||
|
||||
//
|
||||
// For convenience, we add the local variables to the command line argument
|
||||
// system so that they can be overridden with flags such as
|
||||
// system so that they can be overridden with flags such as
|
||||
// "--backboneNodes=20"
|
||||
//
|
||||
CommandLine cmd;
|
||||
@@ -128,11 +128,11 @@ main (int argc, char *argv[])
|
||||
std::cout << "Use a simulation stop time >= 10 seconds" << std::endl;
|
||||
exit (1);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Construct the backbone //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Create a container to manage the nodes of the adhoc (backbone) network.
|
||||
@@ -141,7 +141,7 @@ main (int argc, char *argv[])
|
||||
NodeContainer backbone;
|
||||
backbone.Create (backboneNodes);
|
||||
//
|
||||
// Create the backbone wifi net devices and install them into the nodes in
|
||||
// Create the backbone wifi net devices and install them into the nodes in
|
||||
// our container
|
||||
//
|
||||
WifiHelper wifi;
|
||||
@@ -174,7 +174,7 @@ main (int argc, char *argv[])
|
||||
ipAddrs.Assign (backboneDevices);
|
||||
|
||||
//
|
||||
// The ad-hoc network nodes need a mobility model so we aggregate one to
|
||||
// The ad-hoc network nodes need a mobility model so we aggregate one to
|
||||
// each of the nodes we just finished building.
|
||||
//
|
||||
MobilityHelper mobility;
|
||||
@@ -191,11 +191,11 @@ main (int argc, char *argv[])
|
||||
"Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"));
|
||||
mobility.Install (backbone);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Construct the LANs //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Reset the address base-- all of the CSMA networks will be in
|
||||
// the "172.16 address space
|
||||
@@ -215,11 +215,11 @@ main (int argc, char *argv[])
|
||||
// Now, create the container with all nodes on this link
|
||||
NodeContainer lan (backbone.Get (i), newLanNodes);
|
||||
//
|
||||
// Create the CSMA net devices and install them into the nodes in our
|
||||
// Create the CSMA net devices and install them into the nodes in our
|
||||
// collection.
|
||||
//
|
||||
CsmaHelper csma;
|
||||
csma.SetChannelAttribute ("DataRate",
|
||||
csma.SetChannelAttribute ("DataRate",
|
||||
DataRateValue (DataRate (5000000)));
|
||||
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
|
||||
NetDeviceContainer lanDevices = csma.Install (lan);
|
||||
@@ -228,7 +228,7 @@ main (int argc, char *argv[])
|
||||
//
|
||||
internet.Install (newLanNodes);
|
||||
//
|
||||
// Assign IPv4 addresses to the device drivers (actually to the
|
||||
// Assign IPv4 addresses to the device drivers (actually to the
|
||||
// associated IPv4 interfaces) we just created.
|
||||
//
|
||||
ipAddrs.Assign (lanDevices);
|
||||
@@ -242,11 +242,11 @@ main (int argc, char *argv[])
|
||||
// to each of the nodes we just finished building.
|
||||
//
|
||||
MobilityHelper mobilityLan;
|
||||
Ptr<ListPositionAllocator> subnetAlloc =
|
||||
Ptr<ListPositionAllocator> subnetAlloc =
|
||||
CreateObject<ListPositionAllocator> ();
|
||||
for (uint32_t j = 0; j < newLanNodes.GetN (); ++j)
|
||||
{
|
||||
subnetAlloc->Add (Vector (0.0, j*10 + 10, 0.0));
|
||||
subnetAlloc->Add (Vector (0.0, j * 10 + 10, 0.0));
|
||||
}
|
||||
mobilityLan.PushReferenceMobilityModel (backbone.Get (i));
|
||||
mobilityLan.SetPositionAllocator (subnetAlloc);
|
||||
@@ -254,11 +254,11 @@ main (int argc, char *argv[])
|
||||
mobilityLan.Install (newLanNodes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Construct the mobile networks //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Reset the address base-- all of the 802.11 networks will be in
|
||||
// the "10.0" address space
|
||||
@@ -297,7 +297,7 @@ main (int argc, char *argv[])
|
||||
macInfra.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true),
|
||||
"BeaconInterval", TimeValue(Seconds(2.5)));
|
||||
"BeaconInterval", TimeValue (Seconds (2.5)));
|
||||
NetDeviceContainer apDevices = wifiInfra.Install (wifiPhy, macInfra, backbone.Get (i));
|
||||
// Collect all of these new devices
|
||||
NetDeviceContainer infraDevices (apDevices, staDevices);
|
||||
@@ -311,15 +311,15 @@ main (int argc, char *argv[])
|
||||
//
|
||||
ipAddrs.Assign (infraDevices);
|
||||
//
|
||||
// Assign a new network prefix for each mobile network, according to
|
||||
// Assign a new network prefix for each mobile network, according to
|
||||
// the network mask initialized above
|
||||
//
|
||||
ipAddrs.NewNetwork ();
|
||||
//
|
||||
// The new wireless nodes need a mobility model so we aggregate one
|
||||
// The new wireless nodes need a mobility model so we aggregate one
|
||||
// to each of the nodes we just finished building.
|
||||
//
|
||||
Ptr<ListPositionAllocator> subnetAlloc =
|
||||
Ptr<ListPositionAllocator> subnetAlloc =
|
||||
CreateObject<ListPositionAllocator> ();
|
||||
for (uint32_t j = 0; j < infra.GetN (); ++j)
|
||||
{
|
||||
@@ -334,11 +334,11 @@ main (int argc, char *argv[])
|
||||
mobility.Install (stas);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Application configuration //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 10 Kb/s, between two nodes
|
||||
@@ -356,12 +356,12 @@ main (int argc, char *argv[])
|
||||
// Conveniently, the variable "backboneNodes" holds this node index value
|
||||
Ptr<Node> appSource = NodeList::GetNode (backboneNodes);
|
||||
// We want the sink to be the last node created in the topology.
|
||||
uint32_t lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backboneNodes*(infraNodes - 1) - 1;
|
||||
uint32_t lastNodeIndex = backboneNodes + backboneNodes * (lanNodes - 1) + backboneNodes * (infraNodes - 1) - 1;
|
||||
Ptr<Node> appSink = NodeList::GetNode (lastNodeIndex);
|
||||
// Let's fetch the IP address of the last node, which is on Ipv4Interface 1
|
||||
Ipv4Address remoteAddr = appSink->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
|
||||
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (remoteAddr, port)));
|
||||
|
||||
ApplicationContainer apps = onoff.Install (appSource);
|
||||
@@ -369,16 +369,16 @@ main (int argc, char *argv[])
|
||||
apps.Stop (Seconds (stopTime - 1));
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
apps = sink.Install (appSink);
|
||||
apps.Start (Seconds (3));
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Tracing configuration //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_LOG_INFO ("Configure Tracing.");
|
||||
CsmaHelper csma;
|
||||
@@ -406,11 +406,11 @@ main (int argc, char *argv[])
|
||||
|
||||
AnimationInterface anim ("mixed-wireless.xml");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Run simulation //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Stop (Seconds (stopTime));
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*
|
||||
* QUICK INSTRUCTIONS:
|
||||
*
|
||||
* To optimize build:
|
||||
* To optimize build:
|
||||
* ./waf -d optimized configure
|
||||
* ./waf
|
||||
*
|
||||
@@ -64,24 +64,40 @@ NS_LOG_COMPONENT_DEFINE ("multirate");
|
||||
class Experiment
|
||||
{
|
||||
public:
|
||||
|
||||
Experiment ();
|
||||
Experiment (std::string name);
|
||||
Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
|
||||
const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility);
|
||||
|
||||
bool CommandSetup (int argc, char **argv);
|
||||
bool IsRouting () { return (enableRouting == 1) ? 1 : 0; }
|
||||
bool IsMobility () { return (enableMobility == 1) ? 1 : 0; }
|
||||
bool IsRouting ()
|
||||
{
|
||||
return (enableRouting == 1) ? 1 : 0;
|
||||
}
|
||||
bool IsMobility ()
|
||||
{
|
||||
return (enableMobility == 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
uint32_t GetScenario () { return scenario; }
|
||||
uint32_t GetScenario ()
|
||||
{
|
||||
return scenario;
|
||||
}
|
||||
|
||||
std::string GetRtsThreshold () { return rtsThreshold; }
|
||||
std::string GetOutputFileName () { return outputFileName; }
|
||||
std::string GetRateManager () { return rateManager; }
|
||||
std::string GetRtsThreshold ()
|
||||
{
|
||||
return rtsThreshold;
|
||||
}
|
||||
std::string GetOutputFileName ()
|
||||
{
|
||||
return outputFileName;
|
||||
}
|
||||
std::string GetRateManager ()
|
||||
{
|
||||
return rateManager;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Ptr<Socket> SetupPacketReceive (Ptr<Node> node);
|
||||
NodeContainer GenerateNeighbors (NodeContainer c, uint32_t senderId);
|
||||
|
||||
@@ -94,13 +110,13 @@ private:
|
||||
|
||||
Gnuplot2dDataset m_output;
|
||||
|
||||
double totalTime;
|
||||
double totalTime;
|
||||
double expMean;
|
||||
double samplingPeriod;
|
||||
|
||||
uint32_t bytesTotal;
|
||||
uint32_t packetSize;
|
||||
uint32_t gridSize;
|
||||
uint32_t gridSize;
|
||||
uint32_t nodeDistance;
|
||||
uint32_t port;
|
||||
uint32_t scenario;
|
||||
@@ -111,7 +127,7 @@ private:
|
||||
bool enableRouting;
|
||||
bool enableMobility;
|
||||
|
||||
NodeContainer containerA, containerB, containerC, containerD;
|
||||
NodeContainer containerA, containerB, containerC, containerD;
|
||||
std::string rtsThreshold, rateManager, outputFileName;
|
||||
};
|
||||
|
||||
@@ -119,25 +135,28 @@ Experiment::Experiment ()
|
||||
{
|
||||
}
|
||||
|
||||
Experiment::Experiment (std::string name) :
|
||||
m_output (name),
|
||||
totalTime (0.3),
|
||||
expMean (0.1), //flows being exponentially distributed
|
||||
samplingPeriod(0.1),
|
||||
bytesTotal (0),
|
||||
packetSize (2000),
|
||||
gridSize (10), //10x10 grid for a total of 100 nodes
|
||||
nodeDistance (30),
|
||||
port (5000),
|
||||
scenario (4),
|
||||
enablePcap (false),
|
||||
enableTracing (true),
|
||||
enableFlowMon (false),
|
||||
enableRouting (false),
|
||||
enableMobility (false),
|
||||
rtsThreshold ("2200"), //0 for enabling rts/cts
|
||||
rateManager ("ns3::MinstrelWifiManager"),
|
||||
outputFileName ("minstrel")
|
||||
Experiment::Experiment (std::string name)
|
||||
: m_output (name),
|
||||
totalTime (0.3),
|
||||
expMean (0.1),
|
||||
//flows being exponentially distributed
|
||||
samplingPeriod (0.1),
|
||||
bytesTotal (0),
|
||||
packetSize (2000),
|
||||
gridSize (10),
|
||||
//10x10 grid for a total of 100 nodes
|
||||
nodeDistance (30),
|
||||
port (5000),
|
||||
scenario (4),
|
||||
enablePcap (false),
|
||||
enableTracing (true),
|
||||
enableFlowMon (false),
|
||||
enableRouting (false),
|
||||
enableMobility (false),
|
||||
rtsThreshold ("2200"),
|
||||
//0 for enabling rts/cts
|
||||
rateManager ("ns3::MinstrelWifiManager"),
|
||||
outputFileName ("minstrel")
|
||||
{
|
||||
m_output.SetStyle (Gnuplot2dDataset::LINES);
|
||||
}
|
||||
@@ -167,7 +186,7 @@ Experiment::ReceivePacket (Ptr<Socket> socket)
|
||||
void
|
||||
Experiment::CheckThroughput ()
|
||||
{
|
||||
double mbs = ((bytesTotal * 8.0) /1000000 /samplingPeriod);
|
||||
double mbs = ((bytesTotal * 8.0) / 1000000 / samplingPeriod);
|
||||
bytesTotal = 0;
|
||||
m_output.Add ((Simulator::Now ()).GetSeconds (), mbs);
|
||||
|
||||
@@ -178,39 +197,39 @@ Experiment::CheckThroughput ()
|
||||
/**
|
||||
*
|
||||
* Take the grid map, divide it into 4 quadrants
|
||||
* Assign all nodes from each quadrant to a specific container
|
||||
*
|
||||
* Assign all nodes from each quadrant to a specific container
|
||||
*
|
||||
*/
|
||||
void
|
||||
Experiment::AssignNeighbors (NodeContainer c)
|
||||
{
|
||||
uint32_t totalNodes = c.GetN ();
|
||||
for (uint32_t i=0; i< totalNodes; i++)
|
||||
for (uint32_t i = 0; i < totalNodes; i++)
|
||||
{
|
||||
if ( (i % gridSize) <= (gridSize/2 - 1))
|
||||
if ( (i % gridSize) <= (gridSize / 2 - 1))
|
||||
{
|
||||
//lower left quadrant
|
||||
if ( i < totalNodes/2 )
|
||||
if ( i < totalNodes / 2 )
|
||||
{
|
||||
containerA.Add (c.Get (i));
|
||||
}
|
||||
|
||||
//upper left quadrant
|
||||
if ( i >= (uint32_t)(4*totalNodes)/10 )
|
||||
if ( i >= (uint32_t)(4 * totalNodes) / 10 )
|
||||
{
|
||||
containerC.Add (c.Get (i));
|
||||
}
|
||||
}
|
||||
if ( (i % gridSize) >= (gridSize/2 - 1))
|
||||
if ( (i % gridSize) >= (gridSize / 2 - 1))
|
||||
{
|
||||
//lower right quadrant
|
||||
if ( i < totalNodes/2 )
|
||||
if ( i < totalNodes / 2 )
|
||||
{
|
||||
containerB.Add (c.Get (i));
|
||||
}
|
||||
|
||||
//upper right quadrant
|
||||
if ( i >= (uint32_t)(4*totalNodes)/10 )
|
||||
if ( i >= (uint32_t)(4 * totalNodes) / 10 )
|
||||
{
|
||||
containerD.Add (c.Get (i));
|
||||
}
|
||||
@@ -227,7 +246,7 @@ Experiment::GenerateNeighbors (NodeContainer c, uint32_t senderId)
|
||||
{
|
||||
NodeContainer nc;
|
||||
uint32_t limit = senderId + 2;
|
||||
for (uint32_t i= senderId - 2; i <= limit; i++)
|
||||
for (uint32_t i = senderId - 2; i <= limit; i++)
|
||||
{
|
||||
//must ensure the boundaries for other topologies
|
||||
nc.Add (c.Get (i));
|
||||
@@ -240,9 +259,9 @@ Experiment::GenerateNeighbors (NodeContainer c, uint32_t senderId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sources and destinations are randomly selected such that a node
|
||||
* may be the source for multiple destinations and a node maybe a destination
|
||||
* for multiple sources.
|
||||
* Sources and destinations are randomly selected such that a node
|
||||
* may be the source for multiple destinations and a node maybe a destination
|
||||
* for multiple sources.
|
||||
*/
|
||||
void
|
||||
Experiment::SelectSrcDest (NodeContainer c)
|
||||
@@ -250,12 +269,12 @@ Experiment::SelectSrcDest (NodeContainer c)
|
||||
uint32_t totalNodes = c.GetN ();
|
||||
Ptr<UniformRandomVariable> uvSrc = CreateObject<UniformRandomVariable> ();
|
||||
uvSrc->SetAttribute ("Min", DoubleValue (0));
|
||||
uvSrc->SetAttribute ("Max", DoubleValue (totalNodes/2 -1));
|
||||
uvSrc->SetAttribute ("Max", DoubleValue (totalNodes / 2 - 1));
|
||||
Ptr<UniformRandomVariable> uvDest = CreateObject<UniformRandomVariable> ();
|
||||
uvDest->SetAttribute ("Min", DoubleValue (totalNodes/2));
|
||||
uvDest->SetAttribute ("Min", DoubleValue (totalNodes / 2));
|
||||
uvDest->SetAttribute ("Max", DoubleValue (totalNodes));
|
||||
|
||||
for (uint32_t i=0; i < totalNodes/3; i++)
|
||||
for (uint32_t i = 0; i < totalNodes / 3; i++)
|
||||
{
|
||||
ApplicationSetup (c.Get (uvSrc->GetInteger ()), c.Get (uvDest->GetInteger ()), 0, totalTime);
|
||||
}
|
||||
@@ -281,23 +300,25 @@ Experiment::SendMultiDestinations (Ptr<Node> sender, NodeContainer c)
|
||||
ev->SetAttribute ("Mean", DoubleValue (expMean));
|
||||
ev->SetAttribute ("Bound", DoubleValue (totalTime));
|
||||
|
||||
double start=0.0, stop;
|
||||
double start = 0.0, stop;
|
||||
uint32_t destIndex;
|
||||
|
||||
for (uint32_t i=0; i < c.GetN (); i++)
|
||||
for (uint32_t i = 0; i < c.GetN (); i++)
|
||||
{
|
||||
stop = start + ev->GetValue ();
|
||||
NS_LOG_DEBUG ("Start=" << start << " Stop=" << stop);
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
destIndex = (uint32_t) uv->GetValue ();
|
||||
} while ( (c.Get (destIndex))->GetId () == sender->GetId ());
|
||||
}
|
||||
while ( (c.Get (destIndex))->GetId () == sender->GetId ());
|
||||
|
||||
ApplicationSetup (sender, c.Get (destIndex), start, stop);
|
||||
|
||||
start = stop;
|
||||
|
||||
if(start > totalTime)
|
||||
if (start > totalTime)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -317,8 +338,8 @@ PrintPosition (Ptr<Node> client, Ptr<Node> server)
|
||||
Vector serverPos = GetPosition (server);
|
||||
Vector clientPos = GetPosition (client);
|
||||
|
||||
Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4>();
|
||||
Ptr<Ipv4> ipv4Client = client->GetObject<Ipv4>();
|
||||
Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4Client = client->GetObject<Ipv4> ();
|
||||
|
||||
Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0);
|
||||
Ipv4InterfaceAddress iaddrClient = ipv4Client->GetAddress (1,0);
|
||||
@@ -328,13 +349,13 @@ PrintPosition (Ptr<Node> client, Ptr<Node> server)
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "Set up Server Device " << (server->GetDevice (0))->GetAddress ()
|
||||
<< " with ip " << ipv4AddrServer
|
||||
<< " position (" << serverPos.x << "," << serverPos.y << "," << serverPos.z << ")";
|
||||
<< " with ip " << ipv4AddrServer
|
||||
<< " position (" << serverPos.x << "," << serverPos.y << "," << serverPos.z << ")";
|
||||
|
||||
oss << "Set up Client Device " << (client->GetDevice (0))->GetAddress ()
|
||||
<< " with ip " << ipv4AddrClient
|
||||
<< " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")"
|
||||
<< "\n";
|
||||
<< " with ip " << ipv4AddrClient
|
||||
<< " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")"
|
||||
<< "\n";
|
||||
return oss.str ();
|
||||
}
|
||||
|
||||
@@ -348,7 +369,7 @@ Experiment::ApplicationSetup (Ptr<Node> client, Ptr<Node> server, double start,
|
||||
|
||||
NS_LOG_DEBUG (PrintPosition (client, server));
|
||||
|
||||
// Equipping the source node with OnOff Application used for sending
|
||||
// Equipping the source node with OnOff Application used for sending
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address ("10.0.0.1"), port)));
|
||||
onoff.SetConstantRate (DataRate (60000000));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (packetSize));
|
||||
@@ -368,7 +389,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
|
||||
{
|
||||
|
||||
|
||||
uint32_t nodeSize = gridSize*gridSize;
|
||||
uint32_t nodeSize = gridSize * gridSize;
|
||||
NodeContainer c;
|
||||
c.Create (nodeSize);
|
||||
|
||||
@@ -405,7 +426,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
|
||||
Ipv4InterfaceContainer ipInterfaces;
|
||||
ipInterfaces = address.Assign (devices);
|
||||
|
||||
MobilityHelper mobil= mobility;
|
||||
MobilityHelper mobil = mobility;
|
||||
mobil.SetPositionAllocator ("ns3::GridPositionAllocator",
|
||||
"MinX", DoubleValue (0.0),
|
||||
"MinY", DoubleValue (0.0),
|
||||
@@ -437,9 +458,9 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
|
||||
else if ( scenario == 2)
|
||||
{
|
||||
//All flows begin at the same time
|
||||
for (uint32_t i = 0; i < nodeSize - 1; i = i+2)
|
||||
for (uint32_t i = 0; i < nodeSize - 1; i = i + 2)
|
||||
{
|
||||
ApplicationSetup (c.Get (i), c.Get (i+1), 0, totalTime);
|
||||
ApplicationSetup (c.Get (i), c.Get (i + 1), 0, totalTime);
|
||||
}
|
||||
}
|
||||
else if ( scenario == 3)
|
||||
@@ -447,7 +468,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
|
||||
AssignNeighbors (c);
|
||||
//Note: these senders are hand-picked in order to ensure good coverage
|
||||
//for 10x10 grid, basically one sender for each quadrant
|
||||
//you might have to change these values for other grids
|
||||
//you might have to change these values for other grids
|
||||
NS_LOG_DEBUG (">>>>>>>>>region A<<<<<<<<<");
|
||||
SendMultiDestinations (c.Get (22), containerA);
|
||||
|
||||
@@ -464,18 +485,18 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
|
||||
{
|
||||
//GenerateNeighbors(NodeContainer, uint32_t sender)
|
||||
//Note: these senders are hand-picked in order to ensure good coverage
|
||||
//you might have to change these values for other grids
|
||||
//you might have to change these values for other grids
|
||||
NodeContainer c1, c2, c3, c4, c5, c6, c7, c8, c9;
|
||||
|
||||
c1 = GenerateNeighbors (c, 22);
|
||||
c2 = GenerateNeighbors (c, 24);;
|
||||
c3 = GenerateNeighbors (c, 26);;
|
||||
c4 = GenerateNeighbors (c, 42);;
|
||||
c5 = GenerateNeighbors (c, 44);;
|
||||
c6 = GenerateNeighbors (c, 46);;
|
||||
c7 = GenerateNeighbors (c, 62);;
|
||||
c8 = GenerateNeighbors (c, 64);;
|
||||
c9 = GenerateNeighbors (c, 66);;
|
||||
c2 = GenerateNeighbors (c, 24);
|
||||
c3 = GenerateNeighbors (c, 26);
|
||||
c4 = GenerateNeighbors (c, 42);
|
||||
c5 = GenerateNeighbors (c, 44);
|
||||
c6 = GenerateNeighbors (c, 46);
|
||||
c7 = GenerateNeighbors (c, 62);
|
||||
c8 = GenerateNeighbors (c, 64);
|
||||
c9 = GenerateNeighbors (c, 66);
|
||||
|
||||
SendMultiDestinations (c.Get (22), c1);
|
||||
SendMultiDestinations (c.Get (24), c2);
|
||||
@@ -531,11 +552,11 @@ Experiment::CommandSetup (int argc, char **argv)
|
||||
// according to totalTime, select an appropriate samplingPeriod automatically.
|
||||
if (totalTime < 1.0)
|
||||
{
|
||||
samplingPeriod = 0.1;
|
||||
samplingPeriod = 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
samplingPeriod = 1.0;
|
||||
samplingPeriod = 1.0;
|
||||
}
|
||||
// or user selects a samplingPeriod.
|
||||
cmd.AddValue ("samplingPeriod", "sampling period", samplingPeriod);
|
||||
@@ -563,7 +584,7 @@ int main (int argc, char *argv[])
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue (experiment.GetRtsThreshold ()));
|
||||
|
||||
std::ofstream outfile ((experiment.GetOutputFileName ()+ ".plt").c_str ());
|
||||
std::ofstream outfile ((experiment.GetOutputFileName () + ".plt").c_str ());
|
||||
|
||||
MobilityHelper mobility;
|
||||
Gnuplot gnuplot;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* and ns3::AparfWifiManager.
|
||||
*
|
||||
* The output of this is typically two plot files, named throughput-parf.plt
|
||||
* (or throughput-aparf.plt, if Aparf is used) and power-parf.plt If
|
||||
* (or throughput-aparf.plt, if Aparf is used) and power-parf.plt If
|
||||
* Gnuplot program is available, one can use it to convert the plt file
|
||||
* into an eps file, by running:
|
||||
* \code{.sh}
|
||||
@@ -38,10 +38,10 @@
|
||||
*
|
||||
* This simulation consist of 2 nodes, one AP and one STA.
|
||||
* The AP generates UDP traffic with a CBR of 54 Mbps to the STA.
|
||||
* The AP can use any power and rate control mechanism and the STA uses
|
||||
* The AP can use any power and rate control mechanism and the STA uses
|
||||
* only Minstrel rate control.
|
||||
* The STA can be configured to move away from (or towards to) the AP.
|
||||
* By default, the AP is at coordinate (0,0,0) and the STA starts at
|
||||
* By default, the AP is at coordinate (0,0,0) and the STA starts at
|
||||
* coordinate (5,0,0) (meters) and moves away on the x axis by 1 meter every
|
||||
* second.
|
||||
*
|
||||
@@ -52,11 +52,11 @@
|
||||
*
|
||||
* The Average Transmit Power is defined as an average of the power
|
||||
* consumed per measurement interval, expressed in milliwatts. The
|
||||
* power level for each frame transmission is reported by the simulator,
|
||||
* power level for each frame transmission is reported by the simulator,
|
||||
* and the energy consumed is obtained by multiplying the power by the
|
||||
* frame duration. At every 'stepTime' (defaulting to 1 second), the
|
||||
* total energy for the collection period is divided by the step time
|
||||
* and converted from dbm to milliwatt units, and this average is
|
||||
* total energy for the collection period is divided by the step time
|
||||
* and converted from dbm to milliwatt units, and this average is
|
||||
* plotted against time.
|
||||
*
|
||||
* When neither Parf nor Aparf is selected as the rate control, the
|
||||
@@ -68,7 +68,7 @@
|
||||
* \code{.sh}
|
||||
* ./waf --run "power-adaptation-distance --help"
|
||||
* \endcode
|
||||
*
|
||||
*
|
||||
* Example usage (selecting Aparf rather than Parf):
|
||||
* \code{.sh}
|
||||
* ./waf --run "power-adaptation-distance --manager=ns3::AparfWifiManager --outputFileName=aparf"
|
||||
@@ -192,7 +192,7 @@ NodeStatistics::PhyCallback (std::string path, Ptr<const Packet> packet)
|
||||
packet->PeekHeader (head);
|
||||
Mac48Address dest = head.GetAddr1 ();
|
||||
|
||||
if (head.GetType() == WIFI_MAC_DATA)
|
||||
if (head.GetType () == WIFI_MAC_DATA)
|
||||
{
|
||||
totalEnergy += pow (10.0, actualPower[dest] / 10.0) * GetCalcTxTime (actualMode[dest]).GetSeconds ();
|
||||
totalTime += GetCalcTxTime (actualMode[dest]).GetSeconds ();
|
||||
@@ -386,7 +386,7 @@ int main (int argc, char *argv[])
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (wifiApNodes.Get (0));
|
||||
mobility.Install (wifiStaNodes.Get (0));
|
||||
|
||||
|
||||
//Statistics counter
|
||||
NodeStatistics statistics = NodeStatistics (wifiApDevices, wifiStaDevices);
|
||||
|
||||
@@ -450,8 +450,8 @@ int main (int argc, char *argv[])
|
||||
gnuplot.AddDataset (statistics.GetDatafile ());
|
||||
gnuplot.GenerateOutput (outfile);
|
||||
|
||||
if (manager.compare ("ns3::ParfWifiManager") == 0 ||
|
||||
manager.compare ("ns3::AparfWifiManager") == 0)
|
||||
if (manager.compare ("ns3::ParfWifiManager") == 0
|
||||
|| manager.compare ("ns3::AparfWifiManager") == 0)
|
||||
{
|
||||
std::ofstream outfile2 (("power-" + outputFileName + ".plt").c_str ());
|
||||
gnuplot = Gnuplot (("power-" + outputFileName + ".eps").c_str (), "Average Transmit Power");
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
*
|
||||
* This simulation consist of 4 nodes, two APs and two STAs.
|
||||
* The APs generates UDP traffic with a CBR of 54 Mbps to the STAs.
|
||||
* The APa use any power and rate control mechanism, and the STAs use only
|
||||
* The APa use any power and rate control mechanism, and the STAs use only
|
||||
* Minstrel rate control.
|
||||
* The STAs can be configured to be at any distance from the APs.
|
||||
*
|
||||
* The objective is to test power and rate control in the links with
|
||||
* The objective is to test power and rate control in the links with
|
||||
* interference from the other link.
|
||||
*
|
||||
* The output consists of:
|
||||
@@ -190,7 +190,7 @@ NodeStatistics::PhyCallback (std::string path, Ptr<const Packet> packet)
|
||||
packet->PeekHeader (head);
|
||||
Mac48Address dest = head.GetAddr1 ();
|
||||
|
||||
if (head.GetType() == WIFI_MAC_DATA)
|
||||
if (head.GetType () == WIFI_MAC_DATA)
|
||||
{
|
||||
totalEnergy += pow (10.0, actualPower[dest] / 10.0) * GetCalcTxTime (actualMode[dest]).GetSeconds ();
|
||||
totalTime += GetCalcTxTime (actualMode[dest]).GetSeconds ();
|
||||
@@ -565,8 +565,8 @@ int main (int argc, char *argv[])
|
||||
gnuplot.AddDataset (statisticsAp0.GetDatafile ());
|
||||
gnuplot.GenerateOutput (outfileTh0);
|
||||
|
||||
if (manager.compare ("ns3::ParfWifiManager") == 0 ||
|
||||
manager.compare ("ns3::AparfWifiManager") == 0)
|
||||
if (manager.compare ("ns3::ParfWifiManager") == 0
|
||||
|| manager.compare ("ns3::AparfWifiManager") == 0)
|
||||
{
|
||||
std::ofstream outfilePower0 (("power-" + outputFileName + "-0.plt").c_str ());
|
||||
gnuplot = Gnuplot (("power-" + outputFileName + "-0.eps").c_str (), "Average Transmit Power");
|
||||
@@ -575,7 +575,7 @@ int main (int argc, char *argv[])
|
||||
gnuplot.SetTitle ("Average transmit power (AP0 to STA) vs time");
|
||||
gnuplot.AddDataset (statisticsAp0.GetPowerDatafile ());
|
||||
gnuplot.GenerateOutput (outfilePower0);
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream outfileTx0 (("tx-" + outputFileName + "-0.plt").c_str ());
|
||||
gnuplot = Gnuplot (("tx-" + outputFileName + "-0.eps").c_str (), "Time in TX State");
|
||||
@@ -618,8 +618,8 @@ int main (int argc, char *argv[])
|
||||
gnuplot.AddDataset (statisticsAp1.GetDatafile ());
|
||||
gnuplot.GenerateOutput (outfileTh1);
|
||||
|
||||
if (manager.compare ("ns3::ParfWifiManager") == 0 ||
|
||||
manager.compare ("ns3::AparfWifiManager") == 0)
|
||||
if (manager.compare ("ns3::ParfWifiManager") == 0
|
||||
|| manager.compare ("ns3::AparfWifiManager") == 0)
|
||||
{
|
||||
std::ofstream outfilePower1 (("power-" + outputFileName + "-1.plt").c_str ());
|
||||
gnuplot = Gnuplot (("power-" + outputFileName + "-1.eps").c_str (), "Average Transmit Power");
|
||||
@@ -628,7 +628,7 @@ int main (int argc, char *argv[])
|
||||
gnuplot.SetTitle ("Average transmit power (AP1 to STA) vs time");
|
||||
gnuplot.AddDataset (statisticsAp1.GetPowerDatafile ());
|
||||
gnuplot.GenerateOutput (outfilePower1);
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream outfileTx1 (("tx-" + outputFileName + "-1.plt").c_str ());
|
||||
gnuplot = Gnuplot (("tx-" + outputFileName + "-1.eps").c_str (), "Time in TX State");
|
||||
|
||||
@@ -187,7 +187,7 @@ int main (int argc, char *argv[])
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
|
||||
wifiPhy.Set("ShortGuardEnabled", BooleanValue(shortGuardInterval));
|
||||
wifiPhy.Set ("ShortGuardEnabled", BooleanValue (shortGuardInterval));
|
||||
|
||||
NetDeviceContainer wifiApDevices;
|
||||
NetDeviceContainer wifiStaDevices;
|
||||
|
||||
@@ -80,7 +80,7 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
uint8_t index = 0;
|
||||
double previous = 0;
|
||||
for (int channelWidth = 20; channelWidth <= 160;)
|
||||
for (int channelWidth = 20; channelWidth <= 160; )
|
||||
{
|
||||
if (mcs == 9 && channelWidth == 20)
|
||||
{
|
||||
@@ -115,12 +115,12 @@ int main (int argc, char *argv[])
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
|
||||
WifiMacHelper mac;
|
||||
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "VhtMcs" << mcs;
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue (oss.str ()),
|
||||
"ControlMode", StringValue (oss.str ()));
|
||||
|
||||
|
||||
Ssid ssid = Ssid ("ns3-80211ac");
|
||||
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
|
||||
@@ -71,15 +71,15 @@ Experiment::GetPosition (Ptr<Node> node)
|
||||
return mobility->GetPosition ();
|
||||
}
|
||||
|
||||
void
|
||||
Experiment::AdvancePosition (Ptr<Node> node)
|
||||
void
|
||||
Experiment::AdvancePosition (Ptr<Node> node)
|
||||
{
|
||||
Vector pos = GetPosition (node);
|
||||
double mbs = ((m_bytesTotal * 8.0) / 1000000);
|
||||
m_bytesTotal = 0;
|
||||
m_output.Add (pos.x, mbs);
|
||||
pos.x += 1.0;
|
||||
if (pos.x >= 210.0)
|
||||
if (pos.x >= 210.0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ int main (int argc, char *argv[])
|
||||
cmd.AddValue ("enablePcap", "Enable/disable pcap file generation", enablePcap);
|
||||
cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", enableRts ? StringValue ("0") : StringValue ("999999"));
|
||||
|
||||
NodeContainer wifiStaNode;
|
||||
@@ -96,65 +96,65 @@ int main (int argc, char *argv[])
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("HtMcs7"), "ControlMode", StringValue ("HtMcs0"));
|
||||
WifiMacHelper mac;
|
||||
|
||||
|
||||
NetDeviceContainer staDeviceA, staDeviceB, staDeviceC, staDeviceD, apDeviceA, apDeviceB, apDeviceC, apDeviceD;
|
||||
Ssid ssid;
|
||||
|
||||
//Network A
|
||||
ssid = Ssid ("network-A");
|
||||
phy.Set ("ChannelNumber", UintegerValue(36));
|
||||
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, wifiStaNode.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, wifiApNode.Get (0));
|
||||
|
||||
//Network B
|
||||
ssid = Ssid ("network-B");
|
||||
phy.Set ("ChannelNumber", UintegerValue(40));
|
||||
phy.Set ("ChannelNumber", UintegerValue (40));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BE_MaxAmpduSize", UintegerValue (0)); //Disable A-MPDU
|
||||
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNode.Get(1));
|
||||
staDeviceB = wifi.Install (phy, mac, wifiStaNode.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, wifiApNode.Get (1));
|
||||
|
||||
//Network C
|
||||
ssid = Ssid ("network-C");
|
||||
phy.Set ("ChannelNumber", UintegerValue(44));
|
||||
phy.Set ("ChannelNumber", UintegerValue (44));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"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, wifiStaNode.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, wifiApNode.Get (2));
|
||||
|
||||
//Network D
|
||||
ssid = Ssid ("network-D");
|
||||
phy.Set ("ChannelNumber", UintegerValue(48));
|
||||
phy.Set ("ChannelNumber", UintegerValue (48));
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"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, wifiStaNode.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, wifiApNode.Get (3));
|
||||
|
||||
/* Setting mobility model */
|
||||
MobilityHelper mobility;
|
||||
@@ -171,7 +171,7 @@ int main (int argc, char *argv[])
|
||||
positionAlloc->Add (Vector (10 + distance, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (20 + distance, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (30 + distance, 0.0, 0.0));
|
||||
|
||||
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.Install (wifiApNode);
|
||||
mobility.Install (wifiStaNode);
|
||||
@@ -188,19 +188,19 @@ int main (int argc, char *argv[])
|
||||
StaInterfaceA = address.Assign (staDeviceA);
|
||||
Ipv4InterfaceContainer ApInterfaceA;
|
||||
ApInterfaceA = address.Assign (apDeviceA);
|
||||
|
||||
|
||||
address.SetBase ("192.168.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceB;
|
||||
StaInterfaceB = address.Assign (staDeviceB);
|
||||
Ipv4InterfaceContainer ApInterfaceB;
|
||||
ApInterfaceB = address.Assign (apDeviceB);
|
||||
|
||||
|
||||
address.SetBase ("192.168.3.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceC;
|
||||
StaInterfaceC = address.Assign (staDeviceC);
|
||||
Ipv4InterfaceContainer ApInterfaceC;
|
||||
ApInterfaceC = address.Assign (apDeviceC);
|
||||
|
||||
|
||||
address.SetBase ("192.168.4.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer StaInterfaceD;
|
||||
StaInterfaceD = address.Assign (staDeviceD);
|
||||
@@ -221,7 +221,7 @@ int main (int argc, char *argv[])
|
||||
ApplicationContainer clientAppA = myClientA.Install (wifiApNode.Get (0));
|
||||
clientAppA.Start (Seconds (1.0));
|
||||
clientAppA.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
UdpServerHelper myServerB (9);
|
||||
ApplicationContainer serverAppB = myServerB.Install (wifiStaNode.Get (1));
|
||||
serverAppB.Start (Seconds (0.0));
|
||||
@@ -235,7 +235,7 @@ int main (int argc, char *argv[])
|
||||
ApplicationContainer clientAppB = myClientB.Install (wifiApNode.Get (1));
|
||||
clientAppB.Start (Seconds (1.0));
|
||||
clientAppB.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
UdpServerHelper myServerC (9);
|
||||
ApplicationContainer serverAppC = myServerC.Install (wifiStaNode.Get (2));
|
||||
serverAppC.Start (Seconds (0.0));
|
||||
@@ -249,7 +249,7 @@ int main (int argc, char *argv[])
|
||||
ApplicationContainer clientAppC = myClientC.Install (wifiApNode.Get (2));
|
||||
clientAppC.Start (Seconds (1.0));
|
||||
clientAppC.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
UdpServerHelper myServerD (9);
|
||||
ApplicationContainer serverAppD = myServerD.Install (wifiStaNode.Get (3));
|
||||
serverAppD.Start (Seconds (0.0));
|
||||
@@ -263,7 +263,7 @@ int main (int argc, char *argv[])
|
||||
ApplicationContainer clientAppD = myClientD.Install (wifiApNode.Get (3));
|
||||
clientAppD.Start (Seconds (1.0));
|
||||
clientAppD.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
if (enablePcap)
|
||||
{
|
||||
phy.EnablePcap ("AP_A", apDeviceA.Get (0));
|
||||
@@ -289,7 +289,7 @@ int main (int argc, char *argv[])
|
||||
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
totalPacketsThrough = DynamicCast<UdpServer> (serverAppB.Get (0))->GetReceived ();
|
||||
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
|
||||
std::cout << "Throughput with aggregation disabled: " << throughput << " Mbit/s" << '\n';
|
||||
|
||||
@@ -92,12 +92,12 @@ GetPosition (Ptr<Node> node)
|
||||
return mobility->GetPosition ();
|
||||
}
|
||||
|
||||
static void
|
||||
AdvancePosition (Ptr<Node> node)
|
||||
static void
|
||||
AdvancePosition (Ptr<Node> node)
|
||||
{
|
||||
Vector pos = GetPosition (node);
|
||||
pos.x += 5.0;
|
||||
if (pos.x >= 210.0)
|
||||
if (pos.x >= 210.0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,17 +120,17 @@ int main (int argc, char *argv[])
|
||||
Ssid ssid = Ssid ("ns3");
|
||||
|
||||
wifi.SetStandard (ConvertStringToStandard (staVersion));
|
||||
wifi.SetRemoteStationManager ("ns3::"+staRaa+"WifiManager");
|
||||
|
||||
wifi.SetRemoteStationManager ("ns3::" + staRaa + "WifiManager");
|
||||
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
|
||||
NetDeviceContainer staDevice;
|
||||
staDevice = wifi.Install (phy, mac, wifiStaNode);
|
||||
|
||||
|
||||
wifi.SetStandard (ConvertStringToStandard (apVersion));
|
||||
wifi.SetRemoteStationManager ("ns3::"+apRaa+"WifiManager");
|
||||
wifi.SetRemoteStationManager ("ns3::" + apRaa + "WifiManager");
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
@@ -176,7 +176,7 @@ int main (int argc, char *argv[])
|
||||
ApplicationContainer apServerApp = apServer.Install (wifiApNode.Get (0));
|
||||
apServerApp.Start (Seconds (0.0));
|
||||
apServerApp.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
UdpServerHelper staServer (5001);
|
||||
ApplicationContainer staServerApp = staServer.Install (wifiStaNode.Get (0));
|
||||
staServerApp.Start (Seconds (0.0));
|
||||
@@ -192,7 +192,7 @@ int main (int argc, char *argv[])
|
||||
apClientApp.Start (Seconds (1.0));
|
||||
apClientApp.Stop (Seconds (simulationTime + 1));
|
||||
}
|
||||
|
||||
|
||||
if (staHasTraffic)
|
||||
{
|
||||
UdpClientHelper staClient (apNodeInterface.GetAddress (0), 9);
|
||||
@@ -218,10 +218,10 @@ int main (int argc, char *argv[])
|
||||
throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
|
||||
std::cout << "AP Throughput: " << throughput << " Mbit/s" << std::endl;
|
||||
if (throughput == 0)
|
||||
{
|
||||
NS_LOG_ERROR ("No traffic received!");
|
||||
exit (1);
|
||||
}
|
||||
{
|
||||
NS_LOG_ERROR ("No traffic received!");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (staHasTraffic)
|
||||
{
|
||||
@@ -229,10 +229,10 @@ int main (int argc, char *argv[])
|
||||
throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
|
||||
std::cout << "STA Throughput: " << throughput << " Mbit/s" << std::endl;
|
||||
if (throughput == 0)
|
||||
{
|
||||
NS_LOG_ERROR ("No traffic received!");
|
||||
exit (1);
|
||||
}
|
||||
{
|
||||
NS_LOG_ERROR ("No traffic received!");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Copyright (c) 2009 MIRKO BANCHI
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
@@ -22,13 +22,13 @@
|
||||
* This is a simple example in order to show how 802.11e compressed block ack mechanism could be used.
|
||||
*
|
||||
* Network topology:
|
||||
*
|
||||
*
|
||||
* Wifi 192.168.1.0
|
||||
*
|
||||
*
|
||||
* AP
|
||||
* * *
|
||||
* | |
|
||||
* n1 n2
|
||||
* n1 n2
|
||||
*
|
||||
* In this example a QoS sta sends UDP datagram packets to access point. On the access point
|
||||
* there is no application installed so it replies to every packet with an ICMP frame. However
|
||||
@@ -37,7 +37,7 @@
|
||||
* negotiated. We also set a timeout for block ack inactivity to 3 blocks of 1024 microseconds. This timer is
|
||||
* reset when:
|
||||
* - the originator receives a block ack frame.
|
||||
* - the recipient receives a block ack request or a MPDU with ack policy Block Ack.
|
||||
* - the recipient receives a block ack request or a MPDU with ack policy Block Ack.
|
||||
*/
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
@@ -55,10 +55,10 @@ int main (int argc, char * argv[])
|
||||
{
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
|
||||
LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG);
|
||||
LogComponentEnable ("BlockAckManager", LOG_LEVEL_INFO);
|
||||
|
||||
|
||||
Ptr<Node> sta = CreateObject<Node> ();
|
||||
Ptr<Node> ap = CreateObject<Node> ();
|
||||
|
||||
@@ -76,9 +76,9 @@ int main (int argc, char * argv[])
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"QosSupported", BooleanValue (true),
|
||||
"Ssid", SsidValue (ssid),
|
||||
/* setting blockack threshold for sta's BE queue */
|
||||
/* setting blockack threshold for sta's BE queue */
|
||||
"BE_BlockAckThreshold", UintegerValue (2),
|
||||
/* setting block inactivity timeout to 3*1024 = 3072 microseconds */
|
||||
/* setting block inactivity timeout to 3*1024 = 3072 microseconds */
|
||||
"BE_BlockAckInactivityTimeout", UintegerValue (3));
|
||||
NetDeviceContainer staDevice = wifi.Install (phy, mac, sta);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
void SetPosition (Ptr<Node> node, Vector position);
|
||||
Vector GetPosition (Ptr<Node> node);
|
||||
Ptr<Socket> SetupPacketReceive (Ptr<Node> node);
|
||||
void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval );
|
||||
|
||||
uint32_t m_pktsTotal;
|
||||
@@ -93,14 +93,14 @@ Experiment::SetupPacketReceive (Ptr<Node> node)
|
||||
}
|
||||
|
||||
void
|
||||
Experiment::GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
Experiment::GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &Experiment::GenerateTraffic, this,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
Simulator::Schedule (pktInterval, &Experiment::GenerateTraffic, this,
|
||||
socket, pktSize,pktCount - 1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -149,7 +149,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
|
||||
uint32_t packetSize = 1014;
|
||||
uint32_t maxPacketCount = 200;
|
||||
Time interPacketInterval = Seconds (1.);
|
||||
Simulator::Schedule (Seconds (1.0), &Experiment::GenerateTraffic,
|
||||
Simulator::Schedule (Seconds (1.0), &Experiment::GenerateTraffic,
|
||||
this, source, packetSize, maxPacketCount,interPacketInterval);
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -185,7 +185,7 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
Experiment experiment;
|
||||
dataset.SetStyle (Gnuplot2dDataset::LINES);
|
||||
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
WifiMacHelper wifiMac;
|
||||
@@ -195,13 +195,13 @@ int main (int argc, char *argv[])
|
||||
"DataMode",StringValue (modes[i]),
|
||||
"ControlMode",StringValue (modes[i]));
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss));
|
||||
|
||||
|
||||
|
||||
|
||||
NS_LOG_DEBUG (modes[i]);
|
||||
experiment = Experiment (modes[i]);
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-110.0) );
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
* Classical hidden terminal problem and its RTS/CTS solution.
|
||||
*
|
||||
* Topology: [node 0] <-- -50 dB --> [node 1] <-- -50 dB --> [node 2]
|
||||
*
|
||||
* This example illustrates the use of
|
||||
*
|
||||
* This example illustrates the use of
|
||||
* - Wifi in ad-hoc mode
|
||||
* - Matrix propagation loss model
|
||||
* - Use of OnOffApplication to generate CBR stream
|
||||
* - Use of OnOffApplication to generate CBR stream
|
||||
* - IP flow monitor
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,7 @@ void experiment (bool enableCtsRts)
|
||||
UintegerValue ctsThr = (enableCtsRts ? UintegerValue (100) : UintegerValue (2200));
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", ctsThr);
|
||||
|
||||
// 1. Create 3 nodes
|
||||
// 1. Create 3 nodes
|
||||
NodeContainer nodes;
|
||||
nodes.Create (3);
|
||||
|
||||
@@ -60,8 +60,8 @@ void experiment (bool enableCtsRts)
|
||||
// 3. Create propagation loss matrix
|
||||
Ptr<MatrixPropagationLossModel> lossModel = CreateObject<MatrixPropagationLossModel> ();
|
||||
lossModel->SetDefaultLoss (200); // set default loss to 200 dB (no link)
|
||||
lossModel->SetLoss (nodes.Get (0)->GetObject<MobilityModel>(), nodes.Get (1)->GetObject<MobilityModel>(), 50); // set symmetric loss 0 <-> 1 to 50 dB
|
||||
lossModel->SetLoss (nodes.Get (2)->GetObject<MobilityModel>(), nodes.Get (1)->GetObject<MobilityModel>(), 50); // set symmetric loss 2 <-> 1 to 50 dB
|
||||
lossModel->SetLoss (nodes.Get (0)->GetObject<MobilityModel> (), nodes.Get (1)->GetObject<MobilityModel> (), 50); // set symmetric loss 0 <-> 1 to 50 dB
|
||||
lossModel->SetLoss (nodes.Get (2)->GetObject<MobilityModel> (), nodes.Get (1)->GetObject<MobilityModel> (), 50); // set symmetric loss 2 <-> 1 to 50 dB
|
||||
|
||||
// 4. Create & setup wifi channel
|
||||
Ptr<YansWifiChannel> wifiChannel = CreateObject <YansWifiChannel> ();
|
||||
@@ -71,8 +71,8 @@ void experiment (bool enableCtsRts)
|
||||
// 5. Install wireless devices
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue ("DsssRate2Mbps"),
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue ("DsssRate2Mbps"),
|
||||
"ControlMode",StringValue ("DsssRate1Mbps"));
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.SetChannel (wifiChannel);
|
||||
@@ -95,7 +95,7 @@ void experiment (bool enableCtsRts)
|
||||
ipv4.SetBase ("10.0.0.0", "255.0.0.0");
|
||||
ipv4.Assign (devices);
|
||||
|
||||
// 7. Install applications: two CBR streams each saturating the channel
|
||||
// 7. Install applications: two CBR streams each saturating the channel
|
||||
ApplicationContainer cbrApps;
|
||||
uint16_t cbrPort = 12345;
|
||||
OnOffHelper onOffHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address ("10.0.0.2"), cbrPort));
|
||||
@@ -106,7 +106,7 @@ void experiment (bool enableCtsRts)
|
||||
// flow 1: node 0 -> node 1
|
||||
onOffHelper.SetAttribute ("DataRate", StringValue ("3000000bps"));
|
||||
onOffHelper.SetAttribute ("StartTime", TimeValue (Seconds (1.000000)));
|
||||
cbrApps.Add (onOffHelper.Install (nodes.Get (0)));
|
||||
cbrApps.Add (onOffHelper.Install (nodes.Get (0)));
|
||||
|
||||
// flow 2: node 2 -> node 1
|
||||
/** \internal
|
||||
@@ -115,11 +115,11 @@ void experiment (bool enableCtsRts)
|
||||
*/
|
||||
onOffHelper.SetAttribute ("DataRate", StringValue ("3001100bps"));
|
||||
onOffHelper.SetAttribute ("StartTime", TimeValue (Seconds (1.001)));
|
||||
cbrApps.Add (onOffHelper.Install (nodes.Get (2)));
|
||||
cbrApps.Add (onOffHelper.Install (nodes.Get (2)));
|
||||
|
||||
/** \internal
|
||||
* We also use separate UDP applications that will send a single
|
||||
* packet before the CBR flows start.
|
||||
* packet before the CBR flows start.
|
||||
* This is a workaround for the lack of perfect ARP, see \bugid{187}
|
||||
*/
|
||||
uint16_t echoPort = 9;
|
||||
@@ -131,7 +131,7 @@ void experiment (bool enableCtsRts)
|
||||
|
||||
// again using different start times to workaround Bug 388 and Bug 912
|
||||
echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (0.001)));
|
||||
pingApps.Add (echoClientHelper.Install (nodes.Get (0)));
|
||||
pingApps.Add (echoClientHelper.Install (nodes.Get (0)));
|
||||
echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (0.006)));
|
||||
pingApps.Add (echoClientHelper.Install (nodes.Get (2)));
|
||||
|
||||
@@ -154,9 +154,9 @@ void experiment (bool enableCtsRts)
|
||||
{
|
||||
// first 2 FlowIds are for ECHO apps, we don't want to display them
|
||||
//
|
||||
// Duration for throughput measurement is 9.0 seconds, since
|
||||
// Duration for throughput measurement is 9.0 seconds, since
|
||||
// StartTime of the OnOffApplication is at about "second 1"
|
||||
// and
|
||||
// and
|
||||
// Simulator::Stops at "second 10".
|
||||
if (i->first > 2)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
|
||||
std::cout << "Hidden station experiment with RTS/CTS disabled:\n" << std::flush;
|
||||
experiment (false);
|
||||
std::cout << "------------------------------------------------\n";
|
||||
|
||||
@@ -43,7 +43,7 @@ int main (int argc, char *argv[])
|
||||
uint8_t channelWidth = 20; //MHz
|
||||
bool useShortGuardInterval = false;
|
||||
bool useRts = false;
|
||||
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("nWifi", "Number of stations", nWifi);
|
||||
cmd.AddValue ("distance", "Distance in meters between the stations and the access point", distance);
|
||||
@@ -76,7 +76,7 @@ int main (int argc, char *argv[])
|
||||
"DataMode", StringValue (oss.str ()),
|
||||
"ControlMode", StringValue (oss.str ()),
|
||||
"RtsCtsThreshold", UintegerValue (useRts ? 0 : 999999));
|
||||
|
||||
|
||||
Ssid ssid = Ssid ("ns3-80211n");
|
||||
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
@@ -98,10 +98,10 @@ int main (int argc, char *argv[])
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
for (uint32_t i = 0; i< nWifi; i++)
|
||||
{
|
||||
positionAlloc->Add (Vector (distance, 0.0, 0.0));
|
||||
}
|
||||
for (uint32_t i = 0; i < nWifi; i++)
|
||||
{
|
||||
positionAlloc->Add (Vector (distance, 0.0, 0.0));
|
||||
}
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (wifiApNode);
|
||||
@@ -124,29 +124,29 @@ int main (int argc, char *argv[])
|
||||
std::vector<uint8_t> tosValues = {0x70, 0x28, 0xb8, 0xc0}; //AC_BE, AC_BK, AC_VI, AC_VO
|
||||
uint32_t portNumber = 9;
|
||||
for (uint8_t index = 0; index < nWifi; ++index)
|
||||
{
|
||||
for (uint8_t tosValue : tosValues)
|
||||
{
|
||||
auto ipv4 = wifiApNode.Get (0)->GetObject<Ipv4> ();
|
||||
const auto address = ipv4->GetAddress (1, 0).GetLocal ();
|
||||
InetSocketAddress sinkSocket(address, portNumber++);
|
||||
sinkSocket.SetTos(tosValue);
|
||||
OnOffHelper onOffHelper ("ns3::UdpSocketFactory", sinkSocket);
|
||||
onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onOffHelper.SetAttribute ("DataRate", DataRateValue (50000000/nWifi));
|
||||
onOffHelper.SetAttribute ("PacketSize", UintegerValue (1472)); //bytes
|
||||
sourceApplications.Add (onOffHelper.Install (wifiStaNodes.Get (index)));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", sinkSocket);
|
||||
sinkApplications.Add (packetSinkHelper.Install (wifiApNode.Get (0)));
|
||||
for (uint8_t tosValue : tosValues)
|
||||
{
|
||||
auto ipv4 = wifiApNode.Get (0)->GetObject<Ipv4> ();
|
||||
const auto address = ipv4->GetAddress (1, 0).GetLocal ();
|
||||
InetSocketAddress sinkSocket (address, portNumber++);
|
||||
sinkSocket.SetTos (tosValue);
|
||||
OnOffHelper onOffHelper ("ns3::UdpSocketFactory", sinkSocket);
|
||||
onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
onOffHelper.SetAttribute ("DataRate", DataRateValue (50000000 / nWifi));
|
||||
onOffHelper.SetAttribute ("PacketSize", UintegerValue (1472)); //bytes
|
||||
sourceApplications.Add (onOffHelper.Install (wifiStaNodes.Get (index)));
|
||||
PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", sinkSocket);
|
||||
sinkApplications.Add (packetSinkHelper.Install (wifiApNode.Get (0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sinkApplications.Start (Seconds (0.0));
|
||||
sinkApplications.Stop (Seconds (simulationTime + 1));
|
||||
sourceApplications.Start (Seconds (1.0));
|
||||
sourceApplications.Stop (Seconds (simulationTime + 1));
|
||||
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
|
||||
Simulator::Stop (Seconds (simulationTime + 1));
|
||||
@@ -155,10 +155,10 @@ 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 ();
|
||||
throughput += ((totalPacketsThrough * 8) / (simulationTime * 1000000.0)); //Mbit/s
|
||||
}
|
||||
{
|
||||
uint32_t totalPacketsThrough = DynamicCast<PacketSink> (sinkApplications.Get (index))->GetTotalRx ();
|
||||
throughput += ((totalPacketsThrough * 8) / (simulationTime * 1000000.0)); //Mbit/s
|
||||
}
|
||||
if (throughput > 0)
|
||||
{
|
||||
std::cout << "Aggregated throughput: " << throughput << " Mbit/s" << std::endl;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
|
||||
//
|
||||
// This program configures a grid (default 5x5) of nodes on an
|
||||
// This program configures a grid (default 5x5) of nodes on an
|
||||
// 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000
|
||||
// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000
|
||||
// (application) bytes to node 1.
|
||||
//
|
||||
// The default layout is like this, on a 2-D grid.
|
||||
@@ -50,20 +50,20 @@
|
||||
// ./waf --run "wifi-simple-adhoc --distance=500"
|
||||
// ./waf --run "wifi-simple-adhoc --distance=1000"
|
||||
// ./waf --run "wifi-simple-adhoc --distance=1500"
|
||||
//
|
||||
//
|
||||
// The source node and sink node can be changed like this:
|
||||
//
|
||||
//
|
||||
// ./waf --run "wifi-simple-adhoc --sourceNode=20 --sinkNode=10"
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
//
|
||||
// ./waf --run "wifi-simple-adhoc-grid --verbose=1"
|
||||
//
|
||||
// By default, trace file writing is off-- to enable it, try:
|
||||
// ./waf --run "wifi-simple-adhoc-grid --tracing=1"
|
||||
//
|
||||
// When you are done tracing, you will notice many pcap trace files
|
||||
// When you are done tracing, you will notice many pcap trace files
|
||||
// in your directory. If you have tcpdump installed, you can try this:
|
||||
//
|
||||
// tcpdump -r wifi-simple-adhoc-grid-0-0.pcap -nn -tt
|
||||
@@ -87,14 +87,14 @@ void ReceivePacket (Ptr<Socket> socket)
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount - 1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -138,7 +138,7 @@ int main (int argc, char *argv[])
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
@@ -153,9 +153,9 @@ int main (int argc, char *argv[])
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (-10) );
|
||||
wifiPhy.Set ("RxGain", DoubleValue (-10) );
|
||||
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
@@ -225,7 +225,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Give OLSR time to converge-- 30 seconds perhaps
|
||||
Simulator::Schedule (Seconds (30.0), &GenerateTraffic,
|
||||
Simulator::Schedule (Seconds (30.0), &GenerateTraffic,
|
||||
source, packetSize, numPackets, interPacketInterval);
|
||||
|
||||
// Output what we are doing
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
//
|
||||
// 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
|
||||
// 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
|
||||
// to receive at a fixed RSS (regardless of the distance and transmit
|
||||
// power); therefore, changing position of the nodes has no effect.
|
||||
// power); therefore, changing position of the nodes has no effect.
|
||||
//
|
||||
// There are a number of command-line options available to control
|
||||
// the default behavior. The list of available command-line options
|
||||
@@ -42,7 +42,7 @@
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
//
|
||||
// ./waf --run "wifi-simple-adhoc --verbose=1"
|
||||
//
|
||||
// When you are done, you will notice two pcap trace files in your directory.
|
||||
@@ -68,14 +68,14 @@ void ReceivePacket (Ptr<Socket> socket)
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount - 1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -111,7 +111,7 @@ int main (int argc, char *argv[])
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
@@ -128,9 +128,9 @@ int main (int argc, char *argv[])
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// This is one parameter that matters when using FixedRssLossModel
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
@@ -148,8 +148,8 @@ int main (int argc, char *argv[])
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
|
||||
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
@@ -184,7 +184,7 @@ int main (int argc, char *argv[])
|
||||
NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss );
|
||||
|
||||
Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
|
||||
Seconds (1.0), &GenerateTraffic,
|
||||
Seconds (1.0), &GenerateTraffic,
|
||||
source, packetSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
//
|
||||
// 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
|
||||
// 802.11b NICs in infrastructure mode, and by default, the station sends
|
||||
// one packet of 1000 (application) bytes to the access point. The
|
||||
// physical layer is configured
|
||||
// to receive at a fixed RSS (regardless of the distance and transmit
|
||||
// power); therefore, changing position of the nodes has no effect.
|
||||
// power); therefore, changing position of the nodes has no effect.
|
||||
//
|
||||
// There are a number of command-line options available to control
|
||||
// the default behavior. The list of available command-line options
|
||||
@@ -43,7 +43,7 @@
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
//
|
||||
// ./waf --run "wifi-simple-infra --verbose=1"
|
||||
//
|
||||
// When you are done, you will notice two pcap trace files in your directory.
|
||||
@@ -69,14 +69,14 @@ void ReceivePacket (Ptr<Socket> socket)
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount - 1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -112,7 +112,7 @@ int main (int argc, char *argv[])
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
@@ -129,9 +129,9 @@ int main (int argc, char *argv[])
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// This is one parameter that matters when using FixedRssLossModel
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
@@ -159,8 +159,8 @@ int main (int argc, char *argv[])
|
||||
NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, c.Get (1));
|
||||
devices.Add (apDevice);
|
||||
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
@@ -195,7 +195,7 @@ int main (int argc, char *argv[])
|
||||
NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss );
|
||||
|
||||
Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
|
||||
Seconds (1.0), &GenerateTraffic,
|
||||
Seconds (1.0), &GenerateTraffic,
|
||||
source, packetSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::Stop (Seconds (30.0));
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
//
|
||||
// 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
|
||||
@@ -33,7 +33,7 @@
|
||||
//
|
||||
// |------------------------------------|
|
||||
// | |
|
||||
// | primary received frame (time t0) |
|
||||
// | primary received frame (time t0) |
|
||||
// | |
|
||||
// |------------------------------------|
|
||||
//
|
||||
@@ -42,8 +42,8 @@
|
||||
// |-----------------------------------|
|
||||
// | |
|
||||
// | interfering frame (time t1) |
|
||||
// | |
|
||||
// |-----------------------------------|
|
||||
// | |
|
||||
// |-----------------------------------|
|
||||
//
|
||||
// The orientation is:
|
||||
// n2 ---------> n0 <---------- n1
|
||||
@@ -66,7 +66,7 @@
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
//
|
||||
// ./waf --run "wifi-simple-interference --verbose=1"
|
||||
//
|
||||
// When you are done, you will notice a pcap trace file in your directory.
|
||||
@@ -111,14 +111,14 @@ static void ReceivePacket (Ptr<Socket> socket)
|
||||
NS_LOG_UNCOND (PrintReceivedPacket (socket));
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount - 1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -130,7 +130,7 @@ static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
// LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL);
|
||||
|
||||
|
||||
std::string phyMode ("DsssRate1Mbps");
|
||||
double Prss = -80; // -dBm
|
||||
double Irss = -95; // -dBm
|
||||
@@ -145,7 +145,7 @@ int main (int argc, char *argv[])
|
||||
double startTime = 10.0; // seconds
|
||||
double distanceToRx = 100.0; // meters
|
||||
|
||||
double offset = 91; // This is a magic number used to set the
|
||||
double offset = 91; // This is a magic number used to set the
|
||||
// transmit power, based on other configuration
|
||||
CommandLine cmd;
|
||||
|
||||
@@ -166,7 +166,7 @@ int main (int argc, char *argv[])
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
@@ -182,11 +182,11 @@ int main (int argc, char *argv[])
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0) );
|
||||
|
||||
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
@@ -201,21 +201,21 @@ int main (int argc, char *argv[])
|
||||
// Set it to adhoc mode
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0));
|
||||
// This will disable these sending devices from detecting a signal
|
||||
// This will disable these sending devices from detecting a signal
|
||||
// so that they do not backoff
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (0.0) );
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Prss) );
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Prss) );
|
||||
devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (1)));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Irss) );
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Irss) );
|
||||
devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (2)));
|
||||
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (distanceToRx, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (-1*distanceToRx, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (-1 * distanceToRx, 0.0, 0.0));
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (c);
|
||||
@@ -253,11 +253,11 @@ int main (int argc, char *argv[])
|
||||
NS_LOG_UNCOND ("Primary packet RSS=" << Prss << " dBm and interferer RSS=" << Irss << " dBm at time offset=" << delta << " ms");
|
||||
|
||||
Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
|
||||
Seconds (startTime), &GenerateTraffic,
|
||||
Seconds (startTime), &GenerateTraffic,
|
||||
source, PpacketSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::ScheduleWithContext (interferer->GetNode ()->GetId (),
|
||||
Seconds (startTime + delta/1000000.0), &GenerateTraffic,
|
||||
Seconds (startTime + delta / 1000000.0), &GenerateTraffic,
|
||||
interferer, IpacketSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// The purpose is to test the energy depletion on the nodes and the
|
||||
// The purpose is to test the energy depletion on the nodes and the
|
||||
// activation of the callback that puts a node in the sleep state when
|
||||
// its energy is depleted. Furthermore, this script can be used to test
|
||||
// the available policies for updating the transmit current based on
|
||||
@@ -39,7 +39,7 @@
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
//
|
||||
// ./waf --run "wifi-sleep --verbose=1"
|
||||
//
|
||||
// When you are done, you will notice four trace files in your directory:
|
||||
@@ -64,9 +64,9 @@ void RemainingEnergyTrace (double oldValue, double newValue)
|
||||
std::stringstream ss;
|
||||
ss << "energy_" << node << ".log";
|
||||
|
||||
static std::fstream f (ss.str().c_str(), std::ios::out);
|
||||
static std::fstream f (ss.str ().c_str (), std::ios::out);
|
||||
|
||||
f << Simulator::Now().GetSeconds() << " remaining energy=" << newValue << std::endl;
|
||||
f << Simulator::Now ().GetSeconds () << " remaining energy=" << newValue << std::endl;
|
||||
}
|
||||
|
||||
template <int node>
|
||||
@@ -75,9 +75,9 @@ void PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy
|
||||
std::stringstream ss;
|
||||
ss << "state_" << node << ".log";
|
||||
|
||||
static std::fstream f (ss.str().c_str(), std::ios::out);
|
||||
static std::fstream f (ss.str ().c_str (), std::ios::out);
|
||||
|
||||
f << Simulator::Now().GetSeconds() << " state=" << state << " start=" << start << " duration=" << duration << std::endl;
|
||||
f << Simulator::Now ().GetSeconds () << " state=" << state << " start=" << start << " duration=" << duration << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
|
||||
wifiPhy.Set ("TxPowerStart", DoubleValue (txPowerStart));
|
||||
wifiPhy.Set ("TxPowerEnd", DoubleValue (txPowerEnd));
|
||||
@@ -163,8 +163,8 @@ int main (int argc, char *argv[])
|
||||
|
||||
ApplicationContainer apps;
|
||||
|
||||
std::string transportProto = std::string("ns3::UdpSocketFactory");
|
||||
OnOffHelper onOff(transportProto, InetSocketAddress (Ipv4Address ("10.1.1.2"), 9000));
|
||||
std::string transportProto = std::string ("ns3::UdpSocketFactory");
|
||||
OnOffHelper onOff (transportProto, InetSocketAddress (Ipv4Address ("10.1.1.2"), 9000));
|
||||
|
||||
onOff.SetAttribute ("DataRate", DataRateValue (DataRate (dataRate)));
|
||||
onOff.SetAttribute ("PacketSize", UintegerValue (packetSize));
|
||||
@@ -202,34 +202,34 @@ int main (int argc, char *argv[])
|
||||
"Eta", DoubleValue (eta));
|
||||
|
||||
// install an energy source on each node
|
||||
for (NodeContainer::Iterator n = c.Begin(); n != c.End(); n++)
|
||||
{
|
||||
eSources.Add (basicSourceHelper.Install (*n));
|
||||
|
||||
Ptr<WifiNetDevice> wnd;
|
||||
|
||||
for (uint32_t i = 0; i < (*n)->GetNDevices (); ++i)
|
||||
for (NodeContainer::Iterator n = c.Begin (); n != c.End (); n++)
|
||||
{
|
||||
wnd = (*n)->GetDevice (i)->GetObject<WifiNetDevice> ();
|
||||
// if it is a WifiNetDevice
|
||||
if (wnd != 0)
|
||||
{
|
||||
// this device draws power from the last created energy source
|
||||
radioEnergyHelper.Install (wnd, eSources.Get (eSources.GetN()-1));
|
||||
}
|
||||
eSources.Add (basicSourceHelper.Install (*n));
|
||||
|
||||
Ptr<WifiNetDevice> wnd;
|
||||
|
||||
for (uint32_t i = 0; i < (*n)->GetNDevices (); ++i)
|
||||
{
|
||||
wnd = (*n)->GetDevice (i)->GetObject<WifiNetDevice> ();
|
||||
// if it is a WifiNetDevice
|
||||
if (wnd != 0)
|
||||
{
|
||||
// this device draws power from the last created energy source
|
||||
radioEnergyHelper.Install (wnd, eSources.Get (eSources.GetN () - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tracing
|
||||
eSources.Get (0)->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback(&RemainingEnergyTrace<0>));
|
||||
eSources.Get (1)->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback(&RemainingEnergyTrace<1>));
|
||||
eSources.Get (0)->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergyTrace<0>));
|
||||
eSources.Get (1)->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergyTrace<1>));
|
||||
|
||||
Config::Connect ("/NodeList/0/DeviceList/*/Phy/State/State", MakeCallback (&PhyStateTrace<0>));
|
||||
Config::Connect ("/NodeList/1/DeviceList/*/Phy/State/State", MakeCallback (&PhyStateTrace<1>));
|
||||
|
||||
// wifiPhy.EnablePcap ("wifi-sleep", devices);
|
||||
|
||||
Simulator::Stop (Seconds(duration+1));
|
||||
Simulator::Stop (Seconds (duration + 1));
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -194,7 +194,7 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
//Bug 2460: CcaMode1Threshold default should be set to -62 dBm when using Spectrum
|
||||
Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
|
||||
|
||||
|
||||
Ptr<MultiModelSpectrumChannel> spectrumChannel
|
||||
= CreateObject<MultiModelSpectrumChannel> ();
|
||||
Ptr<FriisPropagationLossModel> lossModel
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
* | |
|
||||
* n1 n2
|
||||
*
|
||||
* In this example, an HT station sends TCP packets to the access point.
|
||||
* We report the total throughput received during a window of 100ms.
|
||||
* In this example, an HT station sends TCP packets to the access point.
|
||||
* We report the total throughput received during a window of 100ms.
|
||||
* The user can specify the application data rate and choose the variant
|
||||
* of TCP i.e. congestion control algorithm to use.
|
||||
*/
|
||||
@@ -49,14 +49,14 @@ void
|
||||
CalculateThroughput ()
|
||||
{
|
||||
Time now = Simulator::Now (); /* Return the simulator's virtual time. */
|
||||
double cur = (sink->GetTotalRx() - lastTotalRx) * (double) 8/1e5; /* Convert Application RX Packets to MBits. */
|
||||
double cur = (sink->GetTotalRx () - lastTotalRx) * (double) 8 / 1e5; /* Convert Application RX Packets to MBits. */
|
||||
std::cout << now.GetSeconds () << "s: \t" << cur << " Mbit/s" << std::endl;
|
||||
lastTotalRx = sink->GetTotalRx ();
|
||||
Simulator::Schedule (MilliSeconds (100), &CalculateThroughput);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
uint32_t payloadSize = 1472; /* Transport layer payload size in bytes. */
|
||||
std::string dataRate = "100Mbps"; /* Application layer datarate. */
|
||||
@@ -87,7 +87,7 @@ main(int argc, char *argv[])
|
||||
wifiHelper.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
|
||||
/* Set up Legacy Channel */
|
||||
YansWifiChannelHelper wifiChannel ;
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel", "Frequency", DoubleValue (5e9));
|
||||
|
||||
@@ -115,14 +115,14 @@ main(int argc, char *argv[])
|
||||
/* Configure AP */
|
||||
Ssid ssid = Ssid ("network");
|
||||
wifiMac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
NetDeviceContainer apDevice;
|
||||
apDevice = wifiHelper.Install (wifiPhy, wifiMac, apWifiNode);
|
||||
|
||||
/* Configure STA */
|
||||
wifiMac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
NetDeviceContainer staDevices;
|
||||
staDevices = wifiHelper.Install (wifiPhy, wifiMac, staWifiNode);
|
||||
@@ -183,7 +183,7 @@ main(int argc, char *argv[])
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
double averageThroughput = ((sink->GetTotalRx() * 8) / (1e6 * simulationTime));
|
||||
double averageThroughput = ((sink->GetTotalRx () * 8) / (1e6 * simulationTime));
|
||||
if (averageThroughput < 50)
|
||||
{
|
||||
NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Copyright (c) 2015 SEBASTIEN DERONNE
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
@@ -31,9 +31,9 @@
|
||||
// ./waf --run "wifi-timing-attributes --slot=20"
|
||||
//
|
||||
// Network topology:
|
||||
//
|
||||
//
|
||||
// Wifi 192.168.1.0
|
||||
//
|
||||
//
|
||||
// AP
|
||||
// * *
|
||||
// | |
|
||||
@@ -65,16 +65,16 @@ int main (int argc, char *argv[])
|
||||
cmd.AddValue ("compressedBlockAckTimeoutTimeout", "Compressed Block ACK timeout duration in microseconds", compressedBlockAckTimeout);
|
||||
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
|
||||
cmd.Parse (argc,argv);
|
||||
|
||||
|
||||
//Since default reference loss is defined for 5 GHz, it needs to be changed when operating at 2.4 GHz
|
||||
Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.046));
|
||||
|
||||
|
||||
//Create nodes
|
||||
NodeContainer wifiStaNode;
|
||||
wifiStaNode.Create (1);
|
||||
NodeContainer wifiApNode;
|
||||
wifiApNode.Create (1);
|
||||
|
||||
|
||||
//Create wireless channel
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
|
||||
@@ -84,8 +84,8 @@ int main (int argc, char *argv[])
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode", StringValue("OfdmRate65MbpsBW20MHz"),
|
||||
"ControlMode", StringValue("OfdmRate6_5MbpsBW20MHz"));
|
||||
"DataMode", StringValue ("OfdmRate65MbpsBW20MHz"),
|
||||
"ControlMode", StringValue ("OfdmRate6_5MbpsBW20MHz"));
|
||||
WifiMacHelper mac;
|
||||
|
||||
//Install PHY and MAC
|
||||
@@ -110,17 +110,17 @@ int main (int argc, char *argv[])
|
||||
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/Rifs", TimeValue (MicroSeconds (rifs)));
|
||||
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BasicBlockAckTimeout", TimeValue (MicroSeconds (basicBlockAckTimeout)));
|
||||
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/CompressedBlockAckTimeout", TimeValue (MicroSeconds (compressedBlockAckTimeout)));
|
||||
|
||||
|
||||
//Mobility
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
|
||||
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (1.0, 0.0, 0.0));
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
|
||||
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
|
||||
|
||||
mobility.Install (wifiApNode);
|
||||
mobility.Install (wifiStaNode);
|
||||
|
||||
@@ -137,7 +137,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
staNodeInterface = address.Assign (staDevice);
|
||||
apNodeInterface = address.Assign (apDevice);
|
||||
|
||||
|
||||
//Setting applications
|
||||
UdpServerHelper myServer (9);
|
||||
ApplicationContainer serverApp = myServer.Install (wifiStaNode.Get (0));
|
||||
@@ -148,11 +148,11 @@ int main (int argc, char *argv[])
|
||||
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
|
||||
client.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
|
||||
client.SetAttribute ("PacketSize", UintegerValue (1472)); //bytes
|
||||
|
||||
|
||||
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
|
||||
clientApp.Start (Seconds (1.0));
|
||||
clientApp.Stop (Seconds (simulationTime));
|
||||
|
||||
|
||||
//Populate routing table
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
|
||||
@@ -162,9 +162,9 @@ int main (int argc, char *argv[])
|
||||
Simulator::Destroy ();
|
||||
|
||||
//Get and print results
|
||||
uint32_t totalPacketsThrough = DynamicCast<UdpServer>(serverApp.Get (0))->GetReceived ();
|
||||
double throughput = totalPacketsThrough * 1472 * 8/((simulationTime-1) * 1000000.0); //Mbit/s
|
||||
uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
|
||||
double throughput = totalPacketsThrough * 1472 * 8 / ((simulationTime - 1) * 1000000.0); //Mbit/s
|
||||
std::cout << "Throughput: " << throughput << " Mbit/s" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
// on each AP node that bridge the whole thing into one network.
|
||||
//
|
||||
// +-----+ +-----+ +-----+ +-----+
|
||||
// | STA | | STA | | STA | | STA |
|
||||
// | STA | | STA | | STA | | STA |
|
||||
// +-----+ +-----+ +-----+ +-----+
|
||||
// 192.168.0.2 192.168.0.3 192.168.0.5 192.168.0.6
|
||||
// -------- -------- -------- --------
|
||||
@@ -32,11 +32,11 @@
|
||||
// |
|
||||
// ((*)) | ((*))
|
||||
// ------- -------
|
||||
// WIFI AP CSMA ========= CSMA WIFI AP
|
||||
// WIFI AP CSMA ========= CSMA WIFI AP
|
||||
// ------- ---- ---- -------
|
||||
// ############## ##############
|
||||
// BRIDGE BRIDGE
|
||||
// ############## ##############
|
||||
// ############## ##############
|
||||
// 192.168.0.1 192.168.0.4
|
||||
// +---------+ +---------+
|
||||
// | AP Node | | AP Node |
|
||||
@@ -90,7 +90,7 @@ int main (int argc, char *argv[])
|
||||
double wifiX = 0.0;
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
|
||||
for (uint32_t i = 0; i < nWifis; ++i)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ int main (int argc, char *argv[])
|
||||
"Mode", StringValue ("Time"),
|
||||
"Time", StringValue ("2s"),
|
||||
"Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
|
||||
"Bounds", RectangleValue (Rectangle (wifiX, wifiX+5.0,0.0, (nStas+1)*5.0)));
|
||||
"Bounds", RectangleValue (Rectangle (wifiX, wifiX + 5.0,0.0, (nStas + 1) * 5.0)));
|
||||
mobility.Install (sta);
|
||||
wifiMac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
Reference in New Issue
Block a user