35 #define MY_DEBUG(x) \ |
35 #define MY_DEBUG(x) \ |
36 NS_LOG_DEBUG (m_mac->GetAddress () << " " << x) |
36 NS_LOG_DEBUG (m_mac->GetAddress () << " " << x) |
37 |
37 |
38 namespace ns3 { |
38 namespace ns3 { |
39 |
39 |
40 class SnrTag : public Tag |
40 class SnrTag : public Mtag |
41 { |
41 { |
42 public: |
42 public: |
43 SnrTag (); |
43 |
44 SnrTag (const SnrTag &o); |
44 static TypeId GetTypeId (void); |
45 ~SnrTag (); |
45 virtual TypeId GetInstanceTypeId (void) const; |
46 static uint32_t GetUid (void); |
46 |
47 void Print (std::ostream &os) const; |
47 virtual uint32_t GetSerializedSize (void) const; |
48 uint32_t GetSerializedSize (void) const; |
48 virtual void Serialize (MtagBuffer i) const; |
49 void Serialize (Buffer::Iterator i) const; |
49 virtual void Deserialize (MtagBuffer i); |
50 uint32_t Deserialize (Buffer::Iterator i); |
|
51 |
50 |
52 void Set (double snr); |
51 void Set (double snr); |
53 double Get (void) const; |
52 double Get (void) const; |
54 private: |
53 private: |
55 double m_snr; |
54 double m_snr; |
56 }; |
55 }; |
57 |
56 |
58 SnrTag::SnrTag () |
57 TypeId |
59 : m_snr (0.0) |
58 SnrTag::GetTypeId (void) |
60 {} |
59 { |
61 SnrTag::SnrTag (const SnrTag &o) |
60 static TypeId tid = TypeId ("ns3::SnrTag") |
62 : m_snr (o.m_snr) |
61 .SetParent<Mtag> () |
63 {} |
62 .AddConstructor<SnrTag> () |
64 SnrTag::~SnrTag () |
63 .AddAttribute ("Snr", "The snr of the last packet received", |
65 {} |
64 DoubleValue (0.0), |
66 uint32_t |
65 MakeDoubleAccessor (&SnrTag::Get), |
67 SnrTag::GetUid (void) |
66 MakeDoubleChecker<double> ()) |
68 { |
67 ; |
69 static uint32_t uid = AllocateUid<SnrTag> ("SnrTag.ns3.inria.fr"); |
68 return tid; |
70 return uid; |
69 } |
71 } |
70 TypeId |
72 void |
71 SnrTag::GetInstanceTypeId (void) const |
73 SnrTag::Print (std::ostream &os) const |
72 { |
74 { |
73 return GetTypeId (); |
75 os << "snr="<<m_snr; |
74 } |
76 } |
75 |
77 uint32_t |
76 uint32_t |
78 SnrTag::GetSerializedSize (void) const |
77 SnrTag::GetSerializedSize (void) const |
79 { |
78 { |
80 return 0; |
79 return sizeof (double); |
81 } |
80 } |
82 void |
81 void |
83 SnrTag::Serialize (Buffer::Iterator i) const |
82 SnrTag::Serialize (MtagBuffer i) const |
84 { |
83 { |
85 // would need to serialize double to platform-independent format. |
84 i.WriteDouble (m_snr); |
86 } |
85 } |
87 uint32_t |
86 void |
88 SnrTag::Deserialize (Buffer::Iterator i) |
87 SnrTag::Deserialize (MtagBuffer i) |
89 { |
88 { |
90 // would need to deserialize double from platform-independent format. |
89 m_snr = i.ReadDouble (); |
91 return 0; |
|
92 } |
90 } |
93 void |
91 void |
94 SnrTag::Set (double snr) |
92 SnrTag::Set (double snr) |
95 { |
93 { |
96 m_snr = snr; |
94 m_snr = snr; |
470 m_ctsTimeoutEvent.IsRunning () && |
468 m_ctsTimeoutEvent.IsRunning () && |
471 m_currentPacket != 0) |
469 m_currentPacket != 0) |
472 { |
470 { |
473 MY_DEBUG ("receive cts from="<<m_currentHdr.GetAddr1 ()); |
471 MY_DEBUG ("receive cts from="<<m_currentHdr.GetAddr1 ()); |
474 SnrTag tag; |
472 SnrTag tag; |
475 packet->PeekTag (tag); |
473 packet->FindFirstMatchingTag (tag); |
476 WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); |
474 WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); |
477 station->ReportRxOk (rxSnr, txMode); |
475 station->ReportRxOk (rxSnr, txMode); |
478 station->ReportRtsOk (rxSnr, txMode, tag.Get ()); |
476 station->ReportRtsOk (rxSnr, txMode, tag.Get ()); |
479 |
477 |
480 m_ctsTimeoutEvent.Cancel (); |
478 m_ctsTimeoutEvent.Cancel (); |
493 m_superFastAckTimeoutEvent.IsRunning ()) && |
491 m_superFastAckTimeoutEvent.IsRunning ()) && |
494 m_txParams.MustWaitAck ()) |
492 m_txParams.MustWaitAck ()) |
495 { |
493 { |
496 MY_DEBUG ("receive ack from="<<m_currentHdr.GetAddr1 ()); |
494 MY_DEBUG ("receive ack from="<<m_currentHdr.GetAddr1 ()); |
497 SnrTag tag; |
495 SnrTag tag; |
498 packet->PeekTag (tag); |
496 packet->FindFirstMatchingTag (tag); |
499 WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); |
497 WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ()); |
500 station->ReportRxOk (rxSnr, txMode); |
498 station->ReportRxOk (rxSnr, txMode); |
501 station->ReportDataOk (rxSnr, txMode, tag.Get ()); |
499 station->ReportDataOk (rxSnr, txMode, tag.Get ()); |
502 bool gotAck = false; |
500 bool gotAck = false; |
503 if (m_txParams.MustWaitNormalAck () && |
501 if (m_txParams.MustWaitNormalAck () && |