25 #include "ns3/simulator.h"
26 #include "ns3/drop-tail-queue.h"
31 #include "ns3/packet-burst.h"
37 #include "ns3/trace-source-accessor.h"
38 #include "ns3/pointer.h"
40 #include "ns3/uinteger.h"
46 #include "ns3/ipv4-address.h"
47 #include "ns3/llc-snap-header.h"
61 .AddConstructor<BaseStationNetDevice> ()
63 .AddAttribute (
"BSScheduler",
64 "Downlink Scheduler for BS",
67 MakePointerChecker<BSScheduler> ())
69 .AddAttribute (
"InitialRangInterval",
70 "Time between Initial Ranging regions assigned by the BS. Maximum is 2s",
76 .AddAttribute (
"DcdInterval",
77 "Time between transmission of DCD messages. Maximum value is 10s.",
82 .AddAttribute (
"UcdInterval",
83 "Time between transmission of UCD messages. Maximum value is 10s.",
88 .AddAttribute (
"IntervalT8",
89 "Wait for DSA/DSC Acknowledge timeout. Maximum 300ms.",
94 .AddAttribute (
"RangReqOppSize",
95 "The ranging opportunity size in symbols",
99 MakeUintegerChecker<uint8_t> (1, 256))
101 .AddAttribute (
"BwReqOppSize",
102 "The bandwidth request opportunity size in symbols",
105 MakeUintegerChecker<uint8_t> (1, 256))
107 .AddAttribute (
"MaxRangCorrectionRetries",
108 "Number of retries on contention Ranging Requests",
112 MakeUintegerChecker<uint8_t> (1, 16))
114 .AddAttribute (
"SSManager",
115 "The ss manager attached to this device.",
118 MakePointerChecker<SSManager> ())
120 .AddAttribute (
"Scheduler",
121 "The BS scheduler attached to this device.",
124 MakePointerChecker<BSScheduler> ())
126 .AddAttribute (
"LinkManager",
127 "The link manager attached to this device.",
130 MakePointerChecker<BSLinkManager> ())
132 .AddAttribute (
"UplinkScheduler",
133 "The uplink scheduler attached to this device.",
137 MakePointerChecker<UplinkScheduler> ())
139 .AddAttribute (
"BsIpcsPacketClassifier",
140 "The uplink IP packet classifier attached to this device.",
143 MakePointerChecker<IpcsClassifier> ())
145 .AddAttribute (
"ServiceFlowManager",
146 "The service flow manager attached to this device.",
150 MakePointerChecker<ServiceFlowManager> ())
152 .AddTraceSource (
"BSTx",
153 "A packet has been received from higher layers "
154 "and is being processed in preparation "
155 "for queueing for transmission.",
157 "ns3::Packet::TracedCallback")
159 .AddTraceSource (
"BSTxDrop",
160 "A packet has been dropped in the MAC layer "
161 "before being queued for transmission.",
163 "ns3::Packet::TracedCallback")
165 .AddTraceSource (
"BSPromiscRx",
166 "A packet has been received by this device, "
167 "has been passed up from the physical layer "
168 "and is being forwarded up the local protocol stack. "
169 "This is a promiscuous trace,",
171 "ns3::Packet::TracedCallback")
173 .AddTraceSource (
"BSRx",
174 "A packet has been received by this device, "
175 "has been passed up from the physical layer "
176 "and is being forwarded up the local protocol stack. "
177 "This is a non-promiscuous trace,",
179 "ns3::Packet::TracedCallback")
181 .AddTraceSource (
"BSRxDrop",
182 "A packet has been dropped in the MAC layer "
183 "after it has been passed up from the physical layer.",
185 "ns3::Packet::TracedCallback");
515 GetPhy ()->SetPhyParameters ();
516 GetPhy ()->SetDataRates ();
541 uint32_t symbolsPerFrame =
GetPhy ()->GetSymbolsPerFrame ();
612 uint16_t protocolNumber)
624 if (protocolNumber == 2048)
629 if (protocolNumber != 2048 || serviceFlow == 0)
634 if (serviceFlow == 0)
640 if (serviceFlow->GetIsEnabled ())
664 "BS: Can not enqueue packet on the selected connection: the connection is not initialized");
669 hdr.
SetCid (connection->GetCid ());
671 return connection->Enqueue (packet, hdrType, hdr);
688 bool fragmentation =
false;
701 cid = gnrcMacHdr.
GetCid ();
713 uint8_t tmpType = type;
714 if (((tmpType >> 2) & 1) == 1)
717 NS_LOG_INFO (
"FRAG_DEBUG: DoReceive -> the packet is a fragment" << std::endl);
718 fragmentation =
true;
816 NS_LOG_INFO (
"FRAG_DEBUG: BS DoReceive, the Packet is a fragment" << std::endl);
818 uint32_t fc = fragSubhdr.
GetFc ();
824 NS_LOG_INFO (
"\t Received the latest fragment" << std::endl);
826 ->FragmentEnqueue (packet);
832 NS_LOG_INFO (
"\t BS PACKET DEFRAGMENTATION" << std::endl);
834 iter != fragmentsQueue.end (); ++iter)
840 ->ClearFragmentsQueue ();
851 NS_LOG_INFO (
"\t Received the first or the middle fragment" << std::endl);
853 ->FragmentEnqueue (packet);
864 "A bandwidth request should be carried by a bandwidth header type");
871 cid = bwRequestHdr.
GetCid ();
883 bool sendDcd =
false, sendUcd =
false, updateDcd =
false, updateUcd =
false;
885 uint16_t currentNrSsRegistered =
m_ssManager->GetNRegisteredSSs ();
889 m_uplinkScheduler->GetChannelDescriptorsToUpdate (updateDcd, updateUcd, sendDcd, sendUcd);
893 sendDcd = sendUcd =
true;
961 std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
963 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts =
m_scheduler->GetDownlinkBursts ();
968 while (downlinkBursts->size ())
970 pair = downlinkBursts->front ();
972 dlMapIe = pair.first;
974 uint8_t diuc = dlMapIe->
GetDiuc ();
993 txTime +=
GetPhy ()->GetTransmissionTime (burst->GetSize (), modulationType);
994 downlinkBursts->pop_front ();
1008 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts =
m_scheduler->GetDownlinkBursts ();
1011 != downlinkBursts->end (); ++iter)
1013 iter->first->SetPreamblePresent (0);
1014 iter->first->SetStartTime (0);
1073 std::list<OfdmUlMapIe> uplinkAllocations =
m_uplinkScheduler->GetUplinkAllocations ();
1075 for (std::list<OfdmUlMapIe>::iterator iter = uplinkAllocations.begin (); iter != uplinkAllocations.end (); ++iter)
1165 NS_ASSERT_MSG (connection != 0,
"BS: Invalid connection=0");
1172 uint16_t symbolsToAllocation = 0;
1173 std::list<OfdmUlMapIe> uplinkAllocations =
m_uplinkScheduler->GetUplinkAllocations ();
1174 for (std::list<OfdmUlMapIe>::iterator iter = uplinkAllocations.begin (); iter != uplinkAllocations.end (); ++iter)
1183 symbolsToAllocation = uplinkAllocation.
GetStartTime ();
void SetUcdInterval(Time ucdInterval)
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
BaseStationNetDevice(void)
void RangingOppStart(void)
uint8_t m_rangingOppNumber
void SetRtg(uint16_t rtg)
Simulation virtual time values and global simulation resolution.
void SetUcdCount(uint8_t ucdCount)
Time GetIntervalT8(void) const
void SetNrDlSymbols(uint32_t dlSymbols)
Introspection did not find any typical Config paths.
Introspection did not find any typical Config paths.
uint16_t GetRtg(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void StartDlSubFrame(void)
void SetEirxPIrMax(uint16_t rss_ir_max)
uint32_t GetNrDcdSent(void) const
uint16_t m_nrSsRegistered
void SetLength(uint8_t length)
void MarkRangingOppStart(Time rangingOppStartTime)
void SetBsEirp(uint16_t bs_eirp)
Introspection did not find any typical Config paths.
void SetRangingBackoffEnd(uint8_t rangingBackoffEnd)
Introspection did not find any typical Config paths.
void SetLinkManager(Ptr< BSLinkManager > linkManager)
void ForwardUp(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< WimaxConnection > GetBroadcastConnection(void) const
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Ptr< BSScheduler > GetBSScheduler(void) const
TracedCallback< Ptr< const Packet > > m_bsRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
uint8_t GetMaxRangingCorrectionRetries(void) const
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
bool IsBroadcast(void) const
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Time m_initialRangInterval
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
void SetBSScheduler(Ptr< BSScheduler > bsSchedule)
Ptr< ConnectionManager > GetConnectionManager(void) const
uint8_t GetRangReqOppSize(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
uint8_t GetType(void) const
Ptr< Packet > CreateUcd(void)
void SetChannelNr(uint8_t channelNr)
void SetMaxInvitedRangRetries(uint8_t maxInvitedRangRetries)
void SetIntervalT8(Time interval)
void SetBsClassifier(Ptr< IpcsClassifier > classifier)
void SetType(uint8_t type)
void SetLength(uint8_t length)
void UplinkAllocationEnd(Cid cid, uint8_t uiuc)
bool IsBasic(Cid cid) const
void SetDiuc(uint8_t diuc)
void SetChannelEncodings(OfdmUcdChannelEncodings channelEncodings)
void SetStartTime(uint16_t startTime)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint16_t m_nrUlAllocations
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetPreamblePresent(uint8_t preamblePresent)
void SetFrameDurationCode(uint8_t frameDurationCode)
uint32_t GetNrFrames(void) const
Time GetDcdInterval(void) const
void SetSbchnlReqRegionFullParams(uint8_t sbchnlReqRegionFullParams)
void SetBaseStationId(Mac48Address baseStationID)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void SetRequestBackoffStart(uint8_t requestBackoffStart)
Ptr< Packet > CreateUlMap(void)
uint32_t m_framesSinceLastDcd
void MarkUplinkAllocationStart(Time allocationStartTime)
uint8_t GetMaxInvitedRangRetries(void) const
TracedCallback< Ptr< const Packet > > m_bsRxDropTrace
The trace source fired when packets coming into the "top" of the device are dropped at the MAC layer ...
void SetDiuc(uint8_t diuc)
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, Ptr< WimaxConnection > connection)
Enqueue a packet into a connection queue.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint16_t GetTtg(void) const
void SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes)
void SetCurrentDcd(Dcd dcd)
void SetRangReqOppSize(uint8_t rangReqOppSize)
AttributeValue implementation for Time.
void SetTtg(uint16_t ttg)
TracedCallback< Ptr< const Packet > > m_bsTxDropTrace
The trace source fired when packets coming into the "top" of the device are dropped at the MAC layer ...
Time GetInitialRangingInterval(void) const
void SetFecCodeType(uint8_t fecCodeType)
static Cid InitialRanging(void)
Time GetSymbolDuration(void) const
Hold an unsigned integer type.
void SetDcdCount(uint8_t dcdCount)
void SetUiuc(uint8_t uiuc)
Introspection did not find any typical Config paths.
void SetAllocationStartTime(uint32_t allocationStartTime)
bool IsInitialRanging(void) const
static TypeId GetTypeId(void)
void SetRangingBackoffStart(uint8_t rangingBackoffStart)
Time GetPsDuration(void) const
uint16_t m_nrDlAllocations
Ptr< UplinkScheduler > GetUplinkScheduler(void) const
void SetInitialRangingInterval(Time initialRangInterval)
Ptr< IpcsClassifier > GetBsClassifier(void) const
Ptr< WimaxConnection > GetInitialRangingConnection(void) const
uint32_t m_allocationStartTime
Ptr< BandwidthManager > GetBandwidthManager(void) const
Ptr< BSLinkManager > m_linkManager
void SetBwReqOppSize(uint16_t bwReqOppSize)
void AddUlBurstProfile(OfdmUlBurstProfile ulBurstProfile)
Introspection did not find any typical Config paths.
~BaseStationNetDevice(void)
Mac48Address GetMacAddress(void) const
Ptr< IpcsClassifier > m_bsClassifier
virtual void DoDispose(void)
Destructor implementation.
Ptr< Packet > CreateDlMap(void)
void SetFrameNumber(uint32_t frameNumber)
Ptr< BsServiceFlowManager > GetServiceFlowManager(void) const
uint8_t GetUiuc(void) const
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings)
uint8_t GetBwReqOppSize(void) const
Hold together all Wimax-related objects in a NetDevice.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t GetDuration(void) const
Hold objects of type Ptr.
this class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
void SetFrequency(uint32_t frequency)
TracedCallback< Ptr< const Packet >, Mac48Address, Cid > m_traceBSRx
void AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile)
uint8_t GetRangingOppNumber(void) const
void SetRangReqOppSize(uint16_t rangReqOppSize)
Ptr< BSScheduler > m_scheduler
This class implements service flows as described by the IEEE-802.16 standard.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
std::list< Ptr< const Packet > > FragmentsQueue
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
void SetDcdInterval(Time dcdInterval)
TracedCallback< Ptr< const Packet > > m_bsPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
void SetPhy(Ptr< WimaxPhy > phy)
void CreateMapMessages(void)
creates the MAC management messages DL-MAP and UL-MAP
bool DoSend(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest, uint16_t protocolNumber)
TracedCallback< Ptr< const Packet > > m_bsTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition...
Ptr< SSManager > m_ssManager
void SetUplinkScheduler(Ptr< UplinkScheduler > ulScheduler)
uint32_t GetNrDlSymbols(void) const
void DoReceive(Ptr< Packet > packet)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void CreateDescriptorMessages(bool sendDcd, bool senUcd)
creates the channel descriptor MAC management messages DCD and UCD
void StartUlSubFrame(void)
void SetDlBurstProfiles(Dcd *dcd)
Ptr< BurstProfileManager > GetBurstProfileManager(void) const
void SetFrequency(uint32_t frequency)
void SetNrFrames(uint32_t nrFrames)
uint32_t GetNrUlSymbols(void) const
void SetMaxRangingCorrectionRetries(uint8_t maxRangCorrectionRetries)
uint32_t m_dcdConfigChangeCount
uint8_t m_maxRangCorrectionRetries
void SetConfigurationChangeCount(uint8_t ucdCount)
void SetCurrentUcd(Ucd ucd)
Introspection did not find any typical Config paths.
uint8_t m_ulAllocationNumber
Time m_dlSubframeStartTime
void ForwardDown(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType)
Ptr< BSLinkManager > GetLinkManager(void) const
Ptr< WimaxPhy > GetPhy(void) const
Time GetUcdInterval(void) const
void SetBwReqOppSize(uint8_t bwReqOppSize)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< SSManager > GetSSManager(void) const
void SetRequestBackoffEnd(uint8_t requestBackoffEnd)
Time Seconds(double value)
Construct a Time in the indicated unit.
void CreateDefaultConnections(void)
uint32_t m_framesSinceLastUcd
void MarkUplinkAllocationEnd(Time allocationEndTime, Cid cid, uint8_t uiuc)
Ptr< BsServiceFlowManager > m_serviceFlowManager
Time m_ulSubframeStartTime
Ptr< UplinkScheduler > m_uplinkScheduler
void SetUlBurstProfiles(Ucd *ucd)
Ptr< WimaxConnection > GetConnection(Cid cid)
void SetSSManager(Ptr< SSManager > ssManager)
uint8_t GetDiuc(void) const
Time GetDlSubframeStartTime(void) const
void SetBaseStationId(Mac48Address baseStationId)
uint32_t m_ucdConfigChangeCount
void SetState(uint8_t state)
bool check_hcs(void) const
void InitBaseStationNetDevice(void)
initializes the BS net device and sets its parameters to the default values
void AddDlMapElement(OfdmDlMapIe dlMapElement)
void SetServiceFlowManager(Ptr< BsServiceFlowManager >)
This class is used exclusively by the BS to allocate CIDs to new connections.
void DoDispose(void)
Destructor implementation.
void MarkUplinkAllocations(void)
uint8_t GetHt(void) const
void SetNrUlSymbols(uint32_t ulSymbols)
CidFactory * m_cidFactory
virtual void SetNode(Ptr< Node > node)
Introspection did not find any typical Config paths.
bool IsPrimary(Cid cid) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void UplinkAllocationStart(void)
void AddUlMapElement(OfdmUlMapIe ulMapElement)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void SetReceiveCallback(void)
Time GetUlSubframeStartTime(void) const
static Time m_frameStartTime
uint16_t GetStartTime(void) const
uint8_t m_maxInvitedRangRetries
void SetConfigurationChangeCount(uint8_t configurationChangeCount)
uint32_t GetNrUcdSent(void) const
void AddHeader(const Header &header)
Add header to this packet.
void SetFecCodeType(uint8_t fecCodeType)
static uint8_t m_direction
void SetType(uint8_t type)
Ptr< Packet > CreateDcd(void)