|
|
| 115 |
void |
115 |
void |
| 116 |
Ns3TcpLossTestCase::DoSetup (void) |
116 |
Ns3TcpLossTestCase::DoSetup (void) |
| 117 |
{ |
117 |
{ |
|
|
118 |
Simulator::Destroy(); |
| 119 |
|
| 120 |
// Enable packet metadata |
| 121 |
Packet::EnablePrinting (); |
| 122 |
|
| 118 |
// |
123 |
// |
| 119 |
// We expect there to be a file called ns3tcp-state-response-vectors.pcap in |
124 |
// We expect there to be a file called ns3tcp-state-response-vectors.pcap in |
| 120 |
// response-vectors/ of this directory |
125 |
// response-vectors/ of this directory |
|
|
| 133 |
m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary); |
138 |
m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary); |
| 134 |
NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory"); |
139 |
NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory"); |
| 135 |
} |
140 |
} |
|
|
141 |
|
| 142 |
// Config |
| 143 |
std::ostringstream tcpModel; |
| 144 |
tcpModel << "ns3::Tcp" << m_tcpModel; |
| 145 |
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel.str ())); |
| 146 |
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000)); |
| 147 |
Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1)); |
| 148 |
|
| 149 |
// Logging |
| 150 |
if (m_writeLogging) |
| 151 |
{ |
| 152 |
LogComponentEnableAll (LOG_PREFIX_FUNC); |
| 153 |
LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL); |
| 154 |
LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG); |
| 155 |
LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL); |
| 156 |
LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO); |
| 157 |
LogComponentEnable ("TcpReno", LOG_LEVEL_INFO); |
| 158 |
LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO); |
| 159 |
LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO); |
| 160 |
} |
| 161 |
|
| 136 |
} |
162 |
} |
| 137 |
|
163 |
|
| 138 |
void |
164 |
void |
| 139 |
Ns3TcpLossTestCase::DoTeardown (void) |
165 |
Ns3TcpLossTestCase::DoTeardown (void) |
| 140 |
{ |
166 |
{ |
|
|
167 |
// Restore Logging |
| 168 |
if (m_writeLogging) |
| 169 |
{ |
| 170 |
LogComponentDisableAll (LOG_PREFIX_FUNC); |
| 171 |
LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL); |
| 172 |
LogComponentDisable ("ErrorModel", LOG_LEVEL_DEBUG); |
| 173 |
LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL); |
| 174 |
LogComponentDisable ("TcpNewReno", LOG_LEVEL_INFO); |
| 175 |
LogComponentDisable ("TcpReno", LOG_LEVEL_INFO); |
| 176 |
LogComponentDisable ("TcpTahoe", LOG_LEVEL_INFO); |
| 177 |
LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO); |
| 178 |
} |
| 179 |
|
| 141 |
m_pcapFile.Close (); |
180 |
m_pcapFile.Close (); |
|
|
181 |
|
| 182 |
// Enable packet metadata |
| 183 |
Packet::DisablePrinting (); |
| 184 |
|
| 185 |
TestCase::DoTeardown (); |
| 142 |
} |
186 |
} |
| 143 |
|
187 |
|
| 144 |
void |
188 |
void |
|
|
| 182 |
// file and see if it still does the right thing. |
226 |
// file and see if it still does the right thing. |
| 183 |
// |
227 |
// |
| 184 |
uint8_t expected[PCAP_SNAPLEN]; |
228 |
uint8_t expected[PCAP_SNAPLEN]; |
| 185 |
uint32_t tsSec, tsUsec, inclLen, origLen, readLen; |
229 |
uint32_t tsSec=0, tsUsec=0, inclLen=0, origLen=0, readLen=0; |
| 186 |
m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen); |
230 |
m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen); |
| 187 |
|
231 |
|
| 188 |
uint8_t *actual = new uint8_t[readLen]; |
232 |
if (readLen != 0 && origLen != 0) |
| 189 |
p->CopyData (actual, readLen); |
233 |
{ |
|
|
234 |
uint8_t *actual = new uint8_t[readLen]; |
| 235 |
p->CopyData (actual, readLen); |
| 190 |
|
236 |
|
| 191 |
uint32_t result = memcmp (actual, expected, readLen); |
237 |
uint32_t result = memcmp (actual, expected, readLen); |
| 192 |
|
238 |
|
| 193 |
delete [] actual; |
239 |
delete [] actual; |
| 194 |
|
240 |
|
| 195 |
// |
241 |
// |
| 196 |
// Avoid streams of errors -- only report the first. |
242 |
// Avoid streams of errors -- only report the first. |
| 197 |
// |
243 |
// |
| 198 |
if (GetErrorStatus () == false) |
244 |
if (GetErrorStatus () == false) |
|
|
245 |
{ |
| 246 |
NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error"); |
| 247 |
} |
| 248 |
} |
| 249 |
else if (GetErrorStatus () == false) |
| 199 |
{ |
250 |
{ |
| 200 |
NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error"); |
251 |
NS_TEST_EXPECT_MSG_GT (readLen, 0, "Unexpected packet error"); |
| 201 |
} |
252 |
} |
| 202 |
} |
253 |
} |
| 203 |
} |
254 |
} |
|
|
| 282 |
// Example corresponding to simulations in the paper "Simulation-based |
333 |
// Example corresponding to simulations in the paper "Simulation-based |
| 283 |
// Comparisons of Tahoe, Reno, and SACK TCP |
334 |
// Comparisons of Tahoe, Reno, and SACK TCP |
| 284 |
|
335 |
|
| 285 |
std::ostringstream tcpModel; |
|
|
| 286 |
tcpModel << "ns3::Tcp" << m_tcpModel; |
| 287 |
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", |
| 288 |
StringValue (tcpModel.str ())); |
| 289 |
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000)); |
| 290 |
Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1)); |
| 291 |
|
| 292 |
if (m_writeLogging) |
| 293 |
{ |
| 294 |
LogComponentEnableAll (LOG_PREFIX_FUNC); |
| 295 |
LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL); |
| 296 |
LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG); |
| 297 |
LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL); |
| 298 |
LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO); |
| 299 |
LogComponentEnable ("TcpReno", LOG_LEVEL_INFO); |
| 300 |
LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO); |
| 301 |
LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO); |
| 302 |
} |
| 303 |
|
| 304 |
//////////////////////////////////////////////////////// |
336 |
//////////////////////////////////////////////////////// |
| 305 |
// Topology construction |
337 |
// Topology construction |
| 306 |
// |
338 |
// |
|
|
| 359 |
ipInterfs.GetAddress (1), |
391 |
ipInterfs.GetAddress (1), |
| 360 |
servPort); |
392 |
servPort); |
| 361 |
|
393 |
|
| 362 |
Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx", |
|
|
| 363 |
MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this)); |
| 364 |
|
| 365 |
Config::ConnectWithoutContext |
| 366 |
("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", |
| 367 |
MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this)); |
| 368 |
|
| 369 |
//////////////////////////////////////////////////////// |
394 |
//////////////////////////////////////////////////////// |
| 370 |
// Set up loss model at node k1 |
395 |
// Set up loss model at node k1 |
| 371 |
// |
396 |
// |
|
|
| 403 |
pem->SetList (sampleList); |
428 |
pem->SetList (sampleList); |
| 404 |
dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem)); |
429 |
dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem)); |
| 405 |
|
430 |
|
|
|
431 |
Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx", |
| 432 |
MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this)); |
| 433 |
|
| 434 |
Config::ConnectWithoutContext |
| 435 |
("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", |
| 436 |
MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this)); |
| 437 |
|
| 406 |
// One can toggle the comment for the following line on or off to see the |
438 |
// One can toggle the comment for the following line on or off to see the |
| 407 |
// effects of finite send buffer modelling. One can also change the size of |
439 |
// effects of finite send buffer modelling. One can also change the size of |
| 408 |
// that buffer. |
440 |
// that buffer. |
|
|
| 442 |
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite () |
474 |
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite () |
| 443 |
: TestSuite ("ns3-tcp-loss", SYSTEM) |
475 |
: TestSuite ("ns3-tcp-loss", SYSTEM) |
| 444 |
{ |
476 |
{ |
| 445 |
Packet::EnablePrinting (); // Enable packet metadata for all test cases |
|
|
| 446 |
AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0)); |
477 |
AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0)); |
| 447 |
AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1)); |
478 |
AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1)); |
| 448 |
AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2)); |
479 |
AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2)); |