22 #include "wimax-helper.h"
23 #include "ns3/simulator.h"
24 #include "ns3/packet.h"
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"
48 WimaxHelper::~WimaxHelper (
void)
58 std::ostringstream oss;
59 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::" << netdevice <<
"/" << connection
60 <<
"/TxQueue/Enqueue";
61 Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultEnqueueSinkWithContext, os));
64 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::" << netdevice <<
"/" << connection
65 <<
"/TxQueue/Dequeue";
66 Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDequeueSinkWithContext, os));
69 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::" << netdevice <<
"/" << connection
71 Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, os));
79 case SIMPLE_PHY_TYPE_OFDM:
80 phy = CreateObject<SimpleOfdmWimaxPhy> ();
83 m_channel = CreateObject<SimpleOfdmWimaxChannel> (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
98 m_channel = CreateObject<SimpleOfdmWimaxChannel> ();
109 case SIMPLE_PHY_TYPE_OFDM:
110 sphy = CreateObject<SimpleOfdmWimaxPhy> ();
112 sphy->SetSNRToBlockErrorRateTracesPath (SNRTraceFilePath);
113 sphy->ActivateLoss (activateLoss);
116 m_channel = CreateObject<SimpleOfdmWimaxChannel> (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
132 case SIMPLE_PHY_TYPE_OFDM:
133 phy = CreateObject<SimpleOfdmWimaxPhy> ();
149 case SIMPLE_PHY_TYPE_OFDM:
150 sphy = CreateObject<SimpleOfdmWimaxPhy> ();
152 sphy->SetSNRToBlockErrorRateTracesPath (SNRTraceFilePath);
153 sphy->ActivateLoss (activateLoss);
166 switch (schedulerType)
169 uplinkScheduler = CreateObject<UplinkSchedulerSimple> ();
172 uplinkScheduler = CreateObject<UplinkSchedulerRtps> ();
175 uplinkScheduler = CreateObject<UplinkSchedulerMBQoS> (
Seconds (0.25));
181 return uplinkScheduler;
187 switch (schedulerType)
190 bsScheduler = CreateObject<BSSchedulerSimple> ();
193 bsScheduler = CreateObject<BSSchedulerRtps> ();
196 bsScheduler = CreateObject<BSSchedulerSimple> ();
209 double frameDuration)
212 for (NodeContainer::Iterator i = c.
Begin (); i != c.
End (); i++)
218 phy->SetFrameDuration (
Seconds (frameDuration));
228 deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
230 uplinkScheduler->SetBs (deviceBS);
231 bsScheduler->SetBs (deviceBS);
235 device = CreateObject<SubscriberStationNetDevice> (node, phy);
238 phy->SetDevice (device);
240 device->Attach (m_channel);
244 devices.
Add (device);
255 for (NodeContainer::Iterator i = c.
Begin (); i != c.
End (); i++)
267 deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
269 uplinkScheduler->SetBs (deviceBS);
270 bsScheduler->SetBs (deviceBS);
274 device = CreateObject<SubscriberStationNetDevice> (node, phy);
277 phy->SetDevice (device);
279 device->Attach (m_channel);
283 devices.
Add (device);
295 for (NodeContainer::Iterator i = c.
Begin (); i != c.
End (); i++)
307 deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
309 uplinkScheduler->SetBs (deviceBS);
310 bsScheduler->SetBs (deviceBS);
314 device = CreateObject<SubscriberStationNetDevice> (node, phy);
317 phy->SetDevice (device);
319 device->Attach (channel);
322 devices.
Add (device);
343 deviceBS = CreateObject<BaseStationNetDevice> (node, phy, uplinkScheduler, bsScheduler);
345 uplinkScheduler->SetBs (deviceBS);
346 bsScheduler->SetBs (deviceBS);
350 device = CreateObject<SubscriberStationNetDevice> (node, phy);
353 phy->SetDevice (device);
355 device->Attach (channel);
413 *stream->
GetStream () << path << std::endl;
416 void WimaxHelper::AsciiTxEvent (Ptr<OutputStreamWrapper> stream, std::string path, Ptr<const Packet> packet,
const Mac48Address &dest)
419 *stream->GetStream () << path << std::endl;
423 ServiceFlow::SchedulingType schedulinType,
428 serviceFlow.SetConvergenceSublayerParam (csParam);
429 serviceFlow.SetCsSpecification (ServiceFlow::IPV4);
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);
449 bool explicitFilename)
459 NS_LOG_INFO (
"WimaxHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::WimaxNetDevice");
483 std::string filename;
484 if (explicitFilename)
494 uint32_t nodeid = nd->GetNode ()->GetId ();
495 uint32_t deviceid = nd->GetIfIndex ();
496 std::ostringstream oss;
501 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WimaxNetDevice/Rx";
502 Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiRxEvent, theStream));
504 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WimaxNetDevice/Tx";
505 Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiTxEvent, theStream));
511 EnableAsciiForConnection (theStream, nodeid, deviceid, (
char*)
"WimaxNetDevice", (
char*)
"InitialRangingConnection");
513 EnableAsciiForConnection (theStream, nodeid, deviceid, (
char*)
"SubscriberStationNetDevice", (
char*)
"BasicConnection");
514 EnableAsciiForConnection (theStream, nodeid, deviceid, (
char*)
"SubscriberStationNetDevice", (
char*)
"PrimaryConnection");
530 uint32_t nodeid = nd->GetNode ()->GetId ();
531 uint32_t deviceid = nd->GetIfIndex ();
532 std::ostringstream oss;
534 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WimaxNetDevice/Rx";
535 Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiRxEvent, stream));
538 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WimaxNetDevice/Tx";
539 Config::Connect (oss.str (), MakeBoundCallback (&WimaxHelper::AsciiTxEvent, stream));
543 EnableAsciiForConnection (stream, nodeid, deviceid, (
char*)
"SubscriberStationNetDevice", (
char*)
"BasicConnection");
544 EnableAsciiForConnection (stream, nodeid, deviceid, (
char*)
"SubscriberStationNetDevice", (
char*)
"PrimaryConnection");
551 std::list<Ptr<Packet> > packets = burst->
GetPackets ();
552 for (std::list<
Ptr<Packet> >::iterator iter = packets.begin (); iter != packets.end (); ++iter)
572 NS_LOG_INFO (
"WimaxHelper::EnablePcapInternal(): Device " << &device <<
" not of type ns3::WimaxNetDevice");
578 std::string filename;
579 if (explicitFilename)
590 phy->TraceConnectWithoutContext (
"Tx", MakeBoundCallback (&PcapSniffTxRxEvent, file));
591 phy->TraceConnectWithoutContext (
"Rx", MakeBoundCallback (&PcapSniffTxRxEvent, file));
598 return m_channel->AssignStreams (stream);
604 int64_t currentStream = stream;
606 for (NetDeviceContainer::Iterator i = c.
Begin (); i != c.
End (); ++i)
613 currentStream += wimax->GetPhy ()->AssignStreams (currentStream);
618 currentStream += m_channel->AssignStreams (currentStream);
620 return (currentStream - stream);
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Manage ASCII trace files for device models.
#define NS_LOG_FUNCTION(parameters)
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0)
Create and initialize a pcap file.
Manage pcap files for device models.
void Write(Time t, Ptr< const Packet > p)
Write the next packet to file.
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
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. ...
void Connect(std::string path, const CallbackBase &cb)
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...
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
#define NS_FATAL_ERROR(msg)
fatal error handling
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.
double GetSeconds(void) const
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...
static Mac48Address Allocate(void)
static void EnablePrinting(void)
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
holds a vector of ns3::NetDevice pointers
void SetPropagationLossModel(SimpleOfdmWimaxChannel::PropModel propagationModel)
Set the propagation and loss model of the channel. By default the channel uses a COST231 propagation ...
Ptr< Packet > Copy(void) const
Hold together all Wimax-related objects in a NetDevice.This class holds together ns3::WimaxPhy, ns3::WimaxConnection, ns3::ConectionManager, ns3::BurstProfileManager, and ns3::BandwidthManager.
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
int64_t AssignStreams(int64_t stream)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
uint32_t AddDevice(Ptr< NetDevice > device)
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
Ptr< WimaxPhy > CreatePhyWithoutChannel(PhyType phyType)
Ptr< BSScheduler > CreateBSScheduler(SchedulerType schedulerType)
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename, bool promiscuous)
Enable pcap output on the indicated net device.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
static void EnableLogComponents(void)
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< WimaxPhy > CreatePhy(PhyType phyType)
Ptr< UplinkScheduler > CreateUplinkScheduler(SchedulerType schedulerType)
WimaxHelper(void)
Create a Wimax helper in an empty state.
std::list< Ptr< Packet > > GetPackets(void) const
std::ostream * GetStream(void)
void AddHeader(const Header &header)
void LogComponentEnable(char const *name, enum LogLevel level)