LEFT | RIGHT |
(no file at all) | |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2015 Natale Patriciello <natale.patriciello@gmail.com> | 3 * Copyright (c) 2015 Natale Patriciello <natale.patriciello@gmail.com> |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ns3/node.h" | 22 #include "ns3/node.h" |
23 #include "ns3/log.h" | 23 #include "ns3/log.h" |
24 #include "ns3/tcp-westwood.h" | 24 #include "ns3/tcp-westwood.h" |
25 | 25 |
26 namespace ns3 { | 26 namespace ns3 { |
27 | 27 |
28 NS_LOG_COMPONENT_DEFINE ("TcpRtoTest"); | 28 NS_LOG_COMPONENT_DEFINE ("TcpRtoTest"); |
29 | 29 |
30 TcpRtoTest::TcpRtoTest (TypeId &congControl, const std::string &desc) | 30 TcpRtoTest::TcpRtoTest (TypeId &congControl, const std::string &desc) |
31 : TcpGeneralTest (desc), | 31 : TcpGeneralTest (desc), |
32 m_rtoExpired (false), | 32 m_afterRTOExpired (false), |
33 m_segmentReceived (false) | 33 m_segmentReceived (false) |
34 { | 34 { |
35 m_congControlTypeId = congControl; | 35 m_congControlTypeId = congControl; |
36 } | 36 } |
37 | 37 |
38 void | 38 void |
39 TcpRtoTest::ConfigureEnvironment () | 39 TcpRtoTest::ConfigureEnvironment () |
40 { | 40 { |
41 TcpGeneralTest::ConfigureEnvironment (); | 41 TcpGeneralTest::ConfigureEnvironment (); |
42 SetAppPktCount (100); | 42 SetAppPktCount (100); |
(...skipping 11 matching lines...) Expand all Loading... |
54 { | 54 { |
55 // Get a really low RTO, and let them fire as soon as possible since | 55 // Get a really low RTO, and let them fire as soon as possible since |
56 // we are interested only in what happen after it expires | 56 // we are interested only in what happen after it expires |
57 Ptr<TcpSocketMsgBase> socket = TcpGeneralTest::CreateSenderSocket (node); | 57 Ptr<TcpSocketMsgBase> socket = TcpGeneralTest::CreateSenderSocket (node); |
58 socket->SetAttribute ("MinRto", TimeValue (Seconds (0.5))); | 58 socket->SetAttribute ("MinRto", TimeValue (Seconds (0.5))); |
59 | 59 |
60 return socket; | 60 return socket; |
61 } | 61 } |
62 | 62 |
63 void | 63 void |
64 TcpRtoTest::RTOExpired (const Ptr<const TcpSocketState> tcb, SocketWho who) | 64 TcpRtoTest::AfterRTOExpired (const Ptr<const TcpSocketState> tcb, SocketWho who) |
65 { | 65 { |
66 // In this test, the RTO fires for the first segment (and no more). | 66 // In this test, the RTO fires for the first segment (and no more). |
67 // This function is called after the management of the RTO expiration, | 67 // This function is called after the management of the RTO expiration, |
68 // and because of this we must check all the involved variables. | 68 // and because of this we must check all the involved variables. |
69 NS_TEST_ASSERT_MSG_EQ (m_rtoExpired, false, | 69 NS_TEST_ASSERT_MSG_EQ (m_afterRTOExpired, false, |
70 "Second RTO expired"); | 70 "Second RTO expired"); |
71 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_LOSS, | 71 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_LOSS, |
72 "Ack state machine not in LOSS state after a loss"); | 72 "Ack state machine not in LOSS state after a loss"); |
73 | 73 |
74 m_rtoExpired = true; | 74 m_afterRTOExpired = true; |
75 } | 75 } |
76 | 76 |
77 void | 77 void |
78 TcpRtoTest::RcvAck (const Ptr<const TcpSocketState> tcb, const TcpHeader& h, | 78 TcpRtoTest::RcvAck (const Ptr<const TcpSocketState> tcb, const TcpHeader& h, |
79 SocketWho who) | 79 SocketWho who) |
80 { | 80 { |
81 // Called after the first ack is received (the lost segment has been | 81 // Called after the first ack is received (the lost segment has been |
82 // successfully retransmitted. We must check on the sender that variables | 82 // successfully retransmitted. We must check on the sender that variables |
83 // are in the same state as they where after RTOExpired if it is the first | 83 // are in the same state as they where after AfterRTOExpired if it is the firs
t |
84 // ACK after the loss; in every other case, all must be OPEN and the counter | 84 // ACK after the loss; in every other case, all must be OPEN and the counter |
85 // set to 0. | 85 // set to 0. |
86 | 86 |
87 if (m_rtoExpired && who == SENDER) | 87 if (m_afterRTOExpired && who == SENDER) |
88 { | 88 { |
89 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_LOSS, | 89 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_LOSS, |
90 "Ack state machine not in LOSS state after a loss")
; | 90 "Ack state machine not in LOSS state after a loss")
; |
91 } | 91 } |
92 else | 92 else |
93 { | 93 { |
94 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_OPEN, | 94 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_OPEN, |
95 "Ack state machine not in OPEN state after recoveri
ng " | 95 "Ack state machine not in OPEN state after recoveri
ng " |
96 "from loss"); | 96 "from loss"); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 void | 100 void |
101 TcpRtoTest::ProcessedAck (const Ptr<const TcpSocketState> tcb, const TcpHeader &
h, | 101 TcpRtoTest::ProcessedAck (const Ptr<const TcpSocketState> tcb, const TcpHeader &
h, |
102 SocketWho who) | 102 SocketWho who) |
103 { | 103 { |
104 // Called after the ACK processing. Every time we should be in OPEN state, | 104 // Called after the ACK processing. Every time we should be in OPEN state, |
105 // without any packet lost or marked as retransmitted, in both the sockets | 105 // without any packet lost or marked as retransmitted, in both the sockets |
106 | 106 |
107 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_OPEN, | 107 NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_OPEN, |
108 "Ack state machine not in OPEN state after recovering " | 108 "Ack state machine not in OPEN state after recovering " |
109 "from loss"); | 109 "from loss"); |
110 | 110 |
111 if (who == SENDER) | 111 if (who == SENDER) |
112 { | 112 { |
113 m_rtoExpired = false; | 113 m_afterRTOExpired = false; |
114 m_segmentReceived = true; | 114 m_segmentReceived = true; |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 void | 118 void |
119 TcpRtoTest::FinalChecks () | 119 TcpRtoTest::FinalChecks () |
120 { | 120 { |
121 // At least one time we should process an ACK; otherwise, the segment | 121 // At least one time we should process an ACK; otherwise, the segment |
122 // has not been retransmitted, and this is bad | 122 // has not been retransmitted, and this is bad |
123 | 123 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 void | 240 void |
241 TcpTimeRtoTest::ErrorClose (SocketWho who) | 241 TcpTimeRtoTest::ErrorClose (SocketWho who) |
242 { | 242 { |
243 m_closed = true; | 243 m_closed = true; |
244 } | 244 } |
245 | 245 |
246 void | 246 void |
247 TcpTimeRtoTest::RTOExpired (const Ptr<const TcpSocketState> tcb, SocketWho who) | 247 TcpTimeRtoTest::AfterRTOExpired (const Ptr<const TcpSocketState> tcb, SocketWho
who) |
248 { | 248 { |
249 NS_TEST_ASSERT_MSG_EQ (who, SENDER, "RTO in Receiver. That's unexpected"); | 249 NS_TEST_ASSERT_MSG_EQ (who, SENDER, "RTO in Receiver. That's unexpected"); |
250 | 250 |
251 Time actualRto = GetRto (SENDER); | 251 Time actualRto = GetRto (SENDER); |
252 | 252 |
253 if (actualRto < Seconds (60)) | 253 if (actualRto < Seconds (60)) |
254 { | 254 { |
255 NS_TEST_ASSERT_MSG_EQ_TOL (actualRto, m_previousRTO+m_previousRTO, Seconds
(0.01), | 255 NS_TEST_ASSERT_MSG_EQ_TOL (actualRto, m_previousRTO+m_previousRTO, Seconds
(0.01), |
256 "RTO has not doubled after an expiration"); | 256 "RTO has not doubled after an expiration"); |
257 m_previousRTO += m_previousRTO; | 257 m_previousRTO += m_previousRTO; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 for (std::list<TypeId>::iterator it = types.begin (); it != types.end (); ++
it) | 291 for (std::list<TypeId>::iterator it = types.begin (); it != types.end (); ++
it) |
292 { | 292 { |
293 AddTestCase (new TcpRtoTest ((*it), "RTO retransmit testing"), TestCase:
:QUICK); | 293 AddTestCase (new TcpRtoTest ((*it), "RTO retransmit testing"), TestCase:
:QUICK); |
294 AddTestCase (new TcpTimeRtoTest ((*it), "RTO timing testing"), TestCase:
:QUICK); | 294 AddTestCase (new TcpTimeRtoTest ((*it), "RTO timing testing"), TestCase:
:QUICK); |
295 } | 295 } |
296 } | 296 } |
297 } g_TcpRtoTestSuite; | 297 } g_TcpRtoTestSuite; |
298 | 298 |
299 } // namespace ns3 | 299 } // namespace ns3 |
LEFT | RIGHT |