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
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20
* Author: Mirko Banchi <mk.banchi@gmail.com>
21
* Author: Ghada Badawy <gbadawy@gmail.com>
22
*/
23
24
#include "ns3/assert.h"
25
26
#include "
mac-tx-middle.h
"
27
#include "
wifi-mac-header.h
"
28
29
namespace
ns3
{
30
31
MacTxMiddle::MacTxMiddle
()
32
: m_sequence (0)
33
{
34
}
35
36
MacTxMiddle::~MacTxMiddle
()
37
{
38
for
(std::map<Mac48Address,uint16_t*>::iterator i =
m_qosSequences
.begin (); i !=
m_qosSequences
.end (); i++)
39
{
40
delete
[] i->second;
41
}
42
}
43
44
uint16_t
45
MacTxMiddle::GetNextSequenceNumberfor
(
const
WifiMacHeader
*hdr)
46
{
47
uint16_t retval;
48
if
(hdr->
IsQosData
()
49
&& !hdr->
GetAddr1
().
IsGroup
())
50
{
51
uint8_t tid = hdr->
GetQosTid
();
52
NS_ASSERT
(tid < 16);
53
std::map<Mac48Address, uint16_t*>::iterator it =
m_qosSequences
.find (hdr->
GetAddr1
());
54
if
(it !=
m_qosSequences
.end ())
55
{
56
retval = it->second[tid];
57
it->second[tid]++;
58
it->second[tid] %= 4096;
59
}
60
else
61
{
62
retval = 0;
63
std::pair <Mac48Address,uint16_t*> newSeq (hdr->
GetAddr1
(),
new
uint16_t[16]);
64
std::pair <std::map<Mac48Address,uint16_t*>::iterator,
bool
> newIns =
m_qosSequences
.insert (newSeq);
65
NS_ASSERT
(newIns.second ==
true
);
66
for
(uint8_t i = 0; i < 16; i++)
67
{
68
newIns.first->second[i] = 0;
69
}
70
newIns.first->second[tid]++;
71
}
72
}
73
else
74
{
75
retval =
m_sequence
;
76
m_sequence
++;
77
m_sequence
%= 4096;
78
}
79
return
retval;
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:71
ns3::MacTxMiddle::~MacTxMiddle
~MacTxMiddle()
Definition:
mac-tx-middle.cc:36
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:31
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:767
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:45
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:70
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:580
ns3::WifiMacHeader::GetAddr1
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Definition:
wifi-mac-header.cc:416
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:80
src
wifi
model
mac-tx-middle.cc
Generated on Wed May 13 2015 14:59:35 for ns-3 by
1.8.9.1