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",
"A packet has been received from higher layers and is being processed in preparation for "
155 .AddTraceSource (
"BSTxDrop",
156 "A packet has been dropped in the MAC layer before being queued for transmission.",
159 .AddTraceSource (
"BSPromiscRx",
160 "A packet has been received by this device, has been passed up from the physical layer "
161 "and is being forwarded up the local protocol stack. This is a promiscuous trace,",
164 .AddTraceSource (
"BSRx",
165 "A packet has been received by this device, has been passed up from the physical layer "
166 "and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
169 .AddTraceSource (
"BSRxDrop",
170 "A packet has been dropped in the MAC layer after it has been passed up from the physical "
502 GetPhy ()->SetPhyParameters ();
503 GetPhy ()->SetDataRates ();
528 uint32_t symbolsPerFrame =
GetPhy ()->GetSymbolsPerFrame ();
599 uint16_t protocolNumber)
611 if (protocolNumber == 2048)
616 if (protocolNumber != 2048 || serviceFlow == 0)
621 if (serviceFlow == 0)
627 if (serviceFlow->GetIsEnabled ())
651 "BS: Can not enqueue packet on the selected connection: the connection is not initialized");
656 hdr.
SetCid (connection->GetCid ());
658 return connection->Enqueue (packet, hdrType, hdr);
675 bool fragmentation =
false;
688 cid = gnrcMacHdr.
GetCid ();
700 uint8_t tmpType = type;
701 if (((tmpType >> 2) & 1) == 1)
704 NS_LOG_INFO (
"FRAG_DEBUG: DoReceive -> the packet is a fragment" << std::endl);
705 fragmentation =
true;
803 NS_LOG_INFO (
"FRAG_DEBUG: BS DoReceive, the Packet is a fragment" << std::endl);
805 uint32_t fc = fragSubhdr.
GetFc ();
811 NS_LOG_INFO (
"\t Received the latest fragment" << std::endl);
813 ->FragmentEnqueue (packet);
819 NS_LOG_INFO (
"\t BS PACKET DEFRAGMENTATION" << std::endl);
821 iter != fragmentsQueue.end (); ++iter)
827 ->ClearFragmentsQueue ();
838 NS_LOG_INFO (
"\t Received the first or the middle fragment" << std::endl);
840 ->FragmentEnqueue (packet);
851 "A bandwidth request should be carried by a bandwidth header type");
858 cid = bwRequestHdr.
GetCid ();
870 bool sendDcd =
false, sendUcd =
false, updateDcd =
false, updateUcd =
false;
872 uint16_t currentNrSsRegistered =
m_ssManager->GetNRegisteredSSs ();
876 m_uplinkScheduler->GetChannelDescriptorsToUpdate (updateDcd, updateUcd, sendDcd, sendUcd);
880 sendDcd = sendUcd =
true;
947 Time txTime = Seconds (0);
948 std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
950 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts =
m_scheduler->GetDownlinkBursts ();
955 while (downlinkBursts->size ())
957 pair = downlinkBursts->front ();
959 dlMapIe = pair.first;
961 uint8_t diuc = dlMapIe->
GetDiuc ();
980 txTime +=
GetPhy ()->GetTransmissionTime (burst->GetSize (), modulationType);
981 downlinkBursts->pop_front ();
995 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts =
m_scheduler->GetDownlinkBursts ();
998 != downlinkBursts->end (); ++iter)
1000 iter->first->SetPreamblePresent (0);
1001 iter->first->SetStartTime (0);
1060 std::list<OfdmUlMapIe> uplinkAllocations =
m_uplinkScheduler->GetUplinkAllocations ();
1062 for (std::list<OfdmUlMapIe>::iterator iter = uplinkAllocations.begin (); iter != uplinkAllocations.end (); ++iter)
1152 NS_ASSERT_MSG (connection != 0,
"BS: Invalid connection=0");
1159 uint16_t symbolsToAllocation = 0;
1160 std::list<OfdmUlMapIe> uplinkAllocations =
m_uplinkScheduler->GetUplinkAllocations ();
1161 for (std::list<OfdmUlMapIe>::iterator iter = uplinkAllocations.begin (); iter != uplinkAllocations.end (); ++iter)
1170 symbolsToAllocation = uplinkAllocation.
GetStartTime ();
void SetUcdInterval(Time ucdInterval)
uint32_t RemoveHeader(Header &header)
BaseStationNetDevice(void)
void RangingOppStart(void)
uint8_t m_rangingOppNumber
void SetRtg(uint16_t rtg)
keep track of time values and allow control of global simulation resolution
void SetUcdCount(uint8_t ucdCount)
Time GetIntervalT8(void) const
void SetNrDlSymbols(uint32_t dlSymbols)
uint16_t GetRtg(void) const
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)
void SetRangingBackoffEnd(uint8_t rangingBackoffEnd)
void SetLinkManager(Ptr< BSLinkManager > linkManager)
void ForwardUp(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest)
#define NS_LOG_COMPONENT_DEFINE(name)
Ptr< WimaxConnection > GetBroadcastConnection(void) const
uint32_t GetSize(void) const
Ptr< BSScheduler > GetBSScheduler(void) const
TracedCallback< Ptr< const Packet > > m_bsRxTrace
uint8_t GetMaxRangingCorrectionRetries(void) const
bool IsBroadcast(void) const
Time m_initialRangInterval
static void Cancel(const EventId &id)
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)
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)
#define NS_FATAL_ERROR(msg)
fatal error handling
void SetStartTime(uint16_t startTime)
uint16_t m_nrUlAllocations
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
void AddAtEnd(Ptr< const Packet > 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
void SetDiuc(uint8_t diuc)
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, Ptr< WimaxConnection > connection)
Enqueue a packet into a connection queue.
uint16_t GetTtg(void) const
void SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes)
void SetCurrentDcd(Dcd dcd)
void SetRangReqOppSize(uint8_t rangReqOppSize)
hold objects of type ns3::Time
void SetTtg(uint16_t ttg)
TracedCallback< Ptr< const Packet > > m_bsTxDropTrace
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)
void SetAllocationStartTime(uint32_t allocationStartTime)
bool IsInitialRanging(void) const
static TypeId GetTypeId(void)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
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)
~BaseStationNetDevice(void)
Mac48Address GetMacAddress(void) const
Ptr< IpcsClassifier > m_bsClassifier
virtual void DoDispose(void)
Ptr< Packet > CreateDlMap(void)
void SetFrameNumber(uint32_t frameNumber)
Ptr< BsServiceFlowManager > GetServiceFlowManager(void) const
uint8_t GetUiuc(void) const
Ptr< Packet > Copy(void) const
void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings)
uint8_t GetBwReqOppSize(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.
uint16_t GetDuration(void) const
hold objects of type Ptr<T>
this class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
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
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
std::list< Ptr< const Packet > > FragmentsQueue
void SetDcdInterval(Time dcdInterval)
TracedCallback< Ptr< const Packet > > m_bsPromiscRxTrace
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
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)
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)
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)
Ptr< SSManager > GetSSManager(void) const
void SetRequestBackoffEnd(uint8_t requestBackoffEnd)
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)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
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 >)
void MarkUplinkAllocations(void)
uint8_t GetHt(void) const
void SetNrUlSymbols(uint32_t ulSymbols)
CidFactory * m_cidFactory
virtual void SetNode(Ptr< Node > node)
bool IsPrimary(Cid cid) const
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)
void SetFecCodeType(uint8_t fecCodeType)
static uint8_t m_direction
void SetType(uint8_t type)
Ptr< Packet > CreateDcd(void)