A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"MacTxMiddle"
);
22
23
MacTxMiddle::MacTxMiddle
()
24
: m_sequence(0)
25
{
26
NS_LOG_FUNCTION
(
this
);
27
}
28
29
MacTxMiddle::~MacTxMiddle
()
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
38
uint16_t
39
MacTxMiddle::GetNextSequenceNumberFor
(
const
WifiMacHeader
* hdr)
40
{
41
NS_LOG_FUNCTION
(
this
);
42
uint16_t retval;
43
if
(hdr->
IsQosData
() && !hdr->
GetAddr1
().
IsGroup
())
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
{
69
retval =
m_sequence
;
70
m_sequence
++;
71
m_sequence
%= 4096;
72
}
73
return
retval;
74
}
75
76
uint16_t
77
MacTxMiddle::PeekNextSequenceNumberFor
(
const
WifiMacHeader
* hdr)
78
{
79
NS_LOG_FUNCTION
(
this
);
80
uint16_t retval;
81
if
(hdr->
IsQosData
() && !hdr->
GetAddr1
().
IsGroup
())
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
{
97
retval =
m_sequence
;
98
}
99
return
retval;
100
}
101
102
uint16_t
103
MacTxMiddle::GetNextSeqNumberByTidAndAddress
(uint8_t tid,
Mac48Address
addr)
const
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
116
void
117
MacTxMiddle::SetSequenceNumberFor
(
const
WifiMacHeader
* hdr)
118
{
119
NS_LOG_FUNCTION
(
this
<< *hdr);
120
121
if
(hdr->
IsQosData
() && !hdr->
GetAddr1
().
IsGroup
())
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
ns3::Mac48Address
an EUI-48 address
Definition
mac48-address.h:35
ns3::Mac48Address::IsGroup
bool IsGroup() const
Definition
mac48-address.cc:137
ns3::MacTxMiddle::~MacTxMiddle
~MacTxMiddle()
Definition
mac-tx-middle.cc:29
ns3::MacTxMiddle::SetSequenceNumberFor
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...
Definition
mac-tx-middle.cc:117
ns3::MacTxMiddle::m_qosSequences
std::map< Mac48Address, uint16_t * > m_qosSequences
QOS sequences.
Definition
mac-tx-middle.h:68
ns3::MacTxMiddle::m_sequence
uint16_t m_sequence
current sequence number
Definition
mac-tx-middle.h:69
ns3::MacTxMiddle::GetNextSeqNumberByTidAndAddress
uint16_t GetNextSeqNumberByTidAndAddress(uint8_t tid, Mac48Address addr) const
Return the next sequence number for the Traffic ID and destination.
Definition
mac-tx-middle.cc:103
ns3::MacTxMiddle::GetNextSequenceNumberFor
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition
mac-tx-middle.cc:39
ns3::MacTxMiddle::PeekNextSequenceNumberFor
uint16_t PeekNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i....
Definition
mac-tx-middle.cc:77
ns3::MacTxMiddle::MacTxMiddle
MacTxMiddle()
Definition
mac-tx-middle.cc:23
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition
wifi-mac-header.h:87
ns3::WifiMacHeader::GetQosTid
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
Definition
wifi-mac-header.cc:894
ns3::WifiMacHeader::GetAddr1
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
Definition
wifi-mac-header.cc:432
ns3::WifiMacHeader::GetSequenceNumber
uint16_t GetSequenceNumber() const
Return the sequence number of the header.
Definition
wifi-mac-header.cc:797
ns3::WifiMacHeader::IsQosData
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
Definition
wifi-mac-header.cc:574
NS_ASSERT
#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
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
mac-tx-middle.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
wifi-mac-header.h
src
wifi
model
mac-tx-middle.cc
Generated on Thu Dec 5 2024 18:20:54 for ns-3 by
1.11.0