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
qos-utils.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
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
* Author: Mirko Banchi <mk.banchi@gmail.com>
19
* Author: Cecchi Niccolò <insa@igeek.it>
20
*/
21
#include "
qos-utils.h
"
22
#include "
qos-tag.h
"
23
24
namespace
ns3 {
25
26
AcIndex
27
QosUtilsMapTidToAc
(uint8_t tid)
28
{
29
switch
(tid)
30
{
31
case
0:
32
return
AC_BE
;
33
break
;
34
case
1:
35
return
AC_BK
;
36
break
;
37
case
2:
38
return
AC_BK
;
39
break
;
40
case
3:
41
return
AC_BE
;
42
break
;
43
case
4:
44
return
AC_VI
;
45
break
;
46
case
5:
47
return
AC_VI
;
48
break
;
49
case
6:
50
return
AC_VO
;
51
break
;
52
case
7:
53
return
AC_VO
;
54
break
;
55
}
56
return
AC_UNDEF
;
57
}
58
59
uint8_t
60
QosUtilsGetTidForPacket
(
Ptr<const Packet>
packet)
61
{
62
QosTag
qos;
63
uint8_t tid = 8;
64
if
(packet->
PeekPacketTag
(qos))
65
{
66
if
(qos.
GetTid
() < 8)
67
{
68
tid = qos.
GetTid
();
69
}
70
}
71
return
tid;
72
}
73
74
uint32_t
75
QosUtilsMapSeqControlToUniqueInteger
(uint16_t seqControl, uint16_t endSequence)
76
{
77
uint32_t integer = 0;
78
uint16_t numberSeq = (seqControl >> 4) & 0x0fff;
79
integer = (4096 - (endSequence + 1) + numberSeq) % 4096;
80
integer *= 16;
81
integer += (seqControl & 0x000f);
82
return
integer;
83
}
84
85
bool
86
QosUtilsIsOldPacket
(uint16_t startingSeq, uint16_t seqNumber)
87
{
88
NS_ASSERT
(startingSeq < 4096);
89
NS_ASSERT
(seqNumber < 4096);
90
uint16_t distance = ((seqNumber - startingSeq) + 4096) % 4096;
91
return
(distance >= 2048);
92
}
93
94
}
// namespace ns3
qos-tag.h
ns3::Ptr< const Packet >
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::QosUtilsIsOldPacket
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet. ...
Definition:
qos-utils.cc:86
ns3::AC_VI
Video.
Definition:
qos-utils.h:42
ns3::AC_VO
Voice.
Definition:
qos-utils.h:44
ns3::AC_BE
Best Effort.
Definition:
qos-utils.h:38
qos-utils.h
ns3::QosUtilsGetTidForPacket
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
Definition:
qos-utils.cc:60
ns3::AC_BK
Background.
Definition:
qos-utils.h:40
ns3::Packet::PeekPacketTag
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition:
packet.cc:863
ns3::QosUtilsMapTidToAc
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition:
qos-utils.cc:27
ns3::QosTag
The aim of the QosTag is to provide means for an Application to specify the TID which will be used by...
Definition:
qos-tag.h:61
ns3::QosUtilsMapSeqControlToUniqueInteger
uint32_t QosUtilsMapSeqControlToUniqueInteger(uint16_t seqControl, uint16_t endSequence)
Next function is useful to correctly sort buffered packets under block ack.
Definition:
qos-utils.cc:75
ns3::QosTag::GetTid
uint8_t GetTid(void) const
Return the Type ID.
Definition:
qos-tag.cc:89
ns3::AcIndex
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition:
qos-utils.h:35
ns3::AC_UNDEF
Definition:
qos-utils.h:48
src
wifi
model
qos-utils.cc
Generated on Sat Apr 19 2014 14:07:11 for ns-3 by
1.8.6