A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
bs-net-device.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008,2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8 * <amine.ismail@UDcast.com>
9 */
10
11#include "bs-net-device.h"
12
13#include "bandwidth-manager.h"
14#include "bs-link-manager.h"
15#include "bs-scheduler.h"
16#include "bs-uplink-scheduler.h"
18#include "connection-manager.h"
20#include "service-flow.h"
21#include "ss-manager.h"
22#include "ss-record.h"
23#include "wimax-mac-queue.h"
24#include "wimax-phy.h"
25
26#include "ns3/enum.h"
27#include "ns3/ipv4-address.h"
28#include "ns3/llc-snap-header.h"
29#include "ns3/node.h"
30#include "ns3/packet-burst.h"
31#include "ns3/pointer.h"
32#include "ns3/simulator.h"
33#include "ns3/trace-source-accessor.h"
34#include "ns3/uinteger.h"
35
36#include <cmath>
37
38namespace ns3
39{
40
41NS_LOG_COMPONENT_DEFINE("BaseStationNetDevice");
42
43NS_OBJECT_ENSURE_REGISTERED(BaseStationNetDevice);
44
45TypeId
47{
48 static TypeId tid =
49 TypeId("ns3::BaseStationNetDevice")
50
52
53 .SetGroupName("Wimax")
54
55 .AddConstructor<BaseStationNetDevice>()
56
57 .AddAttribute("BSScheduler",
58 "Downlink Scheduler for BS",
62
63 .AddAttribute("InitialRangInterval",
64 "Time between Initial Ranging regions assigned by the BS. Maximum is 2s",
65 TimeValue(Seconds(0.05)),
69
70 .AddAttribute("DcdInterval",
71 "Time between transmission of DCD messages. Maximum value is 10s.",
76
77 .AddAttribute("UcdInterval",
78 "Time between transmission of UCD messages. Maximum value is 10s.",
83
84 .AddAttribute("IntervalT8",
85 "Wait for DSA/DSC Acknowledge timeout. Maximum 300ms.",
86 TimeValue(Seconds(0.05)),
90
91 .AddAttribute("RangReqOppSize",
92 "The ranging opportunity size in symbols",
97
98 .AddAttribute("BwReqOppSize",
99 "The bandwidth request opportunity size in symbols",
100 UintegerValue(2),
104
105 .AddAttribute(
106 "MaxRangCorrectionRetries",
107 "Number of retries on contention Ranging Requests",
108 UintegerValue(16),
112
113 .AddAttribute("SSManager",
114 "The ss manager attached to this device.",
115 PointerValue(),
119
120 .AddAttribute("Scheduler",
121 "The BS scheduler attached to this device.",
122 PointerValue(),
126
127 .AddAttribute("LinkManager",
128 "The link manager attached to this device.",
129 PointerValue(),
133
134 .AddAttribute("UplinkScheduler",
135 "The uplink scheduler attached to this device.",
136 PointerValue(),
140
141 .AddAttribute("BsIpcsPacketClassifier",
142 "The uplink IP packet classifier attached to this device.",
143 PointerValue(),
147
148 .AddAttribute("ServiceFlowManager",
149 "The service flow manager attached to this device.",
150 PointerValue(),
154
155 .AddTraceSource("BSTx",
156 "A packet has been received from higher layers "
157 "and is being processed in preparation "
158 "for queueing for transmission.",
160 "ns3::Packet::TracedCallback")
161
162 .AddTraceSource("BSTxDrop",
163 "A packet has been dropped in the MAC layer "
164 "before being queued for transmission.",
166 "ns3::Packet::TracedCallback")
167
168 .AddTraceSource("BSPromiscRx",
169 "A packet has been received by this device, "
170 "has been passed up from the physical layer "
171 "and is being forwarded up the local protocol stack. "
172 "This is a promiscuous trace,",
174 "ns3::Packet::TracedCallback")
175
176 .AddTraceSource("BSRx",
177 "A packet has been received by this device, "
178 "has been passed up from the physical layer "
179 "and is being forwarded up the local protocol stack. "
180 "This is a non-promiscuous trace,",
182 "ns3::Packet::TracedCallback")
183
184 .AddTraceSource("BSRxDrop",
185 "A packet has been dropped in the MAC layer "
186 "after it has been passed up from the physical layer.",
188 "ns3::Packet::TracedCallback");
189 return tid;
190}
191
196
197void
199{
200 m_initialRangInterval = Seconds(0.05); // maximum is 2
201 m_dcdInterval = Seconds(3); // maximum is 10
202 m_ucdInterval = Seconds(3); // maximum is 10
203 m_intervalT8 = MilliSeconds(50); // maximum is 300 milliseconds
207 8; // 8 symbols = 2 (preamble) + 2 (RNG-REQ) + 4 (round-trip propagation time)
208 m_bwReqOppSize = 2; // 2 symbols = 1 (preamble) + 1 (bandwidth request header)
209 m_nrDlSymbols = 0;
210 m_nrUlSymbols = 0;
211 m_nrDlMapSent = 0;
212 m_nrUlMapSent = 0;
213 m_nrDcdSent = 0;
214 m_nrUcdSent = 0;
219 m_nrDlFrames = 0;
220 m_nrUlFrames = 0;
232 m_cidFactory = new CidFactory();
236}
237
244
246 Ptr<WimaxPhy> phy,
247 Ptr<UplinkScheduler> uplinkScheduler,
248 Ptr<BSScheduler> bsScheduler)
249{
251 this->SetNode(node);
252 this->SetPhy(phy);
253 m_uplinkScheduler = uplinkScheduler;
254 m_scheduler = bsScheduler;
255}
256
260
261void
263{
264 delete m_cidFactory;
265
266 m_linkManager = nullptr;
267 m_ssManager = nullptr;
268 m_bsClassifier = nullptr;
269 m_serviceFlowManager = nullptr;
270 m_uplinkScheduler = nullptr;
271 m_cidFactory = nullptr;
272 m_ssManager = nullptr;
273 m_uplinkScheduler = nullptr;
274 m_scheduler = nullptr;
275
277}
278
279void
284
290
291void
293{
294 m_initialRangInterval = initialRangInterval;
295}
296
297Time
302
303void
305{
306 m_dcdInterval = dcdInterval;
307}
308
309Time
314
315void
317{
318 m_ucdInterval = ucdInterval;
319}
320
321Time
326
327void
329{
330 m_intervalT8 = interval;
331}
332
333Time
338
339void
341{
342 m_maxRangCorrectionRetries = maxRangCorrectionRetries;
343}
344
345uint8_t
350
351void
353{
354 m_maxInvitedRangRetries = maxInvitedRangRetries;
355}
356
357uint8_t
362
363void
365{
366 m_rangReqOppSize = rangReqOppSize;
367}
368
369uint8_t
374
375void
377{
378 m_bwReqOppSize = bwReqOppSize;
379}
380
381uint8_t
386
387void
389{
390 m_nrDlSymbols = nrDlSymbols;
391}
392
398
399void
401{
402 m_nrUlSymbols = nrUlSymbols;
403}
404
410
416
422
423Time
428
429Time
434
435uint8_t
440
446
447void
452
458
459void
464
470
471void
476
482
483void
488
489void
494
500
501Time
506
507Time
512
513void
515{
517 GetConnectionManager()->SetCidFactory(m_cidFactory);
518 GetPhy()->SetPhyParameters();
519 GetPhy()->SetDataRates();
520 SetTtg(GetPhy()->GetTtg());
521 SetRtg(GetPhy()->GetRtg());
522 m_psDuration = GetPhy()->GetPsDuration();
523 m_symbolDuration = GetPhy()->GetSymbolDuration();
524 GetBandwidthManager()->SetSubframeRatio();
525
527 GetPhy()->SetSimplex(m_linkManager->SelectDlChannel());
529
530 /* shall actually be 2 symbols = 1 (preamble) + 1 (bandwidth request header)*/
531 m_bwReqOppSize = 6;
532 m_uplinkScheduler->InitOnce();
533}
534
535void
539
540void
542{
543 // setting DL/UL subframe allocation for this frame
544 uint32_t symbolsPerFrame = GetPhy()->GetSymbolsPerFrame();
545 SetNrDlSymbols((symbolsPerFrame / 2) -
546 static_cast<uint32_t>(std::ceil(GetTtg() * m_psDuration.GetSeconds() /
548 SetNrUlSymbols((symbolsPerFrame / 2) -
549 static_cast<uint32_t>(std::ceil(GetRtg() * m_psDuration.GetSeconds() /
551
553
554 NS_LOG_INFO("----------------------frame" << GetNrFrames() + 1 << "----------------------");
555
557}
558
559void
577
578void
587
588void
602
603void
612
613void
618
619bool
621 const Mac48Address& source,
622 const Mac48Address& dest,
623 uint16_t protocolNumber)
624{
626 ServiceFlow* serviceFlow = nullptr;
627
628 NS_LOG_INFO("BS (" << source << "):");
629 NS_LOG_INFO("\tSending packet...");
630 NS_LOG_INFO("\t\tDestination: " << dest);
631 NS_LOG_INFO("\t\tPacket Size: " << packet->GetSize());
632 NS_LOG_INFO("\t\tProtocol: " << protocolNumber);
633
634 if (protocolNumber == 2048)
635 {
636 serviceFlow = m_bsClassifier->Classify(packet,
639 }
640
641 if (protocolNumber != 2048 || serviceFlow == nullptr)
642 {
643 serviceFlow = *GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_ALL).begin();
644 }
645
646 if (serviceFlow == nullptr)
647 {
648 NS_LOG_INFO("No Service Flow!!");
649 m_bsTxDropTrace(packet);
650 return false;
651 }
652 if (serviceFlow->GetIsEnabled())
653 {
654 if (!Enqueue(packet, MacHeaderType(), serviceFlow->GetConnection()))
655 {
656 NS_LOG_INFO("Enqueue Error!!");
657 m_bsTxDropTrace(packet);
658 return false;
659 }
660 }
661 else
662 {
663 m_bsTxDropTrace(packet);
664 NS_LOG_INFO("Service Flow is not enabled");
665 return false;
666 }
667 m_bsTxTrace(packet);
668
669 return true;
670}
671
672bool
674 const MacHeaderType& hdrType,
675 Ptr<WimaxConnection> connection)
676{
678 connection,
679 "BS: Can not enqueue packet on the selected connection: the connection is not initialized");
680
682 hdr.SetLen(packet->GetSize() + hdr.GetSerializedSize());
683
684 hdr.SetCid(connection->GetCid());
685
686 return connection->Enqueue(packet, hdrType, hdr);
687}
688
689void
691{
692 GenericMacHeader gnrcMacHdr;
693 BandwidthRequestHeader bwRequestHdr;
694 ManagementMessageType msgType;
695 RngReq rngReq;
696 Cid cid;
697 uint8_t type = 0;
698 GrantManagementSubheader grantMgmntSubhdr;
699 Mac48Address source;
700 LlcSnapHeader llc;
701 Ptr<WimaxConnection> connection = nullptr;
702 FragmentationSubheader fragSubhdr;
703 bool fragmentation = false; // it becomes true when there is a fragmentation subheader
704
705 packet->RemoveHeader(gnrcMacHdr);
706 if (gnrcMacHdr.GetHt() == MacHeaderType::HEADER_TYPE_GENERIC)
707 {
708 if (!gnrcMacHdr.check_hcs())
709 {
710 // The header is noisy
711 m_bsRxDropTrace(packet);
712 NS_LOG_INFO("Header HCS ERROR");
713 return;
714 }
715
716 cid = gnrcMacHdr.GetCid();
717
718 // checking for subheaders (only grant management subheader is implemented)
719 type = gnrcMacHdr.GetType();
720 if (type)
721 {
722 // checking 1st bit, see Table 6
723 if (type & 1)
724 {
725 packet->RemoveHeader(grantMgmntSubhdr);
726 }
727 // Check if there is a fragmentation Subheader
728 uint8_t tmpType = type;
729 if (((tmpType >> 2) & 1) == 1)
730 {
731 // a TRANSPORT packet with fragmentation subheader has been received!
732 NS_LOG_INFO("FRAG_DEBUG: DoReceive -> the packet is a fragment" << std::endl);
733 fragmentation = true;
734 }
735 }
736
737 if (cid.IsInitialRanging()) // initial ranging connection
738 {
739 packet->RemoveHeader(msgType);
740 switch (msgType.GetType())
741 {
743 packet->RemoveHeader(rngReq);
744 m_linkManager->ProcessRangingRequest(cid, rngReq);
745 break;
746 }
748 // from other base station, ignore
749 break;
750 default:
751 NS_FATAL_ERROR("Invalid message type");
752 }
753 }
754 else if (m_cidFactory->IsBasic(cid)) // basic management connection
755 {
756 source = m_ssManager->GetMacAddress(cid);
757 m_traceBSRx(packet, source, cid);
758 packet->RemoveHeader(msgType);
759 switch (msgType.GetType())
760 {
762 packet->RemoveHeader(rngReq);
763 m_linkManager->ProcessRangingRequest(cid, rngReq);
764 break;
765 }
767 // from other base station, ignore
768 break;
769 default:
770 NS_FATAL_ERROR("Invalid message type");
771 }
772 }
773 else if (m_cidFactory->IsPrimary(cid)) // primary management connection
774 {
775 source = m_ssManager->GetMacAddress(cid);
776 m_traceBSRx(packet, source, cid);
777 packet->RemoveHeader(msgType);
778 switch (msgType.GetType())
779 {
781 // not yet implemented
783 // from other base station, ignore
784 break;
786 DsaReq dsaReq;
787 packet->RemoveHeader(dsaReq);
788 GetServiceFlowManager()->AllocateServiceFlows(dsaReq, cid);
789 break;
790 }
792
793 /*from other base station, as DSA initiated
794 from BS is not supported, ignore*/
795 break;
797 Simulator::Cancel(GetServiceFlowManager()->GetDsaAckTimeoutEvent());
798 DsaAck dsaAck;
799 packet->RemoveHeader(dsaAck);
800 GetServiceFlowManager()->ProcessDsaAck(dsaAck, cid);
801 break;
802 }
803 default:
804 NS_FATAL_ERROR("Invalid message type");
805 }
806 }
807 else if (cid.IsBroadcast()) // broadcast connection
808 {
809 // from other base station, ignore
810 // or perhaps data packet (using other protocol) for BS, handle later
811 return;
812 }
813 else // transport connection
814 {
815 // If fragmentation is true, the packet is a fragment.
816 Ptr<Packet> C_Packet = packet->Copy();
817 if (!fragmentation)
818 {
819 C_Packet->RemoveHeader(llc);
820 source = m_ssManager->GetMacAddress(cid);
821 m_bsRxTrace(packet);
822 ForwardUp(packet->Copy(), source, Mac48Address::GetBroadcast());
823 }
824 else
825 {
826 NS_LOG_INFO("FRAG_DEBUG: BS DoReceive, the Packet is a fragment" << std::endl);
827 packet->RemoveHeader(fragSubhdr);
828 uint32_t fc = fragSubhdr.GetFc();
829 NS_LOG_INFO("\t fragment size = " << packet->GetSize() << std::endl);
830 if (fc == 2)
831 {
832 // This is the latest fragment.
833 // Take the fragment queue, defragment a packet and send it to the upper layer
834 NS_LOG_INFO("\t Received the latest fragment" << std::endl);
835 GetConnectionManager()->GetConnection(cid)->FragmentEnqueue(packet);
836 WimaxConnection::FragmentsQueue fragmentsQueue =
837 GetConnectionManager()->GetConnection(cid)->GetFragmentsQueue();
838 Ptr<Packet> fullPacket = Create<Packet>();
839
840 // DEFRAGMENTATION
841 NS_LOG_INFO("\t BS PACKET DEFRAGMENTATION" << std::endl);
842 for (auto iter = fragmentsQueue.begin(); iter != fragmentsQueue.end(); ++iter)
843 {
844 // Create the whole Packet
845 fullPacket->AddAtEnd(*iter);
846 }
847 GetConnectionManager()->GetConnection(cid)->ClearFragmentsQueue();
848
849 NS_LOG_INFO("\t fullPacket size = " << fullPacket->GetSize() << std::endl);
850 source = m_ssManager->GetMacAddress(cid);
851 m_bsRxTrace(fullPacket);
852 ForwardUp(fullPacket->Copy(), source, Mac48Address::GetBroadcast());
853 }
854 else
855 {
856 // This is the first or middle fragment.
857 // Take the fragment queue, store the fragment into the queue
858 NS_LOG_INFO("\t Received the first or the middle fragment" << std::endl);
859 GetConnectionManager()->GetConnection(cid)->FragmentEnqueue(packet);
860 }
861 }
862 }
863 }
864 else
865 {
866 // bandwidth request header
867 packet->AddHeader(gnrcMacHdr);
868 packet->RemoveHeader(bwRequestHdr);
870 "A bandwidth request should be carried by a bandwidth header type");
871 if (!bwRequestHdr.check_hcs())
872 {
873 // The header is noisy
874 NS_LOG_INFO("BS:Header HCS ERROR");
875 return;
876 }
877 cid = bwRequestHdr.GetCid();
878 source = m_ssManager->GetMacAddress(cid);
879 m_traceBSRx(packet, source, cid);
880 GetBandwidthManager()->ProcessBandwidthRequest(bwRequestHdr);
881 }
882}
883
884void
886{
887 Ptr<Packet> dlmap;
888 Ptr<Packet> ulmap;
889 bool sendDcd = false;
890 bool sendUcd = false;
891 bool updateDcd = false;
892 bool updateUcd = false;
893
894 uint16_t currentNrSsRegistered = m_ssManager->GetNRegisteredSSs();
895
896 if (m_nrSsRegistered == currentNrSsRegistered)
897 {
898 m_uplinkScheduler->GetChannelDescriptorsToUpdate(updateDcd, updateUcd, sendDcd, sendUcd);
899 }
900 else
901 {
902 sendDcd = sendUcd = true;
903 }
904
905 m_nrSsRegistered = currentNrSsRegistered;
906
907 /*either DCD and UCD must be created first because CCC is set during their
908 creation, or CCC must be calculated first so that it could be set during
909 creation of DL-MAP and UL-MAP and then set during creation of DCD and UCD*/
910
911 if (sendDcd)
912 {
913 m_dcdConfigChangeCount += 1 % 256;
914 }
915
916 if (sendUcd)
917 {
918 m_ucdConfigChangeCount += 1 % 256;
919 }
920
921 dlmap = CreateDlMap();
924
925 ulmap = CreateUlMap();
928
929 CreateDescriptorMessages(sendDcd, sendUcd);
930}
931
932void
934{
935 Ptr<Packet> dcd;
936 Ptr<Packet> ucd;
937
938 if (sendDcd)
939 {
940 dcd = CreateDcd();
942 m_nrDcdSent++;
944 }
945 else
946 {
948 }
949
950 if (sendUcd)
951 {
952 ucd = CreateUcd();
954 m_nrUcdSent++;
956 }
957 else
958 {
960 }
961}
962
963/*
964 Sends bursts in the downlink subframe. i.e., creates the downlink subframe. The first burst
965 is broadcast burst with MAC management messages. The rest of the bursts contain data packets.
966 */
967void
969{
970 Time txTime = Seconds(0);
971 std::pair<OfdmDlMapIe*, Ptr<PacketBurst>> pair;
973 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>* downlinkBursts =
974 m_scheduler->GetDownlinkBursts();
975 Ptr<PacketBurst> burst;
976 OfdmDlMapIe* dlMapIe;
977 Cid cid;
978
979 while (!downlinkBursts->empty())
980 {
981 pair = downlinkBursts->front();
982 burst = pair.second;
983 dlMapIe = pair.first;
984 cid = dlMapIe->GetCid();
985 uint8_t diuc = dlMapIe->GetDiuc();
986
987 if (cid != GetInitialRangingConnection()->GetCid() &&
988 cid != GetBroadcastConnection()->GetCid())
989 {
990 modulationType =
991 GetBurstProfileManager()->GetModulationType(diuc,
993 }
994 else
995 {
996 modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12;
997 }
998
999 Simulator::Schedule(txTime, &WimaxNetDevice::ForwardDown, this, burst, modulationType);
1000 txTime += GetPhy()->GetTransmissionTime(burst->GetSize(), modulationType);
1001 downlinkBursts->pop_front();
1002 delete dlMapIe;
1003 }
1004}
1005
1008{
1010
1011 DlMap dlmap;
1014
1015 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>* downlinkBursts =
1016 m_scheduler->GetDownlinkBursts();
1017
1018 for (auto iter = downlinkBursts->begin(); iter != downlinkBursts->end(); ++iter)
1019 {
1020 iter->first->SetPreamblePresent(0);
1021 iter->first->SetStartTime(0);
1022 dlmap.AddDlMapElement(*(iter->first));
1023 }
1024
1025 OfdmDlMapIe dlMapIeEnd;
1026
1027 dlMapIeEnd.SetCid(Cid::InitialRanging());
1029 dlMapIeEnd.SetPreamblePresent(0);
1030 dlMapIeEnd.SetStartTime(0);
1031
1032 dlmap.AddDlMapElement(dlMapIeEnd);
1033 m_nrDlAllocations = downlinkBursts->size();
1034
1036 p->AddHeader(dlmap);
1038 return p;
1039}
1040
1043{
1044 Dcd dcd;
1045 OfdmDcdChannelEncodings chnlEncodings;
1046
1047 chnlEncodings.SetBsEirp(0);
1048 chnlEncodings.SetEirxPIrMax(0);
1049 chnlEncodings.SetFrequency(GetPhy()->GetFrequency());
1050 chnlEncodings.SetChannelNr(0);
1051 chnlEncodings.SetTtg(GetTtg());
1052 chnlEncodings.SetRtg(GetRtg());
1053 chnlEncodings.SetBaseStationId(GetMacAddress());
1054 chnlEncodings.SetFrameDurationCode(GetPhy()->GetFrameDurationCode());
1055 chnlEncodings.SetFrameNumber(GetNrFrames());
1056
1058 dcd.SetChannelEncodings(chnlEncodings);
1059
1060 SetDlBurstProfiles(&dcd);
1061 SetCurrentDcd(dcd);
1062
1064 p->AddHeader(dcd);
1066 return p;
1067}
1068
1071{
1075
1076 UlMap ulmap;
1078 ulmap.SetAllocationStartTime(m_uplinkScheduler->CalculateAllocationStartTime());
1079
1080 std::list<OfdmUlMapIe> uplinkAllocations = m_uplinkScheduler->GetUplinkAllocations();
1081
1082 for (auto iter = uplinkAllocations.begin(); iter != uplinkAllocations.end(); ++iter)
1083 {
1084 ulmap.AddUlMapElement(*iter);
1085 }
1086
1087 m_nrUlAllocations = uplinkAllocations.size();
1088
1090 p->AddHeader(ulmap);
1092 return p;
1093}
1094
1097{
1098 Ucd ucd;
1100 ucd.SetRangingBackoffStart(3); // setting to 7. i.e., 2^3 = 8 -> 0-7
1101 ucd.SetRangingBackoffEnd(6); // setting to 63. i.e., 2^6 = 64 -> 0-63
1103 ucd.SetRequestBackoffEnd(6);
1104
1105 OfdmUcdChannelEncodings chnlEncodings;
1106
1107 chnlEncodings.SetBwReqOppSize(m_bwReqOppSize * GetPhy()->GetPsPerSymbol());
1108 chnlEncodings.SetRangReqOppSize(m_rangReqOppSize * GetPhy()->GetPsPerSymbol());
1109
1110 chnlEncodings.SetFrequency(GetPhy()->GetFrequency());
1111 chnlEncodings.SetSbchnlReqRegionFullParams(0);
1112 chnlEncodings.SetSbchnlFocContCodes(0);
1113
1114 ucd.SetChannelEncodings(chnlEncodings);
1115
1116 SetUlBurstProfiles(&ucd);
1117 SetCurrentUcd(ucd);
1118
1120 p->AddHeader(ucd);
1122 return p;
1123}
1124
1125void
1127{
1128 for (int i = 0; i < GetBurstProfileManager()->GetNrBurstProfilesToDefine(); ++i)
1129 {
1130 OfdmDlBurstProfile brstProfile;
1131 brstProfile.SetType(0);
1132 brstProfile.SetLength(0);
1133 brstProfile.SetDiuc(i + 1); // DIUC will be between 1-11, see Table 237
1134 brstProfile.SetFecCodeType(i);
1135 dcd->AddDlBurstProfile(brstProfile);
1136 }
1137}
1138
1139void
1141{
1142 for (int i = 0; i < GetBurstProfileManager()->GetNrBurstProfilesToDefine(); ++i)
1143 {
1144 OfdmUlBurstProfile brstProfile;
1145 brstProfile.SetType(0);
1146 brstProfile.SetLength(0);
1147 // UIUC will be between 5-12, see Table 246. UIUC 1 (initial ranging) is not included
1148 brstProfile.SetUiuc(i + 5);
1149 brstProfile.SetFecCodeType(i);
1150
1151 ucd->AddUlBurstProfile(brstProfile);
1152 }
1153}
1154
1157{
1158 Ptr<WimaxConnection> connection = nullptr;
1159 if (cid.IsInitialRanging())
1160 {
1162 }
1163 else if (cid.IsBroadcast())
1164 {
1165 connection = GetBroadcastConnection();
1166 }
1167 else
1168 {
1169 connection = GetConnectionManager()->GetConnection(cid);
1170 }
1171
1172 NS_ASSERT_MSG(connection, "BS: Invalid connection=0");
1173 return connection;
1174}
1175
1176void
1178{
1179 uint16_t symbolsToAllocation = 0;
1180 std::list<OfdmUlMapIe> uplinkAllocations = m_uplinkScheduler->GetUplinkAllocations();
1181 for (auto iter = uplinkAllocations.begin(); iter != uplinkAllocations.end(); ++iter)
1182 {
1183 OfdmUlMapIe uplinkAllocation = *iter;
1184
1185 if (uplinkAllocation.GetUiuc() == OfdmUlBurstProfile::UIUC_END_OF_MAP)
1186 {
1187 break;
1188 }
1189
1190 symbolsToAllocation = uplinkAllocation.GetStartTime();
1191 MarkUplinkAllocationStart(symbolsToAllocation * m_symbolDuration);
1192 MarkUplinkAllocationEnd((symbolsToAllocation + uplinkAllocation.GetDuration()) *
1194 uplinkAllocation.GetCid(),
1195 uplinkAllocation.GetUiuc());
1196 }
1197}
1198
1199void
1204
1205void
1206BaseStationNetDevice::MarkUplinkAllocationEnd(Time allocationEndTime, Cid cid, uint8_t uiuc)
1207{
1208 Simulator::Schedule(allocationEndTime,
1210 this,
1211 cid,
1212 uiuc);
1213}
1214
1215void
1217{
1219
1220 NS_LOG_DEBUG("--UL allocation " << (uint32_t)m_ulAllocationNumber
1221 << " started : " << Simulator::Now().As(Time::S));
1222}
1223
1224void
1226{
1227 NS_LOG_DEBUG("--UL allocation " << (uint32_t)m_ulAllocationNumber
1228 << " ended : " << Simulator::Now().As(Time::S));
1229
1230 if (m_cidFactory->IsBasic(cid))
1231 {
1232 m_linkManager->VerifyInvitedRanging(cid, uiuc);
1233 }
1234}
1235
1236void
1238{
1240}
1241
1242void
1244{
1246
1247 NS_LOG_DEBUG("Ranging TO " << (uint32_t)m_rangingOppNumber << ": "
1248 << Simulator::Now().As(Time::S));
1249}
1250
1251} // namespace ns3
This class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
uint8_t GetHt() const
Get HT field.
bool check_hcs() const
Check HCS.
Cid GetCid() const
Get CID field.
BaseStation NetDevice.
uint32_t m_nrUlMapSent
number UL map sent
uint8_t GetBwReqOppSize() const
void SetDcdInterval(Time dcdInterval)
Ptr< BSScheduler > GetBSScheduler() const
TracedCallback< Ptr< const Packet >, Mac48Address, Cid > m_traceBSRx
the base station receive trace callback
void SetBsClassifier(Ptr< IpcsClassifier > classifier)
Ptr< UplinkScheduler > m_uplinkScheduler
the uplink scheduler
uint8_t m_bwReqOppSize
in symbols
void SetBwReqOppSize(uint8_t bwReqOppSize)
void SetUcdInterval(Time ucdInterval)
void SetRangReqOppSize(uint8_t rangReqOppSize)
void RangingOppStart()
Ranging opp start.
Time m_ulSubframeStartTime
UL subframe start time.
void SetDlBurstProfiles(Dcd *dcd)
Send DL burst profiles.
void UplinkAllocationStart()
Uplink allocation start.
uint32_t GetNrDlSymbols() const
Ptr< SSManager > m_ssManager
the SS manager
void Stop() override
Stop device.
Ptr< IpcsClassifier > GetBsClassifier() const
uint8_t GetRangReqOppSize() const
Ptr< Packet > CreateUcd()
Create UCD.
Time GetDlSubframeStartTime() const
uint8_t GetMaxRangingCorrectionRetries() const
CidFactory * m_cidFactory
the CID factory
uint32_t m_framesSinceLastDcd
frames since last DCD
uint32_t m_ucdConfigChangeCount
UCD config change count.
uint8_t m_rangingOppNumber
current ranging TO number
uint32_t m_allocationStartTime
allocation start time
void SetNrDlSymbols(uint32_t dlSymbols)
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 ...
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 MarkRangingOppStart(Time rangingOppStartTime)
Mark ranging opp start.
void SetMaxRangingCorrectionRetries(uint8_t maxRangCorrectionRetries)
uint32_t m_nrDlSymbols
number of DL symbols
uint32_t GetNrUcdSent() const
uint32_t m_nrUlSymbols
number of UL symbols
Ptr< WimaxConnection > GetConnection(Cid cid)
uint8_t m_maxRangCorrectionRetries
maximum range correction retries
void MarkUplinkAllocationStart(Time allocationStartTime)
Mark uplink allocation start.
uint32_t m_nrDlFrames
number DL frames
void SetBSScheduler(Ptr< BSScheduler > bsSchedule)
static TypeId GetTypeId()
Get the type ID.
void Start() override
Start device.
uint16_t m_nrUlAllocations
number UL allocations
uint32_t m_nrDcdSent
number DCD sent
void StartFrame()
Start frame function.
Ptr< IpcsClassifier > m_bsClassifier
the base station classifier
void SetIntervalT8(Time interval)
Ptr< Packet > CreateUlMap()
Create UL map.
void EndFrame()
End frame function.
void DoDispose() override
Destructor implementation.
Ptr< BsServiceFlowManager > m_serviceFlowManager
the service flow manager
void SetInitialRangingInterval(Time initialRangInterval)
uint16_t m_nrSsRegistered
number SS registered
Time m_psDuration
ps duration
uint8_t m_maxInvitedRangRetries
maximum invited range retries
uint8_t m_ulAllocationNumber
to see UL burst number
Time GetInitialRangingInterval() const
void MarkUplinkAllocationEnd(Time allocationEndTime, Cid cid, uint8_t uiuc)
Mark uplink allocation end.
void SetNrUlSymbols(uint32_t ulSymbols)
void SetSSManager(Ptr< SSManager > ssManager)
void StartDlSubFrame()
Start DL subframe function.
Ptr< SSManager > GetSSManager() const
Ptr< Packet > CreateDlMap()
Create DL map.
void SetLinkManager(Ptr< BSLinkManager > linkManager)
void SetMaxInvitedRangRetries(uint8_t maxInvitedRangRetries)
Time m_symbolDuration
symbol duration
Time m_initialRangInterval
in seconds
void CreateDescriptorMessages(bool sendDcd, bool sendUcd)
creates the channel descriptor MAC management messages DCD and UCD
void SetUplinkScheduler(Ptr< UplinkScheduler > ulScheduler)
void UplinkAllocationEnd(Cid cid, uint8_t uiuc)
Uplink allocation end.
uint32_t m_nrUcdSent
number UCD sent
void StartUlSubFrame()
Start UL subframe function.
uint32_t m_nrUlFrames
number UL frames
void EndUlSubFrame()
End UL subframe function.
uint32_t GetNrUlSymbols() const
uint32_t m_dcdConfigChangeCount
DCD config change count.
uint32_t m_framesSinceLastUcd
frames since last UCD
void InitBaseStationNetDevice()
initializes the BS net device and sets its parameters to the default values
uint8_t m_rangReqOppSize
in symbols
Ptr< BSLinkManager > GetLinkManager() const
void CreateMapMessages()
creates the MAC management messages DL-MAP and UL-MAP
uint8_t GetMaxInvitedRangRetries() const
void DoReceive(Ptr< Packet > packet) override
Receive packet.
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, Ptr< WimaxConnection > connection) override
Enqueue a packet into a connection queue.
void SetServiceFlowManager(Ptr< BsServiceFlowManager > sfm)
Set service flow manager.
Ptr< Packet > CreateDcd()
Create DCD.
Ptr< BSScheduler > m_scheduler
the base station scheduler
Time m_intervalT8
in milliseconds, wait for DSA/DSC Acknowledge timeout
bool DoSend(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest, uint16_t protocolNumber) override
Send packet.
void SendBursts()
Send burst function.
uint32_t m_nrDlMapSent
number DL map sent
Ptr< UplinkScheduler > GetUplinkScheduler() const
Time m_dlSubframeStartTime
DL subframe start time.
Time GetUlSubframeStartTime() const
uint16_t m_nrDlAllocations
number DL allocations
void EndDlSubFrame()
End DL subframe function.
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< BsServiceFlowManager > GetServiceFlowManager() const
Ptr< BSLinkManager > m_linkManager
the link manager
TracedCallback< Ptr< const Packet > > m_bsPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
uint8_t GetRangingOppNumber() const
void MarkUplinkAllocations()
Mark uplink allocations.
void SetUlBurstProfiles(Ucd *ucd)
Send UL burst profiles.
TracedCallback< Ptr< const Packet > > m_bsRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
uint32_t GetNrDcdSent() const
This class is used exclusively by the BS to allocate CIDs to new connections.
Definition cid-factory.h:35
bool IsBasic(Cid cid) const
This function determines if the CID is basic.
bool IsPrimary(Cid cid) const
This function determines if the CID is primary.
Cid class.
Definition cid.h:26
bool IsInitialRanging() const
Definition cid.cc:58
static Cid InitialRanging()
Definition cid.cc:76
bool IsBroadcast() const
Definition cid.cc:46
void SetBsEirp(uint16_t bs_eirp)
Set BS EIRP field.
void SetFrequency(uint32_t frequency)
Set frequency field.
void SetEirxPIrMax(uint16_t rss_ir_max)
Set EIRX IR MAX field.
This class implements Downlink channel descriptor as described by "IEEE Standard forLocal and metropo...
void SetConfigurationChangeCount(uint8_t configurationChangeCount)
Set configuration change count field.
void AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile)
Add DL burst profile field.
void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings)
Set channel encodings field.
This class implements DL-MAP as described by "IEEE Standard forLocal and metropolitan area networks P...
void SetDcdCount(uint8_t dcdCount)
Set DCD count field.
void AddDlMapElement(OfdmDlMapIe dlMapElement)
Add DL Map element field.
void SetBaseStationId(Mac48Address baseStationID)
Set base station ID field.
This class implements the DSA-ACK message described by "IEEE Standard forLocal and metropolitan area ...
This class implements the DSA-REQ message described by "IEEE Standard forLocal and metropolitan area ...
This class implements the fragmentation sub-header as described by IEEE Standard for Local and metrop...
uint8_t GetFc() const
Get FC field.
This class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
uint8_t GetType() const
Get type field.
bool check_hcs() const
Check HCS.
uint8_t GetHt() const
Get HT field.
uint32_t GetSerializedSize() const override
void SetLen(uint16_t len)
Set length field.
void SetCid(Cid cid)
Set CID field.
Cid GetCid() const
Get CID field.
This class implements the grant management sub-header as described by IEEE Standard for Local and met...
Header for the LLC/SNAP encapsulation.
an EUI-48 address
static Mac48Address GetBroadcast()
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
Mac Management messages Section 6.3.2.3 MAC Management messages page 42, Table 14 page 43.
uint8_t GetType() const
Get type field.
This class implements the OFDM DCD channel encodings as described by "IEEE Standard forLocal and metr...
void SetChannelNr(uint8_t channelNr)
Set channel number field.
void SetTtg(uint8_t ttg)
Set TTG field.
void SetFrameDurationCode(uint8_t frameDurationCode)
Set frame duration code field.
void SetRtg(uint8_t rtg)
Set RTG field.
void SetFrameNumber(uint32_t frameNumber)
Set frame number field.
void SetBaseStationId(Mac48Address baseStationId)
Set base station ID field.
This class implements the OFDM Downlink burst profile descriptor as described by "IEEE Standardfor Lo...
void SetFecCodeType(uint8_t fecCodeType)
Set FEC code type.
void SetLength(uint8_t length)
Set length field.
void SetType(uint8_t type)
Set type field.
void SetDiuc(uint8_t diuc)
Set DIUC field.
This class implements the OFDM DL-MAP information element as described by "IEEE Standard forLocal and...
void SetStartTime(uint16_t startTime)
Set start time field.
uint8_t GetDiuc() const
Get DIUC field.
void SetCid(Cid cid)
Set CID function.
Cid GetCid() const
Set CID field.
void SetDiuc(uint8_t diuc)
Set DIUC field.
void SetPreamblePresent(uint8_t preamblePresent)
Set preamble present field.
This class implements the OFDM UCD channel encodings as described by "IEEE Standard forLocal and metr...
void SetSbchnlReqRegionFullParams(uint8_t sbchnlReqRegionFullParams)
Set SB channel reguest region full parameters.
void SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes)
Set SB channel for control codes.
This class implements the UL burst profile as described by "IEEE Standard forLocal and metropolitan a...
void SetLength(uint8_t length)
Set length.
void SetUiuc(uint8_t uiuc)
Set UIUC.
void SetFecCodeType(uint8_t fecCodeType)
Set FEC code type.
void SetType(uint8_t type)
Set type.
This class implements the UL-MAP_IE message as described by "IEEE Standard forLocal and metropolitan ...
uint16_t GetDuration() const
Get duration.
Cid GetCid() const
Get CID.
uint8_t GetUiuc() const
Get UIUC.
uint16_t GetStartTime() const
Get start time.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
This class implements the ranging request message described by "IEEE Standard forLocal and metropolit...
This class implements service flows as described by the IEEE-802.16 standard.
bool GetIsEnabled() const
Get is enabled flag.
Ptr< WimaxConnection > GetConnection() const
Can return a null connection is this service flow has not been associated yet to a connection.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
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...
Definition simulator.cc:274
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition simulator.h:594
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:392
@ S
second
Definition nstime.h:105
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
void SetRangReqOppSize(uint16_t rangReqOppSize)
Set range request opp size.
void SetFrequency(uint32_t frequency)
Set frequency.
void SetBwReqOppSize(uint16_t bwReqOppSize)
Set BW request opp size.
This class implements the UCD message as described by "IEEE Standard forLocal and metropolitan area n...
void AddUlBurstProfile(OfdmUlBurstProfile ulBurstProfile)
Add UL burst profile.
void SetChannelEncodings(OfdmUcdChannelEncodings channelEncodings)
Set channel encodings.
void SetConfigurationChangeCount(uint8_t ucdCount)
Set configuration change count.
void SetRangingBackoffStart(uint8_t rangingBackoffStart)
Set ranging backoff start.
void SetRangingBackoffEnd(uint8_t rangingBackoffEnd)
Set ranging backoff end.
void SetRequestBackoffEnd(uint8_t requestBackoffEnd)
Set request backoff end.
void SetRequestBackoffStart(uint8_t requestBackoffStart)
Set request backoff start.
Hold an unsigned integer type.
Definition uinteger.h:34
This class implements the UL-MAP_IE message as described by "IEEE Standard forLocal and metropolitan ...
void SetAllocationStartTime(uint32_t allocationStartTime)
Set allocation start time.
void AddUlMapElement(OfdmUlMapIe ulMapElement)
Add UL map element.
void SetUcdCount(uint8_t ucdCount)
Set UCD count.
std::list< Ptr< const Packet > > FragmentsQueue
Definition of Fragments Queue data type.
Hold together all WiMAX-related objects in a NetDevice.
void DoDispose() override
Destructor implementation.
uint16_t GetRtg() const
Get receive/transmit transition gap.
void SetRtg(uint16_t rtg)
Set receive/transmit transition gap.
static uint8_t m_direction
downlink or uplink
Ptr< ConnectionManager > GetConnectionManager() const
Get the connection manager of the device.
void SetPhy(Ptr< WimaxPhy > phy)
Set the physical layer object.
void SetCurrentUcd(Ucd ucd)
Set the current UCD.
uint32_t GetNrFrames() const
Get the number of frames.
static Time m_frameStartTime
temp, to determine the frame start time at SS side, shall actually be determined by frame start pream...
void SetState(uint8_t state)
Set the device state.
Ptr< WimaxConnection > GetInitialRangingConnection() const
Get the initial ranging connection.
Ptr< WimaxPhy > GetPhy() const
Get the physical layer object.
Ptr< BandwidthManager > GetBandwidthManager() const
Get the bandwidth manager on the device.
Ptr< WimaxConnection > GetBroadcastConnection() const
Get the broadcast connection.
void SetTtg(uint16_t ttg)
Set transmission/receive transition gap.
void CreateDefaultConnections()
Creates the initial ranging and broadcast connections.
void SetNrFrames(uint32_t nrFrames)
Set the number of frames.
void SetCurrentDcd(Dcd dcd)
Set the current DCD.
void SetReceiveCallback()
Set receive callback function.
uint16_t GetTtg() const
Get transmission/receive transition gap.
Mac48Address GetMacAddress() const
Get the MAC address.
void SetNode(Ptr< Node > node) override
Set node pointer.
void ForwardUp(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest)
Forward a packet to the next layer above the device.
Ptr< BurstProfileManager > GetBurstProfileManager() const
Get the burst profile manager.
void ForwardDown(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType)
Forward a packet down the stack.
ModulationType
ModulationType enumeration.
Definition wimax-phy.h:43
@ MODULATION_TYPE_BPSK_12
Definition wimax-phy.h:44
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416