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
src
wifi
model
mac-tx-middle.cc
Generated on Tue May 14 2013 11:08:35 for ns-3 by
1.8.1.2