A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
mac-tx-middle.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005, 2009 INRIA
4
* Copyright (c) 2009 MIRKO BANCHI
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20
* Mirko Banchi <mk.banchi@gmail.com>
21
* Ghada Badawy <gbadawy@gmail.com>
22
*/
23
24
#include "ns3/assert.h"
25
#include "
mac-tx-middle.h
"
26
#include "
wifi-mac-header.h
"
27
28
namespace
ns3
{
29
30
MacTxMiddle::MacTxMiddle
()
31
: m_sequence (0)
32
{
33
}
34
35
MacTxMiddle::~MacTxMiddle
()
36
{
37
for
(std::map<Mac48Address,uint16_t*>::iterator i =
m_qosSequences
.begin (); i !=
m_qosSequences
.end (); i++)
38
{
39
delete
[] i->second;
40
}
41
}
42
43
uint16_t
44
MacTxMiddle::GetNextSequenceNumberfor
(
const
WifiMacHeader
*hdr)
45
{
46
uint16_t retval;
47
if
(hdr->
IsQosData
()
48
&& !hdr->
GetAddr1
().
IsGroup
())
49
{
50
uint8_t tid = hdr->
GetQosTid
();
51
NS_ASSERT
(tid < 16);
52
std::map<Mac48Address, uint16_t*>::iterator it =
m_qosSequences
.find (hdr->
GetAddr1
());
53
if
(it !=
m_qosSequences
.end ())
54
{
55
retval = it->second[tid];
56
it->second[tid]++;
57
it->second[tid] %= 4096;
58
}
59
else
60
{
61
retval = 0;
62
std::pair <Mac48Address,uint16_t*> newSeq (hdr->
GetAddr1
(),
new
uint16_t[16]);
63
std::pair <std::map<Mac48Address,uint16_t*>::iterator,
bool
> newIns =
m_qosSequences
.insert (newSeq);
64
NS_ASSERT
(newIns.second ==
true
);
65
for
(uint8_t i = 0; i < 16; i++)
66
{
67
newIns.first->second[i] = 0;
68
}
69
newIns.first->second[tid]++;
70
}
71
}
72
else
73
{
74
retval =
m_sequence
;
75
m_sequence
++;
76
m_sequence
%= 4096;
77
}
78
return
retval;
79
}
80
81
uint16_t
82
MacTxMiddle::PeekNextSequenceNumberfor
(
const
WifiMacHeader
*hdr)
83
{
84
uint16_t retval;
85
if
(hdr->
IsQosData
()
86
&& !hdr->
GetAddr1
().
IsGroup
())
87
{
88
uint8_t tid = hdr->
GetQosTid
();
89
NS_ASSERT
(tid < 16);
90
std::map<Mac48Address, uint16_t*>::iterator it =
m_qosSequences
.find (hdr->
GetAddr1
());
91
if
(it !=
m_qosSequences
.end ())
92
{
93
retval = it->second[tid];
94
}
95
else
96
{
97
retval = 0;
98
}
99
}
100
else
101
{
102
retval =
m_sequence
;
103
}
104
return
retval;
105
}
106
107
uint16_t
108
MacTxMiddle::GetNextSeqNumberByTidAndAddress
(uint8_t tid,
Mac48Address
addr)
const
109
{
110
NS_ASSERT
(tid < 16);
111
uint16_t seq = 0;
112
std::map <Mac48Address,uint16_t*>::const_iterator it =
m_qosSequences
.find (addr);
113
if
(it !=
m_qosSequences
.end ())
114
{
115
return
it->second[tid];
116
}
117
return
seq;
118
}
119
120
}
//namespace ns3
ns3::MacTxMiddle::m_sequence
uint16_t m_sequence
Definition:
mac-tx-middle.h:72
ns3::MacTxMiddle::~MacTxMiddle
~MacTxMiddle()
Definition:
mac-tx-middle.cc:35
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:67
ns3::MacTxMiddle::MacTxMiddle
MacTxMiddle()
Definition:
mac-tx-middle.cc:30
mac-tx-middle.h
ns3::WifiMacHeader::GetQosTid
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
Definition:
wifi-mac-header.cc:853
wifi-mac-header.h
ns3::MacTxMiddle::GetNextSequenceNumberfor
uint16_t GetNextSequenceNumberfor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition:
mac-tx-middle.cc:44
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Mac48Address::IsGroup
bool IsGroup(void) const
Definition:
mac48-address.cc:164
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:82
ns3::MacTxMiddle::m_qosSequences
std::map< Mac48Address, uint16_t * > m_qosSequences
Definition:
mac-tx-middle.h:71
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:43
ns3::WifiMacHeader::IsQosData
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
Definition:
wifi-mac-header.cc:635
ns3::WifiMacHeader::GetAddr1
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Definition:
wifi-mac-header.cc:467
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:108
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition:
wifi-mac-header.h:81
src
wifi
model
mac-tx-middle.cc
Generated on Mon Oct 3 2016 23:04:47 for ns-3 by
1.8.9.1