19 */ |
19 */ |
20 |
20 |
21 #include "wifi-remote-station-manager.h" |
21 #include "wifi-remote-station-manager.h" |
22 #include "ns3/assert.h" |
22 #include "ns3/assert.h" |
23 #include "ns3/log.h" |
23 #include "ns3/log.h" |
24 #include "ns3/tag.h" |
24 #include "ns3/mtag.h" |
25 #include "ns3/boolean.h" |
25 #include "ns3/boolean.h" |
26 #include "ns3/uinteger.h" |
26 #include "ns3/uinteger.h" |
27 #include "ns3/wifi-phy.h" |
27 #include "ns3/wifi-phy.h" |
28 #include "ns3/trace-source-accessor.h" |
28 #include "ns3/trace-source-accessor.h" |
29 |
29 |
304 * Packet Mode Tagger |
304 * Packet Mode Tagger |
305 ***************************************************************/ |
305 ***************************************************************/ |
306 |
306 |
307 namespace ns3 { |
307 namespace ns3 { |
308 |
308 |
309 class TxModeTag : public Tag |
309 class TxModeTag : public Mtag |
310 { |
310 { |
311 public: |
311 public: |
312 TxModeTag (); |
312 TxModeTag (); |
313 TxModeTag (WifiMode rtsMode, WifiMode dataMode); |
313 TxModeTag (WifiMode rtsMode, WifiMode dataMode); |
314 WifiMode GetRtsMode (void) const; |
314 WifiMode GetRtsMode (void) const; |
315 WifiMode GetDataMode (void) const; |
315 WifiMode GetDataMode (void) const; |
316 |
316 |
317 static uint32_t GetUid (void); |
317 static TypeId GetTypeId (void); |
318 void Print (std::ostream &os) const; |
318 virtual TypeId GetInstanceTypeId (void) const; |
319 void Serialize (ns3::Buffer::Iterator start) const; |
319 virtual uint32_t GetSerializedSize (void) const; |
320 uint32_t Deserialize (ns3::Buffer::Iterator start); |
320 virtual void Serialize (MtagBuffer i) const; |
321 uint32_t GetSerializedSize (void) const; |
321 virtual void Deserialize (MtagBuffer i); |
322 private: |
322 private: |
323 WifiMode m_rtsMode; |
323 WifiMode m_rtsMode; |
324 WifiMode m_dataMode; |
324 WifiMode m_dataMode; |
325 }; |
325 }; |
326 |
326 |
338 WifiMode |
338 WifiMode |
339 TxModeTag::GetDataMode (void) const |
339 TxModeTag::GetDataMode (void) const |
340 { |
340 { |
341 return m_dataMode; |
341 return m_dataMode; |
342 } |
342 } |
343 |
343 TypeId |
344 uint32_t |
344 TxModeTag::GetTypeId (void) |
345 TxModeTag::GetUid (void) |
345 { |
346 { |
346 static TypeId tid = TypeId ("ns3::TxModeTag") |
347 static uint32_t uid = Tag::AllocateUid<TxModeTag> ("ns3.wifi.TxModeTag"); |
347 .SetParent<Mtag> () |
348 return uid; |
348 .AddConstructor<TxModeTag> () |
349 } |
349 .AddAttribute ("RtsTxMode", |
350 void |
350 "Tx mode of rts to use later", |
351 TxModeTag::Print (std::ostream &os) const |
351 EmptyAttributeValue (), |
352 { |
352 MakeWifiModeAccessor (&TxModeTag::GetRtsMode), |
353 os << "rts="<<m_rtsMode<<" data="<<m_dataMode; |
353 MakeWifiModeChecker ()) |
354 } |
354 .AddAttribute ("DataTxMode", |
355 void |
355 "Tx mode of data to use later", |
356 TxModeTag::Serialize (ns3::Buffer::Iterator start) const |
356 EmptyAttributeValue (), |
357 {} |
357 MakeWifiModeAccessor (&TxModeTag::GetDataMode), |
358 uint32_t |
358 MakeWifiModeChecker ()) |
359 TxModeTag::Deserialize (ns3::Buffer::Iterator start) |
359 ; |
360 { |
360 return tid; |
361 return 0; |
361 } |
|
362 TypeId |
|
363 TxModeTag::GetInstanceTypeId (void) const |
|
364 { |
|
365 return GetTypeId (); |
362 } |
366 } |
363 uint32_t |
367 uint32_t |
364 TxModeTag::GetSerializedSize (void) const |
368 TxModeTag::GetSerializedSize (void) const |
365 { |
369 { |
366 return 0; |
370 return sizeof (WifiMode) * 2; |
|
371 } |
|
372 void |
|
373 TxModeTag::Serialize (MtagBuffer i) const |
|
374 { |
|
375 i.Write ((uint8_t *)&m_rtsMode, sizeof (WifiMode)); |
|
376 i.Write ((uint8_t *)&m_dataMode, sizeof (WifiMode)); |
|
377 } |
|
378 void |
|
379 TxModeTag::Deserialize (MtagBuffer i) |
|
380 { |
|
381 i.Read ((uint8_t *)&m_rtsMode, sizeof (WifiMode)); |
|
382 i.Read ((uint8_t *)&m_dataMode, sizeof (WifiMode)); |
367 } |
383 } |
368 |
384 |
369 } // namespace ns3 |
385 } // namespace ns3 |
370 |
386 |
371 |
387 |
533 if (GetManager ()->IsLowLatency ()) |
549 if (GetManager ()->IsLowLatency ()) |
534 { |
550 { |
535 return; |
551 return; |
536 } |
552 } |
537 TxModeTag tag = TxModeTag (DoGetRtsMode (), DoGetDataMode (fullPacketSize)); |
553 TxModeTag tag = TxModeTag (DoGetRtsMode (), DoGetDataMode (fullPacketSize)); |
538 packet->AddTag (tag); |
554 packet->AddMtag (tag); |
539 } |
555 } |
540 WifiMode |
556 WifiMode |
541 WifiRemoteStation::GetDataMode (Ptr<const Packet> packet, uint32_t fullPacketSize) |
557 WifiRemoteStation::GetDataMode (Ptr<const Packet> packet, uint32_t fullPacketSize) |
542 { |
558 { |
543 if (GetManager ()->IsLowLatency ()) |
559 if (GetManager ()->IsLowLatency ()) |
544 { |
560 { |
545 return DoGetDataMode (fullPacketSize); |
561 return DoGetDataMode (fullPacketSize); |
546 } |
562 } |
547 TxModeTag tag; |
563 TxModeTag tag; |
548 bool found; |
564 bool found; |
549 found = packet->PeekTag (tag); |
565 found = packet->FindFirstMatchingTag (tag); |
550 NS_ASSERT (found); |
566 NS_ASSERT (found); |
551 return tag.GetDataMode (); |
567 return tag.GetDataMode (); |
552 } |
568 } |
553 WifiMode |
569 WifiMode |
554 WifiRemoteStation::GetRtsMode (Ptr<const Packet> packet) |
570 WifiRemoteStation::GetRtsMode (Ptr<const Packet> packet) |