A Discrete-Event Network Simulator
API
wimax-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20  */
21 
22 #include "wimax-helper.h"
23 #include "ns3/simulator.h"
24 #include "ns3/packet.h"
25 #include "ns3/log.h"
26 #include <string>
27 #include "ns3/config.h"
28 #include "ns3/wimax-net-device.h"
29 #include "ns3/bs-net-device.h"
30 #include "ns3/ss-net-device.h"
31 #include "ns3/wimax-channel.h"
32 #include "ns3/simple-ofdm-wimax-channel.h"
33 #include "ns3/wimax-phy.h"
34 #include "ns3/simple-ofdm-wimax-phy.h"
35 #include "ns3/pointer.h"
36 #include "ns3/wimax-mac-to-mac-header.h"
37 
38 
39 namespace ns3 {
40 
41 NS_LOG_COMPONENT_DEFINE ("WimaxHelper");
42 
44  : m_channel (0)
45 {
46 }
47 
49 {
50 }
51 
53  uint32_t nodeid,
54  uint32_t deviceid,
55  char *netdevice,
56  char *connection)
57 {
58  std::ostringstream oss;
59  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" << connection
60  << "/TxQueue/Enqueue";
62 
63  oss.str ("");
64  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" << connection
65  << "/TxQueue/Dequeue";
67 
68  oss.str ("");
69  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" << connection
70  << "/TxQueue/Drop";
72 }
73 
75 {
77  switch (phyType)
78  {
80  phy = CreateObject<SimpleOfdmWimaxPhy> ();
81  if (!m_channel)
82  {
83  m_channel = CreateObject<SimpleOfdmWimaxChannel> (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
84  }
85  break;
86  default:
87  NS_FATAL_ERROR ("Invalid physical type");
88  break;
89  }
90 
91  return phy;
92 }
93 
95 {
96  if (!m_channel)
97  {
98  m_channel = CreateObject<SimpleOfdmWimaxChannel> ();
99  }
100  m_channel->GetObject<SimpleOfdmWimaxChannel> ()->SetPropagationModel (propagationModel);
101 }
102 
103 Ptr<WimaxPhy> WimaxHelper::CreatePhy (PhyType phyType, char * SNRTraceFilePath, bool activateLoss)
104 {
107  switch (phyType)
108  {
110  sphy = CreateObject<SimpleOfdmWimaxPhy> ();
111  phy = sphy;
112  sphy->SetSNRToBlockErrorRateTracesPath (SNRTraceFilePath);
113  sphy->ActivateLoss (activateLoss);
114  if (!m_channel)
115  {
116  m_channel = CreateObject<SimpleOfdmWimaxChannel> (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
117  }
118  break;
119  default:
120  NS_FATAL_ERROR ("Invalid physical type");
121  break;
122  }
123 
124  return phy;
125 }
126 
128 {
130  switch (phyType)
131  {
133  phy = CreateObject<SimpleOfdmWimaxPhy> ();
134  break;
135  default:
136  NS_FATAL_ERROR ("Invalid physical type");
137  break;
138  }
139 
140  return phy;
141 }
142 
143 Ptr<WimaxPhy> WimaxHelper::CreatePhyWithoutChannel (PhyType phyType, char * SNRTraceFilePath, bool activateLoss)
144 {
147  switch (phyType)
148  {
150  sphy = CreateObject<SimpleOfdmWimaxPhy> ();
151  phy = sphy;
152  sphy->SetSNRToBlockErrorRateTracesPath (SNRTraceFilePath);
153  sphy->ActivateLoss (activateLoss);
154  break;
155  default:
156  NS_FATAL_ERROR ("Invalid physical type");
157  break;
158  }
159 
160  return phy;
161 }
162 
164 {
165  Ptr<UplinkScheduler> uplinkScheduler;
166  switch (schedulerType)
167  {
168  case SCHED_TYPE_SIMPLE:
169  uplinkScheduler = CreateObject<UplinkSchedulerSimple> ();
170  break;
171  case SCHED_TYPE_RTPS:
172  uplinkScheduler = CreateObject<UplinkSchedulerRtps> ();
173  break;
174  case SCHED_TYPE_MBQOS:
175  uplinkScheduler = CreateObject<UplinkSchedulerMBQoS> (Seconds (0.25));
176  break;
177  default:
178  NS_FATAL_ERROR ("Invalid scheduling type");
179  break;
180  }
181  return uplinkScheduler;
182 }
183 
185 {
186  Ptr<BSScheduler> bsScheduler;
187  switch (schedulerType)
188  {
189  case SCHED_TYPE_SIMPLE:
190  bsScheduler = CreateObject<BSSchedulerSimple> ();
191  break;
192  case SCHED_TYPE_RTPS:
193  bsScheduler = CreateObject<BSSchedulerRtps> ();
194  break;
195  case SCHED_TYPE_MBQOS:
196  bsScheduler = CreateObject<BSSchedulerSimple> ();
197  break;
198  default:
199  NS_FATAL_ERROR ("Invalid scheduling type");
200  break;
201  }
202  return bsScheduler;
203 }
204 
206  NetDeviceType deviceType,
207  PhyType phyType,
208  SchedulerType schedulerType,
209  double frameDuration)
210 {
212  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
213  {
214  Ptr<Node> node = *i;
215  Ptr<WimaxPhy> phy = CreatePhy (phyType);
216 
217  // Set SuperFrame Duration
218  phy->SetFrameDuration (Seconds (frameDuration));
219 
220  Ptr<WimaxNetDevice> device;
221  Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
222  Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
223 
224  if (deviceType == DEVICE_TYPE_BASE_STATION)
225  {
226  // attach phy
227  Ptr<BaseStationNetDevice> deviceBS;
228  deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
229  device = deviceBS;
230  uplinkScheduler->SetBs (deviceBS);
231  bsScheduler->SetBs (deviceBS);
232  }
233  else
234  {
235  device = CreateObject<SubscriberStationNetDevice> (node, phy);
236  }
237  device->SetAddress (Mac48Address::Allocate ());
238  phy->SetDevice (device);
239  device->Start ();
240  device->Attach (m_channel); // attach channel
241 
242  node->AddDevice (device);
243 
244  devices.Add (device);
245  }
246  return devices;
247 }
248 
250  NetDeviceType deviceType,
251  PhyType phyType,
252  SchedulerType schedulerType)
253 {
255  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
256  {
257  Ptr<Node> node = *i;
258  Ptr<WimaxPhy> phy = CreatePhy (phyType);
259  Ptr<WimaxNetDevice> device;
260  Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
261  Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
262 
263  if (deviceType == DEVICE_TYPE_BASE_STATION)
264  {
265  // attach phy
266  Ptr<BaseStationNetDevice> deviceBS;
267  deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
268  device = deviceBS;
269  uplinkScheduler->SetBs (deviceBS);
270  bsScheduler->SetBs (deviceBS);
271  }
272  else
273  {
274  device = CreateObject<SubscriberStationNetDevice> (node, phy);
275  }
276  device->SetAddress (Mac48Address::Allocate ());
277  phy->SetDevice (device);
278  device->Start ();
279  device->Attach (m_channel); // attach channel
280 
281  node->AddDevice (device);
282 
283  devices.Add (device);
284  }
285  return devices;
286 }
287 
289  NetDeviceType deviceType,
290  PhyType phyType,
292  SchedulerType schedulerType)
293 {
295  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
296  {
297  Ptr<Node> node = *i;
298 
299  Ptr<WimaxPhy> phy = CreatePhyWithoutChannel (phyType, (char*) "dummy", 0);
300  Ptr<WimaxNetDevice> device;
301  Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
302  Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
303 
304  if (deviceType == DEVICE_TYPE_BASE_STATION)
305  {
306  Ptr<BaseStationNetDevice> deviceBS;
307  deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
308  device = deviceBS;
309  uplinkScheduler->SetBs (deviceBS);
310  bsScheduler->SetBs (deviceBS);
311  }
312  else
313  {
314  device = CreateObject<SubscriberStationNetDevice> (node, phy);
315  }
316  device->SetAddress (Mac48Address::Allocate ());
317  phy->SetDevice (device);
318  device->Start ();
319  device->Attach (channel);
320 
321  node->AddDevice (device);
322  devices.Add (device);
323  }
324  return devices;
325 }
326 
328  NetDeviceType deviceType,
329  PhyType phyType,
331  SchedulerType schedulerType)
332 {
333 
334  // Ptr<WimaxPhy> phy = CreatePhyWithoutChannel (phyType);
335  Ptr<WimaxPhy> phy = CreatePhyWithoutChannel (phyType, (char*) "dummy", 0);
336  Ptr<WimaxNetDevice> device;
337  Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
338  Ptr<BSScheduler> bsScheduler = CreateBSScheduler (schedulerType);
339 
340  if (deviceType == DEVICE_TYPE_BASE_STATION)
341  {
342  Ptr<BaseStationNetDevice> deviceBS;
343  deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
344  device = deviceBS;
345  uplinkScheduler->SetBs (deviceBS);
346  bsScheduler->SetBs (deviceBS);
347  }
348  else
349  {
350  device = CreateObject<SubscriberStationNetDevice> (node, phy);
351  }
352  device->SetAddress (Mac48Address::Allocate ());
353  phy->SetDevice (device);
354  device->Start ();
355  device->Attach (channel);
356 
357  node->AddDevice (device);
358 
359  return device;
360 }
361 
362 void
364 {
365  LogComponentEnable ("BandwidthManager", LOG_LEVEL_ALL);
366  LogComponentEnable ("BSLinkManager", LOG_LEVEL_ALL);
367  LogComponentEnable ("BaseStationNetDevice", LOG_LEVEL_ALL);
368  LogComponentEnable ("BSSchedulerRtps", LOG_LEVEL_ALL);
369  LogComponentEnable ("BSSchedulerSimple", LOG_LEVEL_ALL);
370  LogComponentEnable ("BSScheduler", LOG_LEVEL_ALL);
371  LogComponentEnable ("BsServiceFlowManager", LOG_LEVEL_ALL);
372  LogComponentEnable ("UplinkSchedulerMBQoS", LOG_LEVEL_ALL);
373  LogComponentEnable ("UplinkSchedulerRtps", LOG_LEVEL_ALL);
374  LogComponentEnable ("UplinkSchedulerSimple", LOG_LEVEL_ALL);
375  LogComponentEnable ("UplinkScheduler", LOG_LEVEL_ALL);
376  LogComponentEnable ("BurstProfileManager", LOG_LEVEL_ALL);
377  LogComponentEnable ("ConnectionManager", LOG_LEVEL_ALL);
378  LogComponentEnable ("IpcsClassifierRecord", LOG_LEVEL_ALL);
379  LogComponentEnable ("IpcsClassifier", LOG_LEVEL_ALL);
380  LogComponentEnable ("MACMESSAGES", LOG_LEVEL_ALL);
381  LogComponentEnable ("PacketBurst", LOG_LEVEL_ALL);
382  LogComponentEnable ("ServiceFlowManager", LOG_LEVEL_ALL);
383  LogComponentEnable ("simpleOfdmWimaxChannel", LOG_LEVEL_ALL);
384  LogComponentEnable ("SimpleOfdmWimaxPhy", LOG_LEVEL_ALL);
385  LogComponentEnable ("SNRToBlockErrorRateManager", LOG_LEVEL_ALL);
386  LogComponentEnable ("SSLinkManager", LOG_LEVEL_ALL);
387  LogComponentEnable ("SSManager", LOG_LEVEL_ALL);
388  LogComponentEnable ("SubscriberStationNetDevice", LOG_LEVEL_ALL);
389  LogComponentEnable ("SSScheduler", LOG_LEVEL_ALL);
390  LogComponentEnable ("SsServiceFlowManager", LOG_LEVEL_ALL);
391  LogComponentEnable ("WimaxChannel", LOG_LEVEL_ALL);
392  LogComponentEnable ("WimaxMacQueue", LOG_LEVEL_ALL);
393  LogComponentEnable ("WimaxNetDevice", LOG_LEVEL_ALL);
394  LogComponentEnable ("WimaxPhy", LOG_LEVEL_ALL);
396  LogComponentEnable ("BandwidthManager", LOG_LEVEL_ALL);
397  LogComponentEnable ("BaseStationNetDevice", LOG_LEVEL_ALL);
398  LogComponentEnable ("BSSchedulerRtps", LOG_LEVEL_ALL);
399  LogComponentEnable ("BSSchedulerSimple", LOG_LEVEL_ALL);
400  LogComponentEnable ("BSScheduler", LOG_LEVEL_ALL);
401  LogComponentEnable ("SubscriberStationNetDevice", LOG_LEVEL_ALL);
402  LogComponentEnable ("SSScheduler", LOG_LEVEL_ALL);
403  LogComponentEnable ("WimaxMacQueue", LOG_LEVEL_ALL);
404 }
405 
406 
408  std::string path,
409  Ptr<const Packet> packet,
410  const Mac48Address &source)
411 {
412  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " from: " << source << " ";
413  *stream->GetStream () << path << std::endl;
414 }
415 
416 void WimaxHelper::AsciiTxEvent (Ptr<OutputStreamWrapper> stream, std::string path, Ptr<const Packet> packet, const Mac48Address &dest)
417 {
418  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " to: " << dest << " ";
419  *stream->GetStream () << path << std::endl;
420 }
421 
423  ServiceFlow::SchedulingType schedulinType,
424  IpcsClassifierRecord classifier)
425 {
426  CsParameters csParam (CsParameters::ADD, classifier);
427  ServiceFlow serviceFlow = ServiceFlow (direction);
428  serviceFlow.SetConvergenceSublayerParam (csParam);
430  serviceFlow.SetServiceSchedulingType (schedulinType);
431  serviceFlow.SetMaxSustainedTrafficRate (100);
432  serviceFlow.SetMinReservedTrafficRate (1000000);
433  serviceFlow.SetMinTolerableTrafficRate (1000000);
434  serviceFlow.SetMaximumLatency (100);
435  serviceFlow.SetMaxTrafficBurst (2000);
436  serviceFlow.SetTrafficPriority (1);
437  serviceFlow.SetUnsolicitedGrantInterval (1);
438  serviceFlow.SetMaxSustainedTrafficRate (70);
439  serviceFlow.SetToleratedJitter (10);
440  serviceFlow.SetSduSize (49);
441  serviceFlow.SetRequestTransmissionPolicy (0);
442  return serviceFlow;
443 }
444 
445 void
447  std::string prefix,
448  Ptr<NetDevice> nd,
449  bool explicitFilename)
450 {
451  //
452  // All of the ascii enable functions vector through here including the ones
453  // that are wandering through all of devices on perhaps all of the nodes in
454  // the system. We can only deal with devices of type CsmaNetDevice.
455  //
457  if (device == 0)
458  {
459  NS_LOG_INFO ("WimaxHelper::EnableAsciiInternal(): Device " << device << " not of type ns3::WimaxNetDevice");
460  return;
461  }
462 
463  //
464  // Our default trace sinks are going to use packet printing, so we have to
465  // make sure that is turned on.
466  //
468 
469  //
470  // If we are not provided an OutputStreamWrapper, we are expected to create
471  // one using the usual trace filename conventions and do a Hook*WithoutContext
472  // since there will be one file per context and therefore the context would
473  // be redundant.
474  //
475  if (stream == 0)
476  {
477  //
478  // Set up an output stream object to deal with private ofstream copy
479  // constructor and lifetime issues. Let the helper decide the actual
480  // name of the file given the prefix.
481  //
482  AsciiTraceHelper asciiTraceHelper;
483  std::string filename;
484  if (explicitFilename)
485  {
486  filename = prefix;
487  }
488  else
489  {
490  filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
491  }
492  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
493 
494  uint32_t nodeid = nd->GetNode ()->GetId ();
495  uint32_t deviceid = nd->GetIfIndex ();
496  std::ostringstream oss;
497  //
498  // The MacRx trace source provides our "r" event.
499  //
500 
501  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Rx";
502  Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiRxEvent, theStream));
503  oss.str ("");
504  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Tx";
505  Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiTxEvent, theStream));
506  //
507  // The "+", '-', and 'd' events are driven by trace sources actually in the
508  // transmit queue.
509  //
510 
511  EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "InitialRangingConnection");
512  EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "BroadcastConnection");
513 
514  // The following connections can not be made right away because the BasicConnection and the PrimaryConnection are created later.
515  // We defer the creation to the SubscriberStationNetDevice
516 
517  // EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "BasicConnection");
518  // EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "PrimaryConnection");
519 
520  Ptr<SubscriberStationNetDevice> ssNetDev = DynamicCast<SubscriberStationNetDevice> (nd);
521  if (ssNetDev)
522  {
524  ssNetDev->SetAsciiTxQueueEnqueueCallback (EnqueueCb);
525 
527  ssNetDev->SetAsciiTxQueueDequeueCallback (DequeueCb);
528 
530  ssNetDev->SetAsciiTxQueueDropCallback (DropCb);
531  }
532 
533  return;
534  }
535 
536  //
537  // If we are provided an OutputStreamWrapper, we are expected to use it, and
538  // to provide a context. We are free to come up with our own context if we
539  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
540  // compatibility and simplicity, we just use Config::Connect and let it deal
541  // with the context.
542  //
543  // Note that we are going to use the default trace sinks provided by the
544  // ascii trace helper. There is actually no AsciiTraceHelper in sight here,
545  // but the default trace sinks are actually publicly available static
546  // functions that are always there waiting for just such a case.
547  //
548  uint32_t nodeid = nd->GetNode ()->GetId ();
549  uint32_t deviceid = nd->GetIfIndex ();
550  std::ostringstream oss;
551 
552  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Rx";
554 
555  oss.str ("");
556  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Tx";
558 
559  EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "InitialRangingConnection");
560  EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "WimaxNetDevice", (char*) "BroadcastConnection");
561 
562  // The following connections can not be made right away because the BasicConnection and the PrimaryConnection are created later.
563  // We defer the creation to the SubscriberStationNetDevice
564 
565  // EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "BasicConnection");
566  // EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) "PrimaryConnection");
567 
568  Ptr<SubscriberStationNetDevice> ssNetDev = DynamicCast<SubscriberStationNetDevice> (nd);
569  if (ssNetDev)
570  {
572  ssNetDev->SetAsciiTxQueueEnqueueCallback (EnqueueCb);
573 
575  ssNetDev->SetAsciiTxQueueDequeueCallback (DequeueCb);
576 
578  ssNetDev->SetAsciiTxQueueDropCallback (DropCb);
579  }
580 }
581 
589 {
590  std::list<Ptr<Packet> > packets = burst->GetPackets ();
591  for (std::list<Ptr<Packet> >::iterator iter = packets.begin (); iter != packets.end (); ++iter)
592  {
593  Ptr<Packet> p = (*iter)->Copy ();
594  WimaxMacToMacHeader m2m (p->GetSize ());
595  p->AddHeader (m2m);
596  file->Write (Simulator::Now (), p);
597  }
598 }
599 
600 void
601 WimaxHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool explicitFilename, bool promiscuous)
602 {
603  //
604  // All of the Pcap enable functions vector through here including the ones
605  // that are wandering through all of devices on perhaps all of the nodes in
606  // the system. We can only deal with devices of type WimaxNetDevice.
607  //
609  if (device == 0)
610  {
611  NS_LOG_INFO ("WimaxHelper::EnablePcapInternal(): Device " << &device << " not of type ns3::WimaxNetDevice");
612  return;
613  }
614 
615  Ptr<WimaxPhy> phy = device->GetPhy ();
616  PcapHelper pcapHelper;
617  std::string filename;
618  if (explicitFilename)
619  {
620  filename = prefix;
621  }
622  else
623  {
624  filename = pcapHelper.GetFilenameFromDevice (prefix, device);
625  }
626 
627  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_EN10MB);
628 
629  phy->TraceConnectWithoutContext ("Tx", MakeBoundCallback (&PcapSniffTxRxEvent, file));
630  phy->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&PcapSniffTxRxEvent, file));
631 }
632 
633 int64_t
635 {
636  NS_LOG_FUNCTION (this << stream);
637  return m_channel->AssignStreams (stream);
638 }
639 
640 int64_t
642 {
643  int64_t currentStream = stream;
644  Ptr<NetDevice> netDevice;
645  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
646  {
647  netDevice = (*i);
648  Ptr<WimaxNetDevice> wimax = DynamicCast<WimaxNetDevice> (netDevice);
649  if (wimax)
650  {
651  // Handle any random numbers in the PHY objects.
652  currentStream += wimax->GetPhy ()->AssignStreams (currentStream);
653  }
654  }
655 
656  // Handle any random numbers in the channel.
657  currentStream += m_channel->AssignStreams (currentStream);
658 
659  return (currentStream - stream);
660 }
661 
662 } // namespace ns3
Manage ASCII trace files for device models.
Definition: trace-helper.h:163
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
CsParameters class.
Definition: cs-parameters.h:36
IpcsClassifierRecord class.
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
virtual Ptr< Node > GetNode(void) const =0
virtual uint32_t GetIfIndex(void) const =0
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
uint32_t GetId(void) const
Definition: node.cc:109
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:572
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
Manage pcap files for device models.
Definition: trace-helper.h:39
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device.
Definition: trace-helper.cc:80
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
Definition: trace-helper.cc:49
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:40
void SetRequestTransmissionPolicy(uint32_t policy)
Set request transmission policy.
void SetMaxTrafficBurst(uint32_t maxTrafficBurst)
Set maximum traffic burst.
void SetMaximumLatency(uint32_t MaximumLatency)
Set maximum latency.
void SetCsSpecification(enum CsSpecification spec)
Set CS specification.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition: service-flow.h:59
void SetConvergenceSublayerParam(CsParameters csparam)
Set convergence sublayer parameters.
void SetSduSize(uint8_t sduSize)
Set SDU size.
void SetTrafficPriority(uint8_t priority)
Set traffic priority.
void SetMinTolerableTrafficRate(uint32_t minJitter)
Set minimum tolerable traffic rate.
void SetToleratedJitter(uint32_t jitter)
Set tolerated jitter.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicied grant interval.
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType schedType)
Set service scheduling type.
void SetMinReservedTrafficRate(uint32_t minResvRate)
Set minimum reserved traffic rate.
Direction
Direction enumeration.
Definition: service-flow.h:44
void SetMaxSustainedTrafficRate(uint32_t maxSustainedRate)
Set max sustained traffic rate.
SimpleOfdmWimaxChannel class.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
@ SCHED_TYPE_RTPS
A simple scheduler - rtPS based scheduler.
Definition: wimax-helper.h:88
@ SCHED_TYPE_MBQOS
An migration-based uplink scheduler.
Definition: wimax-helper.h:89
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition: wimax-helper.h:87
NetDeviceType
Net Device Type Distinguish a subscriber station(SS) device from base station(BS) device.
Definition: wimax-helper.h:66
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition: wimax-helper.h:68
Ptr< WimaxChannel > m_channel
wifi channel
Definition: wimax-helper.h:326
Ptr< WimaxPhy > CreatePhyWithoutChannel(PhyType phyType)
static void EnableLogComponents(void)
Helper to enable all WimaxNetDevice log components with one statement.
Ptr< UplinkScheduler > CreateUplinkScheduler(SchedulerType schedulerType)
void SetPropagationLossModel(SimpleOfdmWimaxChannel::PropModel propagationModel)
Set the propagation and loss model of the channel.
Definition: wimax-helper.cc:94
PhyType
WiMAX Physical layer WiMAX Physical layers with different levels of detail.
Definition: wimax-helper.h:77
Ptr< BSScheduler > CreateBSScheduler(SchedulerType schedulerType)
Ptr< WimaxPhy > CreatePhy(PhyType phyType)
Definition: wimax-helper.cc:74
static void AsciiTxEvent(Ptr< OutputStreamWrapper > stream, std::string path, Ptr< const Packet > packet, const Mac48Address &dest)
ASCII trace transmit event.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static void EnableAsciiForConnection(Ptr< OutputStreamWrapper > oss, uint32_t nodeid, uint32_t deviceid, char *netdevice, char *connection)
Enable ascii trace output on the indicated net device for a given connection.
Definition: wimax-helper.cc:52
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
static void AsciiRxEvent(Ptr< OutputStreamWrapper > stream, std::string path, Ptr< const Packet > packet, const Mac48Address &source)
ASCII trace receive event.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename, bool promiscuous)
Enable pcap output on the indicated net device.
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
WimaxHelper(void)
Create a Wimax helper in an empty state.
Definition: wimax-helper.cc:43
this class implements the mac to mac header needed to dump a wimax pcap file The header format was re...
Hold together all WiMAX-related objects in a NetDevice.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1709
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
devices
Definition: first.py:39
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void PcapSniffTxRxEvent(Ptr< PcapFileWrapper > file, Ptr< const PacketBurst > burst)
print pcap record
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361
channel
Definition: third.py:92
phy
Definition: third.py:93
#define list