A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
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
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
* Mirko Banchi <mk.banchi@gmail.com>
20
* Ghada Badawy <gbadawy@gmail.com>
21
*/
22
23
#include "
mac-tx-middle.h
"
24
25
#include "
wifi-mac-header.h
"
26
27
#include "ns3/log.h"
28
29
namespace
ns3
30
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"MacTxMiddle"
);
33
34
MacTxMiddle::MacTxMiddle
()
35
: m_sequence(0)
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
40
MacTxMiddle::~MacTxMiddle
()
41
{
42
NS_LOG_FUNCTION
(
this
);
43
for
(
auto
i =
m_qosSequences
.begin(); i !=
m_qosSequences
.end(); i++)
44
{
45
delete
[] i->second;
46
}
47
}
48
49
uint16_t
50
MacTxMiddle::GetNextSequenceNumberFor
(
const
WifiMacHeader
* hdr)
51
{
52
NS_LOG_FUNCTION
(
this
);
53
uint16_t retval;
54
if
(hdr->
IsQosData
() && !hdr->
GetAddr1
().
IsGroup
())
55
{
56
uint8_t tid = hdr->
GetQosTid
();
57
NS_ASSERT
(tid < 16);
58
auto
it =
m_qosSequences
.find(hdr->
GetAddr1
());
59
if
(it !=
m_qosSequences
.end())
60
{
61
retval = it->second[tid];
62
it->second[tid]++;
63
it->second[tid] %= 4096;
64
}
65
else
66
{
67
retval = 0;
68
std::pair<Mac48Address, uint16_t*> newSeq(hdr->
GetAddr1
(),
new
uint16_t[16]);
69
auto
newIns =
m_qosSequences
.insert(newSeq);
70
NS_ASSERT
(newIns.second ==
true
);
71
for
(uint8_t i = 0; i < 16; i++)
72
{
73
newIns.first->second[i] = 0;
74
}
75
newIns.first->second[tid]++;
76
}
77
}
78
else
79
{
80
retval =
m_sequence
;
81
m_sequence
++;
82
m_sequence
%= 4096;
83
}
84
return
retval;
85
}
86
87
uint16_t
88
MacTxMiddle::PeekNextSequenceNumberFor
(
const
WifiMacHeader
* hdr)
89
{
90
NS_LOG_FUNCTION
(
this
);
91
uint16_t retval;
92
if
(hdr->
IsQosData
() && !hdr->
GetAddr1
().
IsGroup
())
93
{
94
uint8_t tid = hdr->
GetQosTid
();
95
NS_ASSERT
(tid < 16);
96
auto
it =
m_qosSequences
.find(hdr->
GetAddr1
());
97
if
(it !=
m_qosSequences
.end())
98
{
99
retval = it->second[tid];
100
}
101
else
102
{
103
retval = 0;
104
}
105
}
106
else
107
{
108
retval =
m_sequence
;
109
}
110
return
retval;
111
}
112
113
uint16_t
114
MacTxMiddle::GetNextSeqNumberByTidAndAddress
(uint8_t tid,
Mac48Address
addr)
const
115
{
116
NS_LOG_FUNCTION
(
this
);
117
NS_ASSERT
(tid < 16);
118
uint16_t seq = 0;
119
auto
it =
m_qosSequences
.find(addr);
120
if
(it !=
m_qosSequences
.end())
121
{
122
return
it->second[tid];
123
}
124
return
seq;
125
}
126
127
void
128
MacTxMiddle::SetSequenceNumberFor
(
const
WifiMacHeader
* hdr)
129
{
130
NS_LOG_FUNCTION
(
this
<< *hdr);
131
132
if
(hdr->
IsQosData
() && !hdr->
GetAddr1
().
IsGroup
())
133
{
134
uint8_t tid = hdr->
GetQosTid
();
135
NS_ASSERT
(tid < 16);
136
auto
it =
m_qosSequences
.find(hdr->
GetAddr1
());
137
NS_ASSERT
(it !=
m_qosSequences
.end());
138
it->second[tid] = hdr->
GetSequenceNumber
();
139
}
140
else
141
{
142
m_sequence
= hdr->
GetSequenceNumber
();
143
}
144
}
145
146
}
// namespace ns3
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:46
ns3::Mac48Address::IsGroup
bool IsGroup() const
Definition:
mac48-address.cc:148
ns3::MacTxMiddle::~MacTxMiddle
~MacTxMiddle()
Definition:
mac-tx-middle.cc:40
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:128
ns3::MacTxMiddle::m_qosSequences
std::map< Mac48Address, uint16_t * > m_qosSequences
QOS sequences.
Definition:
mac-tx-middle.h:79
ns3::MacTxMiddle::m_sequence
uint16_t m_sequence
current sequence number
Definition:
mac-tx-middle.h:80
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:114
ns3::MacTxMiddle::GetNextSequenceNumberFor
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition:
mac-tx-middle.cc:50
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:88
ns3::MacTxMiddle::MacTxMiddle
MacTxMiddle()
Definition:
mac-tx-middle.cc:34
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition:
wifi-mac-header.h:98
ns3::WifiMacHeader::GetQosTid
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
Definition:
wifi-mac-header.cc:925
ns3::WifiMacHeader::GetAddr1
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
Definition:
wifi-mac-header.cc:463
ns3::WifiMacHeader::GetSequenceNumber
uint16_t GetSequenceNumber() const
Return the sequence number of the header.
Definition:
wifi-mac-header.cc:828
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:605
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:66
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:240
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 Sun Mar 3 2024 17:11:11 for ns-3 by
1.9.1