A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac-tx-middle.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005, 2009 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
8 * Mirko Banchi <mk.banchi@gmail.com>
9 * Ghada Badawy <gbadawy@gmail.com>
10 */
11
12#include "mac-tx-middle.h"
13
14#include "wifi-mac-header.h"
15
16#include "ns3/log.h"
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("MacTxMiddle");
22
24 : m_sequence(0)
25{
26 NS_LOG_FUNCTION(this);
27}
28
30{
31 NS_LOG_FUNCTION(this);
32 for (auto i = m_qosSequences.begin(); i != m_qosSequences.end(); i++)
33 {
34 delete[] i->second;
35 }
36}
37
38uint16_t
40{
41 NS_LOG_FUNCTION(this);
42 uint16_t retval;
43 if (hdr->IsQosData() && !hdr->GetAddr1().IsBroadcast())
44 {
45 uint8_t tid = hdr->GetQosTid();
46 NS_ASSERT(tid < 16);
47 auto it = m_qosSequences.find(hdr->GetAddr1());
48 if (it != m_qosSequences.end())
49 {
50 retval = it->second[tid];
51 it->second[tid]++;
52 it->second[tid] %= 4096;
53 }
54 else
55 {
56 retval = 0;
57 std::pair<Mac48Address, uint16_t*> newSeq(hdr->GetAddr1(), new uint16_t[16]);
58 auto newIns = m_qosSequences.insert(newSeq);
59 NS_ASSERT(newIns.second == true);
60 for (uint8_t i = 0; i < 16; i++)
61 {
62 newIns.first->second[i] = 0;
63 }
64 newIns.first->second[tid]++;
65 }
66 }
67 else
68 {
70 m_sequence++;
71 m_sequence %= 4096;
72 }
73 return retval;
74}
75
76uint16_t
78{
79 NS_LOG_FUNCTION(this);
80 uint16_t retval;
81 if (hdr->IsQosData() && !hdr->GetAddr1().IsBroadcast())
82 {
83 uint8_t tid = hdr->GetQosTid();
84 NS_ASSERT(tid < 16);
85 auto it = m_qosSequences.find(hdr->GetAddr1());
86 if (it != m_qosSequences.end())
87 {
88 retval = it->second[tid];
89 }
90 else
91 {
92 retval = 0;
93 }
94 }
95 else
96 {
98 }
99 return retval;
100}
101
102uint16_t
104{
105 NS_LOG_FUNCTION(this);
106 NS_ASSERT(tid < 16);
107 uint16_t seq = 0;
108 auto it = m_qosSequences.find(addr);
109 if (it != m_qosSequences.end())
110 {
111 return it->second[tid];
112 }
113 return seq;
114}
115
116void
118{
119 NS_LOG_FUNCTION(this << *hdr);
120
121 if (hdr->IsQosData() && !hdr->GetAddr1().IsBroadcast())
122 {
123 uint8_t tid = hdr->GetQosTid();
124 NS_ASSERT(tid < 16);
125 auto it = m_qosSequences.find(hdr->GetAddr1());
126 NS_ASSERT(it != m_qosSequences.end());
127 it->second[tid] = hdr->GetSequenceNumber();
128 }
129 else
130 {
131 m_sequence = hdr->GetSequenceNumber();
132 }
133}
134
135} // namespace ns3
an EUI-48 address
void SetSequenceNumberFor(const WifiMacHeader *hdr)
Set the sequence number of the given MAC header as the next sequence number for the Traffic ID and de...
std::map< Mac48Address, uint16_t * > m_qosSequences
QOS sequences.
uint16_t m_sequence
current sequence number
uint16_t GetNextSeqNumberByTidAndAddress(uint8_t tid, Mac48Address addr) const
Return the next sequence number for the Traffic ID and destination.
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
uint16_t PeekNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i....
Implements the IEEE 802.11 MAC header.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.