LEFT | RIGHT |
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 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
11 * | 11 * |
12 * You should have received a copy of the GNU General Public License | 12 * You should have received a copy of the GNU General Public License |
13 * along with this program; if not, write to the Free Software | 13 * along with this program; if not, write to the Free Software |
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 * | 15 * |
16 */ | 16 */ |
17 | 17 |
18 #include "ns3/test.h" | 18 #include "ns3/test.h" |
19 #include "ns3/tcp-tx-buffer.h" | 19 #include "ns3/tcp-tx-buffer.h" |
20 #include "ns3/packet.h" | 20 #include "ns3/packet.h" |
| 21 #include "ns3/simulator.h" |
21 #include "ns3/log.h" | 22 #include "ns3/log.h" |
22 | 23 |
23 using namespace ns3; | 24 using namespace ns3; |
24 | 25 |
25 NS_LOG_COMPONENT_DEFINE ("TcpTxBufferTestSuite"); | 26 NS_LOG_COMPONENT_DEFINE ("TcpTxBufferTestSuite"); |
26 | 27 |
27 class TcpTxBufferTestCase : public TestCase | 28 class TcpTxBufferTestCase : public TestCase |
28 { | 29 { |
29 public: | 30 public: |
30 TcpTxBufferTestCase (); | 31 TcpTxBufferTestCase (); |
(...skipping 15 matching lines...) Expand all Loading... |
46 | 47 |
47 void | 48 void |
48 TcpTxBufferTestCase::DoRun () | 49 TcpTxBufferTestCase::DoRun () |
49 { | 50 { |
50 /* | 51 /* |
51 * Cases for new block: | 52 * Cases for new block: |
52 * -> is exactly the same as stored | 53 * -> is exactly the same as stored |
53 * -> starts over the boundary, but ends earlier | 54 * -> starts over the boundary, but ends earlier |
54 * -> starts over the boundary, but ends after | 55 * -> starts over the boundary, but ends after |
55 */ | 56 */ |
56 TestNewBlock (); | 57 Simulator::Schedule (Seconds (0.0), &TcpTxBufferTestCase::TestNewBlock, this); |
57 | 58 |
58 /* | 59 /* |
59 * Cases for transmitted block: | 60 * Cases for transmitted block: |
60 * -> is exactly the same as previous | 61 * -> is exactly the same as previous |
61 * -> starts over the boundary, but ends earlier | 62 * -> starts over the boundary, but ends earlier |
62 * -> starts over the boundary, but ends after | 63 * -> starts over the boundary, but ends after |
63 * -> starts inside a packet, ends right | 64 * -> starts inside a packet, ends right |
64 * -> starts inside a packet, ends earlier in the same packet | 65 * -> starts inside a packet, ends earlier in the same packet |
65 * -> starts inside a packet, ends in another packet | 66 * -> starts inside a packet, ends in another packet |
66 */ | 67 */ |
67 TestTransmittedBlock (); | 68 Simulator::Schedule (Seconds (0.0), |
68 | 69 &TcpTxBufferTestCase::TestTransmittedBlock, this); |
69 TestUpdateScoreboardWithCraftedSACK (); | 70 |
70 | 71 Simulator::Schedule (Seconds (0.0), |
71 TestNextSeg (); | 72 &TcpTxBufferTestCase::TestUpdateScoreboardWithCraftedSACK
, this); |
| 73 |
| 74 Simulator::Schedule (Seconds (0.0), |
| 75 &TcpTxBufferTestCase::TestNextSeg, this); |
| 76 Simulator::Run (); |
| 77 Simulator::Destroy (); |
72 } | 78 } |
73 | 79 |
74 void | 80 void |
75 TcpTxBufferTestCase::TestNextSeg () | 81 TcpTxBufferTestCase::TestNextSeg () |
76 { | 82 { |
77 TcpTxBuffer txBuf; | 83 TcpTxBuffer txBuf; |
78 SequenceNumber32 head (1); | 84 SequenceNumber32 head (1); |
79 SequenceNumber32 ret; | 85 SequenceNumber32 ret; |
80 uint32_t dupThresh = 3; | 86 uint32_t dupThresh = 3; |
81 uint32_t segmentSize = 150; | 87 uint32_t segmentSize = 150; |
82 Ptr<TcpOptionSack> sack = CreateObject<TcpOptionSack> (); | 88 Ptr<TcpOptionSack> sack = CreateObject<TcpOptionSack> (); |
83 | 89 |
84 // At the beginning the values of dupThresh and segmentSize don't matter | 90 // At the beginning the values of dupThresh and segmentSize don't matter |
85 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, 0, 0), false, | 91 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, 0, 0, false), false, |
86 "NextSeq should not be returned at the beginning"); | 92 "NextSeq should not be returned at the beginning"); |
87 | 93 |
88 txBuf.SetHeadSequence (head); | 94 txBuf.SetHeadSequence (head); |
89 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, 0, 0), false, | 95 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, 0, 0, false), false, |
90 "NextSeq should not be returned with no data"); | 96 "NextSeq should not be returned with no data"); |
91 | 97 |
92 // Add a single, 3000-bytes long, packet | 98 // Add a single, 3000-bytes long, packet |
93 txBuf.Add (Create<Packet> (30000)); | 99 txBuf.Add (Create<Packet> (30000)); |
94 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, 0, 0), true, | 100 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, 0, 0, false), true, |
95 "No NextSeq with data at beginning"); | 101 "No NextSeq with data at beginning"); |
96 NS_TEST_ASSERT_MSG_EQ (ret.GetValue (), head.GetValue (), | 102 NS_TEST_ASSERT_MSG_EQ (ret.GetValue (), head.GetValue (), |
97 "Different NextSeq than expected at the beginning"); | 103 "Different NextSeq than expected at the beginning"); |
98 | 104 |
99 // Simulate sending 100 packets, 150 bytes long each, from seq 1 | 105 // Simulate sending 100 packets, 150 bytes long each, from seq 1 |
100 for (uint32_t i=0; i<100; ++i) | 106 for (uint32_t i=0; i<100; ++i) |
101 { | 107 { |
102 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, dupThresh, segmentSize), true, | 108 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, dupThresh, segmentSize, false)
, true, |
103 "No NextSeq with data while \"transmitting\""); | 109 "No NextSeq with data while \"transmitting\""); |
104 NS_TEST_ASSERT_MSG_EQ (ret, head + (segmentSize * i), | 110 NS_TEST_ASSERT_MSG_EQ (ret, head + (segmentSize * i), |
105 "Different NextSeq than expected while \"transmitti
ng\""); | 111 "Different NextSeq than expected while \"transmitti
ng\""); |
106 txBuf.CopyFromSequence (segmentSize, ret); | 112 txBuf.CopyFromSequence (segmentSize, ret); |
107 } | 113 } |
108 | 114 |
109 // Ok, now simulate we lost the first segment [1;151], and that we have | 115 // Ok, now simulate we lost the first segment [1;151], and that we have |
110 // limited transmit. NextSeg should return (up to dupThresh-1) new pieces of d
ata | 116 // limited transmit. NextSeg should return (up to dupThresh-1) new pieces of d
ata |
111 SequenceNumber32 lastRet = ret; // This is like m_highTx | 117 SequenceNumber32 lastRet = ret; // This is like m_highTx |
112 for (uint32_t i=1; i<dupThresh; ++i) // iterate dupThresh-1 times (limited tra
nsmit) | 118 for (uint32_t i=1; i<dupThresh; ++i) // iterate dupThresh-1 times (limited tra
nsmit) |
113 { | 119 { |
114 SequenceNumber32 begin = head + (segmentSize * i); | 120 SequenceNumber32 begin = head + (segmentSize * i); |
115 SequenceNumber32 end = begin + segmentSize; | 121 SequenceNumber32 end = begin + segmentSize; |
116 sack->AddSackBlock (TcpOptionSack::SackBlock (begin, end)); | 122 sack->AddSackBlock (TcpOptionSack::SackBlock (begin, end)); |
117 txBuf.Update (sack->GetSackList ()); | 123 txBuf.Update (sack->GetSackList ()); |
118 | 124 |
119 // new data expected and sent | 125 // new data expected and sent |
120 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, dupThresh, segmentSize), true, | 126 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, dupThresh, segmentSize, false)
, true, |
121 "No NextSeq with SACK block while \"transmitting\""
); | 127 "No NextSeq with SACK block while \"transmitting\""
); |
122 NS_TEST_ASSERT_MSG_EQ (ret, lastRet + segmentSize, | 128 NS_TEST_ASSERT_MSG_EQ (ret, lastRet + segmentSize, |
123 "Different NextSeq than expected in limited transmi
t"); | 129 "Different NextSeq than expected in limited transmi
t"); |
124 txBuf.CopyFromSequence (segmentSize, ret); | 130 txBuf.CopyFromSequence (segmentSize, ret); |
125 sack->ClearSackList (); | 131 sack->ClearSackList (); |
126 lastRet = ret; | 132 lastRet = ret; |
127 } | 133 } |
128 | 134 |
129 // Limited transmit was ok; now there is the dupThresh-th dupack. | 135 // Limited transmit was ok; now there is the dupThresh-th dupack. |
130 // Now we need to retransmit the first block.. | 136 // Now we need to retransmit the first block.. |
131 sack->AddSackBlock (TcpOptionSack::SackBlock (head + (segmentSize * (dupThresh
)), | 137 sack->AddSackBlock (TcpOptionSack::SackBlock (head + (segmentSize * (dupThresh
)), |
132 head + (segmentSize * (dupThresh
)) + segmentSize)); | 138 head + (segmentSize * (dupThresh
)) + segmentSize)); |
133 txBuf.Update (sack->GetSackList ()); | 139 txBuf.Update (sack->GetSackList ()); |
134 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, dupThresh, segmentSize), true, | 140 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, dupThresh, segmentSize, false), tr
ue, |
135 "No NextSeq with SACK block for Fast Recovery"); | 141 "No NextSeq with SACK block for Fast Recovery"); |
136 NS_TEST_ASSERT_MSG_EQ (ret, head, | 142 NS_TEST_ASSERT_MSG_EQ (ret, head, |
137 "Different NextSeq than expected for Fast Recovery"); | 143 "Different NextSeq than expected for Fast Recovery"); |
138 txBuf.CopyFromSequence (segmentSize, ret); | 144 txBuf.CopyFromSequence (segmentSize, ret); |
139 sack->ClearSackList (); | 145 sack->ClearSackList (); |
140 | 146 |
141 // Fast Retransmission was ok; now check some additional dupacks. | 147 // Fast Retransmission was ok; now check some additional dupacks. |
142 for (uint32_t i=1; i<=4; ++i) | 148 for (uint32_t i=1; i<=4; ++i) |
143 { | 149 { |
144 sack->AddSackBlock (TcpOptionSack::SackBlock (head + (segmentSize * (dupTh
resh+i)), | 150 sack->AddSackBlock (TcpOptionSack::SackBlock (head + (segmentSize * (dupTh
resh+i)), |
145 head + (segmentSize * (dupTh
resh+i)) + segmentSize)); | 151 head + (segmentSize * (dupTh
resh+i)) + segmentSize)); |
146 txBuf.Update (sack->GetSackList ()); | 152 txBuf.Update (sack->GetSackList ()); |
147 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, dupThresh, segmentSize), true, | 153 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, dupThresh, segmentSize, false)
, true, |
148 "No NextSeq with SACK block after recv dupacks in F
R"); | 154 "No NextSeq with SACK block after recv dupacks in F
R"); |
149 NS_TEST_ASSERT_MSG_EQ (ret, lastRet + segmentSize, | 155 NS_TEST_ASSERT_MSG_EQ (ret, lastRet + segmentSize, |
150 "Different NextSeq than expected after recv dupacks
in FR"); | 156 "Different NextSeq than expected after recv dupacks
in FR"); |
151 txBuf.CopyFromSequence (segmentSize, ret); | 157 txBuf.CopyFromSequence (segmentSize, ret); |
152 sack->ClearSackList (); | 158 sack->ClearSackList (); |
153 lastRet = ret; | 159 lastRet = ret; |
154 } | 160 } |
155 | 161 |
156 // Well now we receive a partial ACK, corresponding to the segment we retransm
itted. | 162 // Well now we receive a partial ACK, corresponding to the segment we retransm
itted. |
157 // Unfortunately, the next one is lost as well; but NextSeg should be smart en
ough | 163 // Unfortunately, the next one is lost as well; but NextSeg should be smart en
ough |
158 // to give us the next segment (head + segmentSize) to retransmit. | 164 // to give us the next segment (head + segmentSize) to retransmit. |
159 /* In this particular case, we are checking the fact that we have badly crafte
d | 165 /* In this particular case, we are checking the fact that we have badly crafte
d |
160 * the SACK blocks. Talking in segment, we transmitted 1,2,3,4,5 ... and then | 166 * the SACK blocks. Talking in segment, we transmitted 1,2,3,4,5 ... and then |
161 * received dupack for 1. While receiving these, we crafted SACK block in the | 167 * received dupack for 1. While receiving these, we crafted SACK block in the |
162 * way that 2,3,4,... were correctly received. Now, if we receive an ACK for 2
, | 168 * way that 2,3,4,... were correctly received. Now, if we receive an ACK for 2
, |
163 * we clearly crafted the corresponding ACK wrongly. TcpTxBuffer should be abl
e | 169 * we clearly crafted the corresponding ACK wrongly. TcpTxBuffer should be abl
e |
164 * to "backoff" that flag on its HEAD (segment 2). We still don't know for seg
ment | 170 * to "backoff" that flag on its HEAD (segment 2). We still don't know for seg
ment |
165 * 3,4 .. so keep them. | 171 * 3,4 .. so keep them. |
166 */ | 172 */ |
167 head = head + segmentSize; | 173 head = head + segmentSize; |
168 txBuf.DiscardUpTo (head); | 174 txBuf.DiscardUpTo (head); |
169 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, dupThresh, segmentSize), true, | 175 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, dupThresh, segmentSize, false), tr
ue, |
170 "No NextSeq with SACK block after receiving partial ACK
"); | 176 "No NextSeq with SACK block after receiving partial ACK
"); |
171 NS_TEST_ASSERT_MSG_EQ (ret, head, | 177 NS_TEST_ASSERT_MSG_EQ (ret, head, |
172 "Different NextSeq than expected after receiving partia
l ACK"); | 178 "Different NextSeq than expected after receiving partia
l ACK"); |
173 txBuf.CopyFromSequence (segmentSize, ret); | 179 txBuf.CopyFromSequence (segmentSize, ret); |
174 | 180 |
175 // Now, check for one more dupack... | 181 // Now, check for one more dupack... |
176 sack->AddSackBlock (TcpOptionSack::SackBlock (head + (segmentSize * (dupThresh
+6)), | 182 sack->AddSackBlock (TcpOptionSack::SackBlock (head + (segmentSize * (dupThresh
+6)), |
177 head + (segmentSize * (dupThresh
+6)) + segmentSize)); | 183 head + (segmentSize * (dupThresh
+6)) + segmentSize)); |
178 txBuf.Update (sack->GetSackList ()); | 184 txBuf.Update (sack->GetSackList ()); |
179 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, dupThresh, segmentSize), true, | 185 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, dupThresh, segmentSize, false), tr
ue, |
180 "No NextSeq with SACK block after recv dupacks after pa
rtial ack"); | 186 "No NextSeq with SACK block after recv dupacks after pa
rtial ack"); |
181 NS_TEST_ASSERT_MSG_EQ (ret, lastRet + segmentSize, | 187 NS_TEST_ASSERT_MSG_EQ (ret, lastRet + segmentSize, |
182 "Different NextSeq than expected after recv dupacks aft
er partial ack"); | 188 "Different NextSeq than expected after recv dupacks aft
er partial ack"); |
183 txBuf.CopyFromSequence (segmentSize, ret); | 189 txBuf.CopyFromSequence (segmentSize, ret); |
184 sack->ClearSackList (); | 190 sack->ClearSackList (); |
185 head = lastRet = ret + segmentSize; | 191 head = lastRet = ret + segmentSize; |
186 | 192 |
187 // And now ack everything we sent to date! | 193 // And now ack everything we sent to date! |
188 txBuf.DiscardUpTo (head); | 194 txBuf.DiscardUpTo (head); |
189 | 195 |
190 // And continue normally until the end | 196 // And continue normally until the end |
191 for (uint32_t i=0; i<93; ++i) | 197 for (uint32_t i=0; i<93; ++i) |
192 { | 198 { |
193 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (ret, dupThresh, segmentSize), true, | 199 NS_TEST_ASSERT_MSG_EQ (txBuf.NextSeg (&ret, dupThresh, segmentSize, false)
, true, |
194 "No NextSeq with data while \"transmitting\""); | 200 "No NextSeq with data while \"transmitting\""); |
195 NS_TEST_ASSERT_MSG_EQ (ret, head + (segmentSize * i), | 201 NS_TEST_ASSERT_MSG_EQ (ret, head + (segmentSize * i), |
196 "Different NextSeq than expected while \"transmitti
ng\""); | 202 "Different NextSeq than expected while \"transmitti
ng\""); |
197 txBuf.CopyFromSequence (segmentSize, ret); | 203 txBuf.CopyFromSequence (segmentSize, ret); |
198 } | 204 } |
199 | 205 |
200 txBuf.DiscardUpTo (ret+segmentSize); | 206 txBuf.DiscardUpTo (ret+segmentSize); |
201 NS_TEST_ASSERT_MSG_EQ (txBuf.Size (), 0, | 207 NS_TEST_ASSERT_MSG_EQ (txBuf.Size (), 0, |
202 "Data inside the buffer"); | 208 "Data inside the buffer"); |
203 } | 209 } |
(...skipping 12 matching lines...) Expand all Loading... |
216 for (uint32_t i=0; i<100; ++i) | 222 for (uint32_t i=0; i<100; ++i) |
217 { | 223 { |
218 txBuf.CopyFromSequence (150, head + (150 * i)); | 224 txBuf.CopyFromSequence (150, head + (150 * i)); |
219 } | 225 } |
220 | 226 |
221 // Now we have 100 packets sent, 100 waiting (well, that 100 are condensed in
one) | 227 // Now we have 100 packets sent, 100 waiting (well, that 100 are condensed in
one) |
222 | 228 |
223 // Suppose now we receive 99 dupacks, because the first was lost. | 229 // Suppose now we receive 99 dupacks, because the first was lost. |
224 for (uint32_t i=0; i<99; ++i) | 230 for (uint32_t i=0; i<99; ++i) |
225 { | 231 { |
226 Ptr<TcpOptionSack> sack = txBuf.CraftSackOption (head, 32); // 3 maximum s
ack block | 232 Ptr<const TcpOptionSack> sack = txBuf.CraftSackOption (head, 32); // 3 max
imum sack block |
227 | 233 |
228 // For iteration 0 and 1 we have 1 and 2 sack blocks, respectively. | 234 // For iteration 0 and 1 we have 1 and 2 sack blocks, respectively. |
229 // For all others, maximum 3 | 235 // For all others, maximum 3 |
230 if (i == 0) | 236 if (i == 0) |
231 { | 237 { |
232 NS_TEST_ASSERT_MSG_EQ (sack->GetNumSackBlocks (), 1, | 238 NS_TEST_ASSERT_MSG_EQ (sack->GetNumSackBlocks (), 1, |
233 "Different block number than expected"); | 239 "Different block number than expected"); |
234 } | 240 } |
235 else if (i == 1) | 241 else if (i == 1) |
236 { | 242 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 279 |
274 if (i == 0) | 280 if (i == 0) |
275 { | 281 { |
276 NS_TEST_ASSERT_MSG_EQ (false, txBuf.IsLost (SequenceNumber32 (1), 3, 1
50), | 282 NS_TEST_ASSERT_MSG_EQ (false, txBuf.IsLost (SequenceNumber32 (1), 3, 1
50), |
277 "SequenceNumber 1 isLost, but for RFC 6675 is n
ot"); | 283 "SequenceNumber 1 isLost, but for RFC 6675 is n
ot"); |
278 } | 284 } |
279 else if (i == 1) | 285 else if (i == 1) |
280 { | 286 { |
281 NS_TEST_ASSERT_MSG_EQ (false, txBuf.IsLost (SequenceNumber32 (1), 3, 1
50), | 287 NS_TEST_ASSERT_MSG_EQ (false, txBuf.IsLost (SequenceNumber32 (1), 3, 1
50), |
282 "SequenceNumber 1 isLost, but for RFC 6675 is n
ot"); | 288 "SequenceNumber 1 isLost, but for RFC 6675 is n
ot"); |
| 289 SequenceNumber32 lost (1 + (150 * i)); |
| 290 NS_TEST_ASSERT_MSG_EQ (false, txBuf.IsLost (lost, 3, 150), |
| 291 "SequenceNumber " << lost << |
| 292 "isLost, but for RFC 6675 is because is SACKed"
); |
283 } | 293 } |
284 else if (i >= 2) | 294 else if (i >= 2) |
285 { | 295 { |
286 SequenceNumber32 lost (1 + (150 * (i-2))); | 296 NS_TEST_ASSERT_MSG_EQ (true, txBuf.IsLost (SequenceNumber32 (1), 3, 15
0), |
287 NS_TEST_ASSERT_MSG_EQ (true, txBuf.IsLost (lost, 3, 150), | 297 "SequenceNumber 1 ! isLost, but for RFC 6675 is
"); |
| 298 SequenceNumber32 lost (1 + (150 * i)); |
| 299 NS_TEST_ASSERT_MSG_EQ (false, txBuf.IsLost (lost, 3, 150), |
288 "SequenceNumber " << lost << | 300 "SequenceNumber " << lost << |
289 " ! isLost, but for RFC 6675 is"); | 301 "isLost, but for RFC 6675 is because is SACKed"
); |
290 } | 302 } |
291 } | 303 } |
| 304 |
| 305 for (uint32_t i=0; i<100; ++i) |
| 306 { |
| 307 txBuf.DiscardUpTo (SequenceNumber32 (30001)); |
| 308 } |
| 309 |
| 310 NS_TEST_ASSERT_MSG_EQ (txBuf.Size (), 0, |
| 311 "Data inside the buffer"); |
292 } | 312 } |
293 | 313 |
294 void | 314 void |
295 TcpTxBufferTestCase::TestNewBlock () | 315 TcpTxBufferTestCase::TestNewBlock () |
296 { | 316 { |
297 // Manually recreating all the conditions | 317 // Manually recreating all the conditions |
298 TcpTxBuffer txBuf; | 318 TcpTxBuffer txBuf; |
299 txBuf.SetHeadSequence (SequenceNumber32 (1)); | 319 txBuf.SetHeadSequence (SequenceNumber32 (1)); |
300 | 320 |
301 // get a packet which is exactly the same stored | 321 // get a packet which is exactly the same stored |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 "TxBuf miscalculates size"); | 365 "TxBuf miscalculates size"); |
346 //NS_TEST_ASSERT_MSG_EQ (txBuf.BytesInFlight (), 120, | 366 //NS_TEST_ASSERT_MSG_EQ (txBuf.BytesInFlight (), 120, |
347 // "TxBuf miscalculates size of in flight segments"); | 367 // "TxBuf miscalculates size of in flight segments"); |
348 | 368 |
349 ret = txBuf.CopyFromSequence (3000, SequenceNumber32 (221)); | 369 ret = txBuf.CopyFromSequence (3000, SequenceNumber32 (221)); |
350 NS_TEST_ASSERT_MSG_EQ (ret->GetSize (), 80, | 370 NS_TEST_ASSERT_MSG_EQ (ret->GetSize (), 80, |
351 "Returned packet has different size than requested"); | 371 "Returned packet has different size than requested"); |
352 NS_TEST_ASSERT_MSG_EQ (txBuf.SizeFromSequence (SequenceNumber32 (301)), 0, | 372 NS_TEST_ASSERT_MSG_EQ (txBuf.SizeFromSequence (SequenceNumber32 (301)), 0, |
353 "TxBuf miscalculates size"); | 373 "TxBuf miscalculates size"); |
354 //NS_TEST_ASSERT_MSG_EQ (txBuf.BytesInFlight (), 200, | 374 //NS_TEST_ASSERT_MSG_EQ (txBuf.BytesInFlight (), 200, |
355 // "TxBuf miscalculates size of in flight segments"); | 375 // "TxBuf miscalculates size of in flight segments"); |
356 | 376 |
357 // Clear everything | 377 // Clear everything |
358 txBuf.DiscardUpTo (SequenceNumber32 (381)); | 378 txBuf.DiscardUpTo (SequenceNumber32 (381)); |
359 NS_TEST_ASSERT_MSG_EQ (txBuf.Size (), 0, | 379 NS_TEST_ASSERT_MSG_EQ (txBuf.Size (), 0, |
360 "Size is different than expected"); | 380 "Size is different than expected"); |
361 } | 381 } |
362 | 382 |
363 void | 383 void |
364 TcpTxBufferTestCase::TestTransmittedBlock () | 384 TcpTxBufferTestCase::TestTransmittedBlock () |
365 { | 385 { |
366 } | 386 } |
367 | 387 |
368 void | 388 void |
369 TcpTxBufferTestCase::DoTeardown () | 389 TcpTxBufferTestCase::DoTeardown () |
370 { | 390 { |
371 } | 391 } |
372 | 392 |
373 class TcpTxBufferTestSuite : public TestSuite | 393 class TcpTxBufferTestSuite : public TestSuite |
374 { | 394 { |
375 public: | 395 public: |
376 TcpTxBufferTestSuite () | 396 TcpTxBufferTestSuite () |
377 : TestSuite ("tcp-tx-buffer", UNIT) | 397 : TestSuite ("tcp-tx-buffer", UNIT) |
378 { | 398 { |
379 AddTestCase (new TcpTxBufferTestCase, TestCase::QUICK); | 399 AddTestCase (new TcpTxBufferTestCase, TestCase::QUICK); |
380 } | 400 } |
381 }; | 401 }; |
382 static TcpTxBufferTestSuite g_tcpTxBufferTestSuite; | 402 static TcpTxBufferTestSuite g_tcpTxBufferTestSuite; |
LEFT | RIGHT |