1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/multi-rate-first.cc Thu Aug 13 09:06:17 2009 +0200
1.3 @@ -0,0 +1,317 @@
1.4 +/**
1.5 + *
1.6 + * Instructions:
1.7 + * ./waf --run multi-rate-first > m.data
1.8 + * gnuplot m.data
1.9 + * eog *.png
1.10 + *
1.11 + */
1.12 +
1.13 +#include "ns3/core-module.h"
1.14 +#include "ns3/common-module.h"
1.15 +#include "ns3/node-module.h"
1.16 +#include "ns3/helper-module.h"
1.17 +#include "ns3/mobility-module.h"
1.18 +#include "ns3/contrib-module.h"
1.19 +
1.20 +#include <iostream>
1.21 +
1.22 +NS_LOG_COMPONENT_DEFINE ("Main");
1.23 +
1.24 +using namespace ns3;
1.25 +
1.26 +class Experiment
1.27 +{
1.28 +public:
1.29 + Experiment ();
1.30 + Experiment (std::string name);
1.31 + Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
1.32 + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility, int positionStep);
1.33 +private:
1.34 + void ReceivePacket (Ptr<Socket> socket);
1.35 + void SetPosition (Ptr<Node> node, Vector position);
1.36 + Vector GetPosition (Ptr<Node> node);
1.37 + void AdvancePosition (Ptr<Node> node);
1.38 + void BackTrackPosition (Ptr<Node> node);
1.39 + void StationaryPosition (Ptr<Node> node);
1.40 + Ptr<Socket> SetupPacketReceive (Ptr<Node> node);
1.41 +
1.42 + uint32_t m_bytesTotal;
1.43 + Gnuplot2dDataset m_output;
1.44 +};
1.45 +
1.46 +Experiment::Experiment ()
1.47 +{}
1.48 +
1.49 +Experiment::Experiment (std::string name)
1.50 + : m_output (name)
1.51 +{
1.52 + m_output.SetStyle (Gnuplot2dDataset::LINES);
1.53 +}
1.54 +
1.55 +void
1.56 +Experiment::SetPosition (Ptr<Node> node, Vector position)
1.57 +{
1.58 + Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
1.59 + mobility->SetPosition (position);
1.60 +}
1.61 +
1.62 +Vector
1.63 +Experiment::GetPosition (Ptr<Node> node)
1.64 +{
1.65 + Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
1.66 + return mobility->GetPosition ();
1.67 +}
1.68 +
1.69 +void
1.70 +Experiment::AdvancePosition (Ptr<Node> node)
1.71 +{
1.72 + Vector pos = GetPosition (node);
1.73 + double mbs = ((m_bytesTotal * 8.0) / 1000000);
1.74 + m_bytesTotal = 0;
1.75 + m_output.Add ((Simulator::Now()).GetSeconds(), mbs);
1.76 + pos.x += 1.0;
1.77 +
1.78 + if (pos.x >= 210.0)
1.79 + {
1.80 + return;
1.81 + }
1.82 + SetPosition (node, pos);
1.83 +
1.84 + //std::cout << "x="<<pos.x << std::endl;
1.85 + Simulator::Schedule (Seconds (1.0), &Experiment::AdvancePosition, this, node);
1.86 +}
1.87 +void
1.88 +Experiment::BackTrackPosition (Ptr<Node> node)
1.89 +{
1.90 + Vector pos = GetPosition (node);
1.91 + double mbs = ((m_bytesTotal * 8.0) / 1000000);
1.92 + m_bytesTotal = 0;
1.93 + m_output.Add ((Simulator::Now()).GetSeconds(), mbs);
1.94 + pos.x -= 1.0;
1.95 +
1.96 + if (pos.x < 0)
1.97 + {
1.98 + return;
1.99 + }
1.100 + SetPosition (node, pos);
1.101 +
1.102 + //std::cout << "x="<<pos.x << std::endl;
1.103 + Simulator::Schedule (Seconds (1.0), &Experiment::BackTrackPosition, this, node);
1.104 +}
1.105 +
1.106 +void
1.107 +Experiment::StationaryPosition (Ptr<Node> node)
1.108 +{
1.109 + double mbs = ((m_bytesTotal * 8.0) / 1000000);
1.110 + m_bytesTotal = 0;
1.111 + m_output.Add ((Simulator::Now()).GetSeconds(), mbs);
1.112 +
1.113 +}
1.114 +
1.115 +void
1.116 +Experiment::ReceivePacket (Ptr<Socket> socket)
1.117 +{
1.118 + Ptr<Packet> packet;
1.119 + while (packet = socket->Recv ())
1.120 + {
1.121 + m_bytesTotal += packet->GetSize ();
1.122 + }
1.123 +}
1.124 +
1.125 +Ptr<Socket>
1.126 +Experiment::SetupPacketReceive (Ptr<Node> node)
1.127 +{
1.128 + TypeId tid = TypeId::LookupByName ("ns3::PacketSocketFactory");
1.129 + Ptr<Socket> sink = Socket::CreateSocket (node, tid);
1.130 + sink->Bind ();
1.131 + sink->SetRecvCallback (MakeCallback (&Experiment::ReceivePacket, this));
1.132 +
1.133 + return sink;
1.134 +
1.135 +}
1.136 +
1.137 +Gnuplot2dDataset
1.138 +Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
1.139 + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility, int positionStep)
1.140 +{
1.141 + m_bytesTotal = 0;
1.142 +
1.143 + NodeContainer c;
1.144 + c.Create (2);
1.145 +
1.146 + PacketSocketHelper packetSocket;
1.147 + packetSocket.Install (c);
1.148 +
1.149 + YansWifiPhyHelper phy = wifiPhy;
1.150 + phy.SetChannel (wifiChannel.Create ());
1.151 +
1.152 + NqosWifiMacHelper mac = wifiMac;
1.153 + NetDeviceContainer devices = wifi.Install (phy, mac, c);
1.154 +
1.155 + mobility.Install (c);
1.156 +
1.157 + PacketSocketAddress socket;
1.158 + socket.SetSingleDevice(devices.Get (0)->GetIfIndex ());
1.159 + socket.SetPhysicalAddress (devices.Get (1)->GetAddress ());
1.160 + socket.SetProtocol (1);
1.161 +
1.162 + OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
1.163 + onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (250)));
1.164 + onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
1.165 + onoff.SetAttribute ("DataRate", DataRateValue (DataRate (60000000)));
1.166 + onoff.SetAttribute ("PacketSize", UintegerValue (2000));
1.167 +
1.168 + ApplicationContainer apps = onoff.Install (c.Get (0));
1.169 + apps.Start (Seconds (0.5));
1.170 + apps.Stop (Seconds (250.0));
1.171 +
1.172 +
1.173 + Ptr<Socket> recvSink = SetupPacketReceive (c.Get (1));
1.174 +
1.175 + if(positionStep == 1)
1.176 + {
1.177 + Simulator::Schedule (Seconds (1.5), &Experiment::AdvancePosition, this, c.Get (1));
1.178 + }
1.179 + else if(positionStep == -1)
1.180 + {
1.181 + Simulator::Schedule (Seconds (1.5), &Experiment::BackTrackPosition, this, c.Get (1));
1.182 + }
1.183 + else if(positionStep == 0)
1.184 + {
1.185 + for(int i = 1; i <= 210; i++)
1.186 + {
1.187 + Simulator::Schedule (Seconds (i), &Experiment::StationaryPosition, this, c.Get (1));
1.188 + }
1.189 + }
1.190 + Simulator::Run ();
1.191 + Simulator::Destroy ();
1.192 +
1.193 + return m_output;
1.194 +}
1.195 +
1.196 +int main (int argc, char *argv[])
1.197 +{
1.198 + // disable fragmentation
1.199 + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
1.200 + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
1.201 +
1.202 + CommandLine cmd;
1.203 + cmd.Parse (argc, argv);
1.204 +
1.205 + Gnuplot gnuplot = Gnuplot ("multi-rate-first.png");
1.206 + Experiment experiment;
1.207 + WifiHelper wifi = WifiHelper::Default ();
1.208 + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
1.209 + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
1.210 + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
1.211 + Gnuplot2dDataset dataset;
1.212 + int myPositionStep = 0;
1.213 +
1.214 +/*
1.215 +
1.216 + // Scenario 1: moving away from one another
1.217 + // Initially set them 5 meters apart
1.218 + // Set positionStep parameter of Experiment::Run to 1
1.219 + // Set RateErrorModel of Experiment::Run to 0
1.220 + myPositionStep = 1;
1.221 +
1.222 + MobilityHelper mobility;
1.223 + Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1.224 + positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1.225 + positionAlloc->Add (Vector (5.0, 0.0, 0.0));
1.226 + mobility.SetPositionAllocator (positionAlloc);
1.227 + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1.228 +
1.229 + wifiMac.SetType ("ns3::AdhocWifiMac");
1.230 +
1.231 + gnuplot = Gnuplot ("multi-rate-first.png");
1.232 + Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland"));
1.233 +
1.234 + NS_LOG_DEBUG ("minstrel");
1.235 + experiment = Experiment ("minstrel");
1.236 + wifi.SetRemoteStationManager ("ns3::MinstrelWifiManager");
1.237 + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep);
1.238 + gnuplot.AddDataset (dataset);
1.239 +
1.240 + NS_LOG_DEBUG ("ideal");
1.241 + experiment = Experiment ("ideal");
1.242 + wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1.243 + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep);
1.244 + gnuplot.AddDataset (dataset);
1.245 +
1.246 + gnuplot.GenerateOutput (std::cout);
1.247 + */
1.248 +
1.249 +
1.250 + // Scenario 2: two nodes out of range, moving into transmission range range
1.251 + // Initially set them 230 meters apart
1.252 + // Set positionStep parameter of Experiment::Rung to -1
1.253 + // set RateErrorModel of Experiment::Run to 0
1.254 +
1.255 + myPositionStep = -1;
1.256 +
1.257 + MobilityHelper mobility;
1.258 + Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1.259 + positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1.260 + positionAlloc->Add (Vector (230.0, 0.0, 0.0));
1.261 + mobility.SetPositionAllocator (positionAlloc);
1.262 + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1.263 +
1.264 + wifiMac.SetType ("ns3::AdhocWifiMac");
1.265 +
1.266 + gnuplot = Gnuplot ("multi-rate-first.png");
1.267 + Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland"));
1.268 +
1.269 + NS_LOG_DEBUG ("minstrel");
1.270 + experiment = Experiment ("minstrel");
1.271 + wifi.SetRemoteStationManager ("ns3::MinstrelWifiManager");
1.272 + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep);
1.273 + gnuplot.AddDataset (dataset);
1.274 +
1.275 + NS_LOG_DEBUG ("ideal");
1.276 + experiment = Experiment ("ideal");
1.277 + wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1.278 + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep);
1.279 + gnuplot.AddDataset (dataset);
1.280 +
1.281 + gnuplot.GenerateOutput (std::cout);
1.282 +
1.283 +
1.284 +
1.285 +/*
1.286 + // Scenario 3:
1.287 + // Initially set them 25 meters apart, stationary
1.288 + // Set positionStep parameter of Experiment::Rung to 0
1.289 + // This is a sanity check
1.290 +
1.291 + myPositionStep = 0;
1.292 + MobilityHelper mobility;
1.293 + Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1.294 + positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1.295 + positionAlloc->Add (Vector (25.0, 0.0, 0.0));
1.296 + mobility.SetPositionAllocator (positionAlloc);
1.297 + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1.298 +
1.299 + wifiMac.SetType ("ns3::AdhocWifiMac");
1.300 +
1.301 + gnuplot = Gnuplot ("multi-rate-first.png");
1.302 + Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland"));
1.303 +
1.304 + NS_LOG_DEBUG ("minstrel");
1.305 + experiment = Experiment ("minstrel");
1.306 + wifi.SetRemoteStationManager ("ns3::MinstrelWifiManager");
1.307 + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep);
1.308 + gnuplot.AddDataset (dataset);
1.309 +
1.310 + NS_LOG_DEBUG ("ideal");
1.311 + experiment = Experiment ("ideal");
1.312 + wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1.313 + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep);
1.314 + gnuplot.AddDataset (dataset);
1.315 +
1.316 + gnuplot.GenerateOutput (std::cout);
1.317 + */
1.318 +
1.319 + return 0;
1.320 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/examples/multi-rate-second.cc Thu Aug 13 09:06:17 2009 +0200
2.3 @@ -0,0 +1,256 @@
2.4 +/*
2.5 + * Instructions:
2.6 + * ./waf --run multi-rate-second
2.7 + * gnuplot multi-rate-second.plt
2.8 + *
2.9 + * Output: multi-rate-second.eps
2.10 + *
2.11 + */
2.12 +
2.13 +#include "ns3/core-module.h"
2.14 +#include "ns3/common-module.h"
2.15 +#include "ns3/node-module.h"
2.16 +#include "ns3/helper-module.h"
2.17 +#include "ns3/mobility-module.h"
2.18 +#include "ns3/contrib-module.h"
2.19 +
2.20 +#include <iostream>
2.21 +#include <fstream>
2.22 +#include <vector>
2.23 +#include <string>
2.24 +
2.25 +NS_LOG_COMPONENT_DEFINE ("Main");
2.26 +
2.27 +using namespace ns3;
2.28 +
2.29 +class Experiment
2.30 +{
2.31 +public:
2.32 + Experiment ();
2.33 + Experiment (std::string name);
2.34 + Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
2.35 + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel);
2.36 +private:
2.37 + void ReceivePacket (Ptr<Socket> socket);
2.38 + void SetPosition (Ptr<Node> node, Vector position);
2.39 + Vector GetPosition (Ptr<Node> node);
2.40 + Ptr<Socket> SetupPacketReceive (Ptr<Node> node);
2.41 + void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
2.42 + uint32_t pktCount, Time pktInterval , Ptr<Node> node);
2.43 +
2.44 + uint32_t m_pktsTotal;
2.45 + Gnuplot2dDataset m_output;
2.46 + bool advanceStep;
2.47 +};
2.48 +
2.49 +Experiment::Experiment ()
2.50 +{
2.51 + advanceStep= true;
2.52 +}
2.53 +
2.54 +Experiment::Experiment (std::string name)
2.55 + : m_output (name)
2.56 +{
2.57 + m_output.SetStyle (Gnuplot2dDataset::LINES);
2.58 +}
2.59 +
2.60 +void
2.61 +Experiment::SetPosition (Ptr<Node> node, Vector position)
2.62 +{
2.63 + Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
2.64 + mobility->SetPosition (position);
2.65 +}
2.66 +
2.67 +Vector
2.68 +Experiment::GetPosition (Ptr<Node> node)
2.69 +{
2.70 + Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
2.71 + return mobility->GetPosition ();
2.72 +}
2.73 +
2.74 +void
2.75 +Experiment::ReceivePacket (Ptr<Socket> socket)
2.76 +{
2.77 + Ptr<Packet> packet;
2.78 + while (packet = socket->Recv ())
2.79 + {
2.80 + m_pktsTotal ++;
2.81 + }
2.82 +}
2.83 +
2.84 +Ptr<Socket>
2.85 +Experiment::SetupPacketReceive (Ptr<Node> node)
2.86 +{
2.87 + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
2.88 + Ptr<Socket> sink = Socket::CreateSocket (node, tid);
2.89 + InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
2.90 + sink->Bind (local);
2.91 + sink->SetRecvCallback (MakeCallback (&Experiment::ReceivePacket, this));
2.92 + return sink;
2.93 +}
2.94 +
2.95 +void
2.96 +Experiment::GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
2.97 + uint32_t pktCount, Time pktInterval, Ptr<Node> node )
2.98 +{
2.99 + Vector pos = GetPosition(node);
2.100 +
2.101 + ///to offset the start time
2.102 + double offSetTime = 100;
2.103 +
2.104 + if (pktCount > 0)
2.105 + {
2.106 + ///To simulate nodes moving in and out of transmission constantly
2.107 + if(pos.x <= 305 && advanceStep)
2.108 + {
2.109 + ///keep moving away
2.110 + pos.x += .1;
2.111 + SetPosition(node, pos);
2.112 + }
2.113 + else
2.114 + {
2.115 + if(pos.x < 150)
2.116 + {
2.117 + advanceStep=true;
2.118 + }
2.119 + else
2.120 + {
2.121 + advanceStep = false;
2.122 + }
2.123 +
2.124 + ///moving back in
2.125 + pos.x -= .1;
2.126 + SetPosition(node, pos);
2.127 + }
2.128 + socket->Send (Create<Packet> (pktSize));
2.129 + Simulator::Schedule (pktInterval, &Experiment::GenerateTraffic, this,
2.130 + socket, pktSize,pktCount-1, pktInterval, node);
2.131 + }
2.132 + else
2.133 + {
2.134 + m_output.Add((Simulator::Now()).GetSeconds() - offSetTime , m_pktsTotal);
2.135 + }
2.136 +}
2.137 +
2.138 +Gnuplot2dDataset
2.139 +Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
2.140 + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
2.141 +{
2.142 + m_pktsTotal = 0;
2.143 +
2.144 + NodeContainer c;
2.145 + c.Create (2);
2.146 +
2.147 + YansWifiPhyHelper phy = wifiPhy;
2.148 + phy.SetChannel (wifiChannel.Create ());
2.149 +
2.150 + NqosWifiMacHelper mac = wifiMac;
2.151 + NetDeviceContainer devices = wifi.Install (phy, mac, c);
2.152 +
2.153 + MobilityHelper mobility;
2.154 + Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2.155 + positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2.156 + positionAlloc->Add (Vector (5.0, 0.0, 0.0));
2.157 + mobility.SetPositionAllocator (positionAlloc);
2.158 + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2.159 + mobility.Install (c);
2.160 +
2.161 + InternetStackHelper internet;
2.162 + internet.Install (c);
2.163 +
2.164 + Ipv4AddressHelper ipv4;
2.165 + NS_LOG_INFO ("Assign IP Addresses.");
2.166 + ipv4.SetBase ("10.1.1.0", "255.255.255.0");
2.167 + Ipv4InterfaceContainer wifiNodesInterface = ipv4.Assign (devices);
2.168 +
2.169 +
2.170 + Ptr<Socket> recvSink = SetupPacketReceive (c.Get (0));
2.171 +
2.172 + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
2.173 + Ptr<Socket> source = Socket::CreateSocket (c.Get (1), tid);
2.174 + InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80);
2.175 + source->Connect (remote);
2.176 + uint32_t packetSize = 1014;
2.177 + uint32_t maxPacketCount = 1000;
2.178 + Time interPacketInterval = Seconds (.1);
2.179 +
2.180 + Ptr<Node> n1 = c.Get(0);
2.181 + Ptr<Ipv4> ipv41 = n1->GetObject<Ipv4> ();
2.182 +
2.183 +
2.184 +
2.185 + for (int i= 1; i <= 100; i++)
2.186 + {
2.187 +
2.188 + Simulator::Schedule (Seconds (i), &Experiment::GenerateTraffic,
2.189 + this, source, packetSize, maxPacketCount,interPacketInterval, c.Get(1));
2.190 +
2.191 + if( i % 5 == 0 )
2.192 + {
2.193 + ///bring a network interface down
2.194 + Simulator::Schedule (Seconds (i+.5), &Ipv4::SetDown, ipv41, 1);
2.195 + i++;
2.196 + Simulator::Schedule (Seconds (i), &Experiment::GenerateTraffic,
2.197 + this, source, packetSize, maxPacketCount,interPacketInterval, c.Get(1));
2.198 +
2.199 + ///bring a network interface up
2.200 + Simulator::Schedule (Seconds (i+.2), &Ipv4::SetUp, ipv41, 1);
2.201 + i++;
2.202 + Simulator::Schedule (Seconds (i), &Experiment::GenerateTraffic,
2.203 + this, source, packetSize, maxPacketCount,interPacketInterval, c.Get(1));
2.204 + }
2.205 + }
2.206 +
2.207 + Simulator::Run ();
2.208 + Simulator::Destroy ();
2.209 +
2.210 + return m_output;
2.211 +}
2.212 +
2.213 +int main (int argc, char *argv[])
2.214 +{
2.215 + std::vector <std::string> ratesControl;
2.216 + ratesControl.push_back ("Ideal");
2.217 + ratesControl.push_back ("Minstrel");
2.218 +
2.219 + std::vector <std::string> wifiManager;
2.220 + wifiManager.push_back("ns3::IdealWifiManager");
2.221 + wifiManager.push_back("ns3::MinstrelWifiManager");
2.222 +
2.223 + // disable fragmentation
2.224 + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
2.225 + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
2.226 +
2.227 + CommandLine cmd;
2.228 + cmd.Parse (argc, argv);
2.229 +
2.230 + Gnuplot gnuplot = Gnuplot ("multi-rate-second.eps");
2.231 +
2.232 + for (uint32_t i = 0; i < ratesControl.size(); i++)
2.233 + {
2.234 + Gnuplot2dDataset dataset (ratesControl[i]);
2.235 + dataset.SetStyle (Gnuplot2dDataset::LINES);
2.236 + Experiment experiment;
2.237 +
2.238 +
2.239 + WifiHelper wifi = WifiHelper::Default ();
2.240 + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
2.241 + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
2.242 + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
2.243 +
2.244 + wifiMac.SetType ("ns3::AdhocWifiMac");
2.245 +
2.246 + NS_LOG_DEBUG (ratesControl[i]);
2.247 +
2.248 + experiment = Experiment (ratesControl[i]);
2.249 + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
2.250 + gnuplot.AddDataset (dataset);
2.251 +
2.252 + }
2.253 + gnuplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
2.254 + gnuplot.SetLegend ("Time (Seconds)", "Number of packets received");
2.255 + gnuplot.SetExtra ("set xrange [0:100]");
2.256 + gnuplot.GenerateOutput (std::cout);
2.257 +
2.258 + return 0;
2.259 +}
3.1 --- a/examples/wscript Thu Aug 13 09:06:01 2009 +0200
3.2 +++ b/examples/wscript Thu Aug 13 09:06:17 2009 +0200
3.3 @@ -163,3 +163,11 @@
3.4 obj = bld.create_ns3_program('simple-wifi-frame-aggregation',
3.5 ['core', 'simulator', 'mobility', 'wifi'])
3.6 obj.source = 'simple-wifi-frame-aggregation.cc'
3.7 +
3.8 + obj = bld.create_ns3_program('multi-rate-first',
3.9 + ['core', 'simulator', 'mobility', 'wifi'])
3.10 + obj.source = 'multi-rate-first.cc'
3.11 +
3.12 + obj = bld.create_ns3_program('multi-rate-second',
3.13 + ['core', 'simulator', 'mobility', 'wifi'])
3.14 + obj.source = 'multi-rate-second.cc'