23 #include "ns3/simulator.h"
24 #include "ns3/drop-tail-queue.h"
28 #include "ns3/packet-burst.h"
34 #include "ns3/trace-source-accessor.h"
35 #include "ns3/pointer.h"
53 return (MicroSeconds (500000));
61 TypeId (
"ns3::SubscriberStationNetDevice")
65 .AddConstructor<SubscriberStationNetDevice> ()
67 .AddAttribute (
"BasicConnection",
71 MakePointerChecker<WimaxConnection> ())
73 .AddAttribute (
"PrimaryConnection",
77 MakePointerChecker<WimaxConnection> ())
79 .AddAttribute (
"LostDlMapInterval",
80 "Time since last received DL-MAP message before downlink synchronization is considered lost. Maximum is 600ms",
86 .AddAttribute (
"LostUlMapInterval",
87 "Time since last received UL-MAP before uplink synchronization is considered lost, maximum is 600.",
93 .AddAttribute (
"MaxDcdInterval",
94 "Maximum time between transmission of DCD messages. Maximum is 10s",
100 .AddAttribute (
"MaxUcdInterval",
101 "Maximum time between transmission of UCD messages. Maximum is 10s",
107 .AddAttribute (
"IntervalT1",
108 "Wait for DCD timeout. Maximum is 5*maxDcdInterval",
114 .AddAttribute (
"IntervalT2",
115 "Wait for broadcast ranging timeout, i.e., wait for initial ranging opportunity. Maximum is 5*Ranging interval",
121 .AddAttribute (
"IntervalT3",
122 "ranging Response reception timeout following the transmission of a ranging request. Maximum is 200ms",
128 .AddAttribute (
"IntervalT7",
129 "wait for DSA/DSC/DSD Response timeout. Maximum is 1s",
135 .AddAttribute (
"IntervalT12",
136 "Wait for UCD descriptor.Maximum is 5*MaxUcdInterval",
142 .AddAttribute (
"IntervalT20",
143 "Time the SS searches for preambles on a given channel. Minimum is 2 MAC frames",
149 .AddAttribute (
"IntervalT21",
150 "time the SS searches for (decodable) DL-MAP on a given channel",
156 .AddAttribute (
"MaxContentionRangingRetries",
157 "Number of retries on contention Ranging Requests",
161 MakeUintegerChecker<uint8_t> (1, 16))
163 .AddAttribute (
"SSScheduler",
164 "The ss scheduler attached to this device.",
168 MakePointerChecker<SSScheduler> ())
170 .AddAttribute (
"LinkManager",
171 "The ss link manager attached to this device.",
175 MakePointerChecker<SSLinkManager> ())
177 .AddAttribute (
"Classifier",
178 "The ss classifier attached to this device.",
182 MakePointerChecker<IpcsClassifier> ())
184 .AddTraceSource (
"SSTxDrop",
185 "A packet has been dropped in the MAC layer before being queued for transmission.",
188 .AddTraceSource (
"SSPromiscRx",
189 "A packet has been received by this device, has been passed up from the physical layer "
190 "and is being forwarded up the local protocol stack. This is a promiscuous trace,",
193 .AddTraceSource (
"SSRx",
194 "A packet has been received by this device, has been passed up from the physical layer "
195 "and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
198 .AddTraceSource (
"SSRxDrop",
199 "A packet has been dropped in the MAC layer after it has been passed up from the physical "
586 uint16_t protocolNumber)
603 NS_LOG_INFO (
"\tCan't send packet! (NotRegitered with the network)");
607 NS_LOG_DEBUG (
"packet to send, size : " << packet->
GetSize () <<
", destination : " << dest);
611 NS_LOG_INFO (
"\tCan't send packet! (No service Flow)");
615 if (protocolNumber == 2048)
620 if ((protocolNumber != 2048) || (serviceFlow == NULL))
623 NS_LOG_INFO (
"\tNo service flows matches...using the default one.");
626 NS_LOG_INFO (
"\tPacket classified in the service flow SFID = " << serviceFlow->
GetSfid () <<
" CID = "
627 << serviceFlow->
GetCid ());
643 NS_LOG_INFO (
"Error!! The Service Flow is not enabled" );
656 NS_ASSERT_MSG (connection != 0,
"SS: Can not enqueue the packet: the selected connection is nor initialized");
673 "Error while equeuing packet: incorrect header type");
676 grantMgmntSubhdr.
SetPm (
true);
680 NS_LOG_INFO (
"ServiceFlowManager: enqueuing packet" );
681 return connection->
Enqueue (packet, hdrType, hdr);
741 uint32_t pktSize = packet->
GetSize ();
744 bool fragmentation =
false;
756 cid = gnrcMacHdr.
GetCid ();
759 uint8_t type = gnrcMacHdr.
GetType ();
763 uint8_t tmpType = type;
764 if (((tmpType >> 2) & 1) == 1)
767 fragmentation =
true;
768 NS_LOG_INFO (
"SS DoReceive -> the packet is a fragment" << std::endl);
921 "SS: Error while receiving a ranging response message: SS state should be SS_STATE_WAITING_RNG_RSP");
940 "SS: Error while receiving a ranging response message: SS state should be SS_STATE_WAITING_RNG_RSP");
996 NS_LOG_INFO (
"FRAG_DEBUG: SS DoReceive, the Packet is a fragment" << std::endl);
998 uint32_t fc = fragSubhdr.
GetFc ();
1005 NS_LOG_INFO (
"\t Received the latest fragment" << std::endl);
1010 GetConnection (cid)->GetFragmentsQueue ();
1015 NS_LOG_INFO (
"\t SS PACKET DEFRAGMENTATION" << std::endl);
1017 iter != fragmentsQueue.end (); ++iter)
1033 NS_LOG_INFO (
"\t Received the first or the middle fragment" << std::endl);
1069 for (std::list<OfdmDlMapIe>::iterator iter = dlMapElements.begin (); iter != dlMapElements.end (); ++iter)
1085 uint8_t temp = iter->GetDiuc ();
1086 temp = iter->GetPreamblePresent ();
1087 temp = iter->GetStartTime ();
1101 for (std::list<OfdmUlMapIe>::iterator iter = ulMapElements.begin (); iter != ulMapElements.end (); ++iter)
1129 "SS: Error while processing UL MAP: SS state should be SS_STATE_WAITING_INV_RANG_INTRVL");
1203 for (std::vector<OfdmDlBurstProfile>::iterator iter = dlBurstProfiles.begin (); iter != dlBurstProfiles.end (); ++iter)
1238 for (std::vector<OfdmUlBurstProfile>::iterator iter = ulBurstProfiles.begin (); iter != ulBurstProfiles.end (); ++iter)
1265 - timeAlreadyElapsed;
1266 return timeToUlSubframe + defferTime;