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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
*/
22
23
#include "ns3/assert.h"
24
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::GetNextSeqNumberByTidAndAddress
(uint8_t tid,
Mac48Address
addr)
const
83
{
84
NS_ASSERT
(tid < 16);
85
uint16_t seq = 0;
86
std::map <Mac48Address,uint16_t*>::const_iterator it =
m_qosSequences
.find (addr);
87
if
(it !=
m_qosSequences
.end ())
88
{
89
return
it->second[tid];
90
}
91
return
seq;
92
}
93
94
}
// namespace ns3
ns3::MacTxMiddle::m_sequence
uint16_t m_sequence
Definition:
mac-tx-middle.h:63
ns3::MacTxMiddle::~MacTxMiddle
~MacTxMiddle()
Definition:
mac-tx-middle.cc:35
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
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:768
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::Mac48Address::IsGroup
bool IsGroup(void) const
Definition:
mac48-address.cc:159
ns3::MacTxMiddle::m_qosSequences
std::map< Mac48Address, uint16_t * > m_qosSequences
Definition:
mac-tx-middle.h:62
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:41
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:581
ns3::WifiMacHeader::GetAddr1
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Definition:
wifi-mac-header.cc:417
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:82
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition:
wifi-mac-header.h:80
src
wifi
model
mac-tx-middle.cc
Generated on Sat Apr 19 2014 14:07:11 for ns-3 by
1.8.6