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
tx-duration-test.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
#include <ns3/object.h>
22
#include <ns3/log.h>
23
#include <ns3/test.h>
24
#include <iostream>
25
#include "ns3/interference-helper.h"
26
#include "ns3/wifi-phy.h"
27
28
NS_LOG_COMPONENT_DEFINE
(
"InterferenceHelperTxDurationTest"
);
29
30
namespace
ns3 {
31
32
class
TxDurationTest
:
public
TestCase
33
{
34
public
:
35
TxDurationTest
();
36
virtual
~TxDurationTest
();
37
virtual
void
DoRun
(
void
);
38
39
private
:
50
bool
CheckPayloadDuration
(uint32_t size,
WifiMode
payloadMode, uint32_t knownDurationMicroSeconds);
51
63
bool
CheckTxDuration
(uint32_t size,
WifiMode
payloadMode,
WifiPreamble
preamble,
double
knownDurationMicroSeconds);
64
65
};
66
67
68
TxDurationTest::TxDurationTest
()
69
:
TestCase
(
"Wifi TX Duration"
)
70
{
71
}
72
73
74
TxDurationTest::~TxDurationTest
()
75
{
76
}
77
78
bool
79
TxDurationTest::CheckPayloadDuration
(uint32_t size,
WifiMode
payloadMode, uint32_t knownDurationMicroSeconds)
80
{
81
WifiTxVector
txVector;
82
txVector.
SetMode
(payloadMode);
83
uint32_t calculatedDurationMicroSeconds =
WifiPhy::GetPayloadDurationMicroSeconds
(size, txVector);
84
if
(calculatedDurationMicroSeconds != knownDurationMicroSeconds)
85
{
86
std::cerr <<
" size="
<< size
87
<<
" mode="
<< payloadMode
88
<<
" known="
<< knownDurationMicroSeconds
89
<<
" calculated="
<< calculatedDurationMicroSeconds
90
<< std::endl;
91
return
false
;
92
}
93
return
true
;
94
}
95
96
bool
97
TxDurationTest::CheckTxDuration
(uint32_t size,
WifiMode
payloadMode,
WifiPreamble
preamble,
double
knownDurationMicroSeconds)
98
{
99
WifiTxVector
txVector;
100
txVector.
SetMode
(payloadMode);
101
txVector.
SetNss
(1);
102
txVector.
SetStbc
(0);
103
txVector.
SetNess
(0);
104
double
calculatedDurationMicroSeconds =
WifiPhy::CalculateTxDuration
(size, txVector, preamble).
GetMicroSeconds
();
105
if
(calculatedDurationMicroSeconds != knownDurationMicroSeconds)
106
{
107
std::cerr <<
" size="
<< size
108
<<
" mode="
<< payloadMode
109
<<
" preamble="
<< preamble
110
<<
" known="
<< knownDurationMicroSeconds
111
<<
" calculated="
<< calculatedDurationMicroSeconds
112
<< std::endl;
113
return
false
;
114
}
115
return
true
;
116
}
117
118
void
119
TxDurationTest::DoRun
(
void
)
120
{
121
bool
retval =
true
;
122
123
124
// IEEE Std 802.11-2007 Table 18-2 "Example of LENGTH calculations for CCK"
125
retval = retval
126
&&
CheckPayloadDuration
(1023,
WifiPhy::GetDsssRate11Mbps
(), 744)
127
&&
CheckPayloadDuration
(1024,
WifiPhy::GetDsssRate11Mbps
(), 745)
128
&&
CheckPayloadDuration
(1025,
WifiPhy::GetDsssRate11Mbps
(), 746)
129
&&
CheckPayloadDuration
(1026,
WifiPhy::GetDsssRate11Mbps
(), 747);
130
131
132
// Similar, but we add PLCP preamble and header durations
133
// and we test different rates.
134
// The payload durations for modes other than 11mbb have been
135
// calculated by hand according to IEEE Std 802.11-2007 18.2.3.5
136
retval = retval
137
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_SHORT
, 744 + 96)
138
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_SHORT
, 745 + 96)
139
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_SHORT
, 746 + 96)
140
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_SHORT
, 747 + 96)
141
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_LONG
, 744 + 192)
142
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_LONG
, 745 + 192)
143
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_LONG
, 746 + 192)
144
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_LONG
, 747 + 192)
145
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_SHORT
, 1488 + 96)
146
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_SHORT
, 1490 + 96)
147
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_SHORT
, 1491 + 96)
148
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_SHORT
, 1493 + 96)
149
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_LONG
, 1488 + 192)
150
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_LONG
, 1490 + 192)
151
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_LONG
, 1491 + 192)
152
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate5_5Mbps
(),
WIFI_PREAMBLE_LONG
, 1493 + 192)
153
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_SHORT
, 4092 + 96)
154
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_SHORT
, 4096 + 96)
155
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_SHORT
, 4100 + 96)
156
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_SHORT
, 4104 + 96)
157
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_LONG
, 4092 + 192)
158
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_LONG
, 4096 + 192)
159
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_LONG
, 4100 + 192)
160
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate2Mbps
(),
WIFI_PREAMBLE_LONG
, 4104 + 192)
161
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_SHORT
, 8184 + 96)
162
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_SHORT
, 8192 + 96)
163
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_SHORT
, 8200 + 96)
164
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_SHORT
, 8208 + 96)
165
&&
CheckTxDuration
(1023,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_LONG
, 8184 + 192)
166
&&
CheckTxDuration
(1024,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_LONG
, 8192 + 192)
167
&&
CheckTxDuration
(1025,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_LONG
, 8200 + 192)
168
&&
CheckTxDuration
(1026,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_LONG
, 8208 + 192);
169
170
// values from http://mailman.isi.edu/pipermail/ns-developers/2009-July/006226.html
171
retval = retval &&
CheckTxDuration
(14,
WifiPhy::GetDsssRate1Mbps
(),
WIFI_PREAMBLE_LONG
, 304);
172
173
// values from
174
// http://www.oreillynet.com/pub/a/wireless/2003/08/08/wireless_throughput.html
175
retval = retval
176
&&
CheckTxDuration
(1536,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_LONG
, 1310)
177
&&
CheckTxDuration
(76,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_LONG
, 248)
178
&&
CheckTxDuration
(14,
WifiPhy::GetDsssRate11Mbps
(),
WIFI_PREAMBLE_LONG
, 203)
179
&&
CheckTxDuration
(1536,
WifiPhy::GetOfdmRate54Mbps
(),
WIFI_PREAMBLE_LONG
, 248)
180
&&
CheckTxDuration
(76,
WifiPhy::GetOfdmRate54Mbps
(),
WIFI_PREAMBLE_LONG
, 32)
181
&&
CheckTxDuration
(14,
WifiPhy::GetOfdmRate54Mbps
(),
WIFI_PREAMBLE_LONG
, 24);
182
183
// 802.11g durations are same as 802.11a durations but with 6 us signal extension
184
retval = retval
185
&&
CheckTxDuration
(1536,
WifiPhy::GetErpOfdmRate54Mbps
(),
WIFI_PREAMBLE_LONG
, 254)
186
&&
CheckTxDuration
(76,
WifiPhy::GetErpOfdmRate54Mbps
(),
WIFI_PREAMBLE_LONG
, 38)
187
&&
CheckTxDuration
(14,
WifiPhy::GetErpOfdmRate54Mbps
(),
WIFI_PREAMBLE_LONG
, 30);
188
189
//802.11n durations
190
retval = retval
191
&&
CheckTxDuration
(1536,
WifiPhy::GetOfdmRate65MbpsBW20MHz
(),
WIFI_PREAMBLE_HT_MF
,228)
192
&&
CheckTxDuration
(76,
WifiPhy::GetOfdmRate65MbpsBW20MHz
(),
WIFI_PREAMBLE_HT_MF
,48)
193
&&
CheckTxDuration
(14,
WifiPhy::GetOfdmRate65MbpsBW20MHz
(),
WIFI_PREAMBLE_HT_MF
,40 )
194
//should be 218.8, 38,8 and 31.6 but microseconds are only represented as integers will have to change Time to change that
195
&&
CheckTxDuration
(1536,
WifiPhy::GetOfdmRate65MbpsBW20MHzShGi
(),
WIFI_PREAMBLE_HT_GF
,218)
196
&&
CheckTxDuration
(76,
WifiPhy::GetOfdmRate65MbpsBW20MHzShGi
(),
WIFI_PREAMBLE_HT_GF
,38)
197
&&
CheckTxDuration
(14,
WifiPhy::GetOfdmRate65MbpsBW20MHzShGi
(),
WIFI_PREAMBLE_HT_GF
,31);
198
}
199
200
class
TxDurationTestSuite
:
public
TestSuite
201
{
202
public
:
203
TxDurationTestSuite
();
204
};
205
206
TxDurationTestSuite::TxDurationTestSuite
()
207
:
TestSuite
(
"devices-wifi-tx-duration"
, UNIT)
208
{
209
AddTestCase
(
new
TxDurationTest
,
TestCase::QUICK
);
210
}
211
212
static
TxDurationTestSuite
g_txDurationTestSuite
;
213
}
// namespace ns3
214
ns3::WifiPhy::GetDsssRate11Mbps
static WifiMode GetDsssRate11Mbps()
Definition:
wifi-phy.cc:549
ns3::WifiTxVector
Definition:
wifi-tx-vector.h:47
ns3::WifiPhy::GetDsssRate1Mbps
static WifiMode GetDsssRate1Mbps()
Definition:
wifi-phy.cc:506
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1025
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::WifiPhy::GetOfdmRate54Mbps
static WifiMode GetOfdmRate54Mbps()
Definition:
wifi-phy.cc:765
ns3::TxDurationTest::TxDurationTest
TxDurationTest()
Definition:
tx-duration-test.cc:68
ns3::TxDurationTest::CheckTxDuration
bool CheckTxDuration(uint32_t size, WifiMode payloadMode, WifiPreamble preamble, double knownDurationMicroSeconds)
Definition:
tx-duration-test.cc:97
ns3::TestCase
encapsulates test code
Definition:
test.h:849
ns3::WifiMode
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition:
wifi-mode.h:91
ns3::WifiPhy::GetErpOfdmRate54Mbps
static WifiMode GetErpOfdmRate54Mbps()
Definition:
wifi-phy.cc:657
ns3::WifiPreamble
WifiPreamble
Definition:
wifi-preamble.h:29
ns3::WifiPhy::GetPayloadDurationMicroSeconds
static double GetPayloadDurationMicroSeconds(uint32_t size, WifiTxVector txvector)
Definition:
wifi-phy.cc:332
ns3::Time::GetMicroSeconds
int64_t GetMicroSeconds(void) const
Definition:
nstime.h:283
ns3::TxDurationTestSuite
Definition:
tx-duration-test.cc:200
ns3::WifiPhy::GetOfdmRate65MbpsBW20MHzShGi
static WifiMode GetOfdmRate65MbpsBW20MHzShGi()
Definition:
wifi-phy.cc:1159
ns3::WifiTxVector::SetNss
void SetNss(uint8_t nss)
Definition:
wifi-tx-vector.cc:98
ns3::WifiPhy::GetOfdmRate65MbpsBW20MHz
static WifiMode GetOfdmRate65MbpsBW20MHz()
Definition:
wifi-phy.cc:1172
ns3::WIFI_PREAMBLE_LONG
Definition:
wifi-preamble.h:31
ns3::WIFI_PREAMBLE_HT_GF
Definition:
wifi-preamble.h:34
ns3::WifiPhy::GetDsssRate5_5Mbps
static WifiMode GetDsssRate5_5Mbps()
Definition:
wifi-phy.cc:536
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition:
test.cc:172
ns3::WifiTxVector::SetMode
void SetMode(WifiMode mode)
Definition:
wifi-tx-vector.cc:78
ns3::TestCase::QUICK
Fast test.
Definition:
test.h:857
ns3::g_txDurationTestSuite
static TxDurationTestSuite g_txDurationTestSuite
Definition:
tx-duration-test.cc:212
ns3::TxDurationTest::CheckPayloadDuration
bool CheckPayloadDuration(uint32_t size, WifiMode payloadMode, uint32_t knownDurationMicroSeconds)
Definition:
tx-duration-test.cc:79
ns3::TxDurationTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
tx-duration-test.cc:119
ns3::WifiPhy::CalculateTxDuration
static Time CalculateTxDuration(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble)
Definition:
wifi-phy.cc:439
ns3::TxDurationTestSuite::TxDurationTestSuite
TxDurationTestSuite()
Definition:
tx-duration-test.cc:206
ns3::WifiTxVector::SetNess
void SetNess(uint8_t ness)
Definition:
wifi-tx-vector.cc:103
ns3::WifiTxVector::SetStbc
void SetStbc(bool stbcsatuts)
Definition:
wifi-tx-vector.cc:108
ns3::TxDurationTest
Definition:
tx-duration-test.cc:32
ns3::WifiPhy::GetDsssRate2Mbps
static WifiMode GetDsssRate2Mbps()
Definition:
wifi-phy.cc:519
ns3::TxDurationTest::~TxDurationTest
virtual ~TxDurationTest()
Definition:
tx-duration-test.cc:74
ns3::WIFI_PREAMBLE_SHORT
Definition:
wifi-preamble.h:32
ns3::WIFI_PREAMBLE_HT_MF
Definition:
wifi-preamble.h:33
src
wifi
test
tx-duration-test.cc
Generated on Sat Nov 16 2013 16:17:55 for ns-3 by
1.8.5