author | Faker Moatamri <faker.moatamri@sophia.inria.fr> |
Tue, 19 Jan 2010 17:06:18 +0100 | |
changeset 5919 | b89ce2e9eed5 |
parent 5749 | 1c6600743c9e |
child 6417 | 82ca017090e7 |
permissions | -rw-r--r-- |
5712 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2009 IITP RAS |
|
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 |
* Authors: Pavel Boyko <boyko@iitp.ru> |
|
19 |
*/ |
|
20 |
#include "ns3/test.h" |
|
21 |
#include "aodv-neighbor.h" |
|
22 |
#include "aodv-packet.h" |
|
23 |
#include "aodv-rqueue.h" |
|
5713
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
24 |
#include "aodv-rtable.h" |
5712 | 25 |
#include "ns3/ipv4-route.h" |
26 |
||
27 |
namespace ns3 |
|
28 |
{ |
|
29 |
namespace aodv |
|
30 |
{ |
|
31 |
||
32 |
/// Unit test for neighbors |
|
33 |
struct NeighborTest : public TestCase |
|
34 |
{ |
|
35 |
NeighborTest () : TestCase ("Neighbor"), neighbor (0) { } |
|
36 |
virtual bool DoRun (); |
|
37 |
void Handler (Ipv4Address addr); |
|
38 |
void CheckTimeout1 (); |
|
39 |
void CheckTimeout2 (); |
|
40 |
void CheckTimeout3 (); |
|
41 |
Neighbors * neighbor; |
|
42 |
}; |
|
43 |
||
44 |
void |
|
45 |
NeighborTest::Handler (Ipv4Address addr) |
|
46 |
{ |
|
47 |
} |
|
48 |
||
49 |
void |
|
50 |
NeighborTest::CheckTimeout1 () |
|
51 |
{ |
|
52 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), true, "Neighbor exists"); |
|
53 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.1.1.1")), true, "Neighbor exists"); |
|
54 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("2.2.2.2")), true, "Neighbor exists"); |
|
55 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("3.3.3.3")), true, "Neighbor exists"); |
|
56 |
} |
|
57 |
void |
|
58 |
NeighborTest::CheckTimeout2 () |
|
59 |
{ |
|
60 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), false, "Neighbor doesn't exist"); |
|
61 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.1.1.1")), false, "Neighbor doesn't exist"); |
|
62 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("2.2.2.2")), false, "Neighbor doesn't exist"); |
|
63 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("3.3.3.3")), true, "Neighbor exists"); |
|
64 |
} |
|
65 |
void |
|
66 |
NeighborTest::CheckTimeout3 () |
|
67 |
{ |
|
68 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), false, "Neighbor doesn't exist"); |
|
69 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.1.1.1")), false, "Neighbor doesn't exist"); |
|
70 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("2.2.2.2")), false, "Neighbor doesn't exist"); |
|
71 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("3.3.3.3")), false, "Neighbor doesn't exist"); |
|
72 |
} |
|
73 |
||
74 |
bool |
|
75 |
NeighborTest::DoRun () |
|
76 |
{ |
|
77 |
Neighbors nb (Seconds (1)); |
|
78 |
neighbor = &nb; |
|
79 |
neighbor->SetCallback (MakeCallback (&NeighborTest::Handler, this)); |
|
80 |
neighbor->Update (Ipv4Address ("1.2.3.4"), Seconds (1)); |
|
81 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), true, "Neighbor exists"); |
|
82 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("4.3.2.1")), false, "Neighbor doesn't exist"); |
|
83 |
neighbor->Update (Ipv4Address ("1.2.3.4"), Seconds (10)); |
|
84 |
NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), true, "Neighbor exists"); |
|
85 |
NS_TEST_EXPECT_MSG_EQ (neighbor->GetExpireTime (Ipv4Address ("1.2.3.4")), Seconds (10), "Known expire time"); |
|
86 |
NS_TEST_EXPECT_MSG_EQ (neighbor->GetExpireTime (Ipv4Address ("4.3.2.1")), Seconds (0), "Known expire time"); |
|
87 |
neighbor->Update (Ipv4Address ("1.1.1.1"), Seconds (5)); |
|
88 |
neighbor->Update (Ipv4Address ("2.2.2.2"), Seconds (10)); |
|
89 |
neighbor->Update (Ipv4Address ("3.3.3.3"), Seconds (20)); |
|
90 |
||
91 |
Simulator::Schedule (Seconds (2), &NeighborTest::CheckTimeout1, this); |
|
92 |
Simulator::Schedule (Seconds (15), &NeighborTest::CheckTimeout2, this); |
|
93 |
Simulator::Schedule (Seconds (30), &NeighborTest::CheckTimeout3, this); |
|
94 |
Simulator::Run (); |
|
95 |
Simulator::Destroy (); |
|
96 |
||
97 |
return GetErrorStatus (); |
|
98 |
} |
|
99 |
//----------------------------------------------------------------------------- |
|
100 |
struct TypeHeaderTest : public TestCase |
|
101 |
{ |
|
102 |
TypeHeaderTest () : TestCase ("AODV TypeHeader") |
|
103 |
{ |
|
104 |
} |
|
105 |
virtual bool DoRun () |
|
106 |
{ |
|
107 |
TypeHeader h (AODVTYPE_RREQ); |
|
108 |
NS_TEST_EXPECT_MSG_EQ (h.IsValid (), true, "Default header is valid"); |
|
109 |
NS_TEST_EXPECT_MSG_EQ (h.Get (), AODVTYPE_RREQ, "Default header is RREQ"); |
|
110 |
||
111 |
Ptr<Packet> p = Create<Packet> (); |
|
112 |
p->AddHeader (h); |
|
113 |
TypeHeader h2 (AODVTYPE_RREP); |
|
114 |
uint32_t bytes = p->RemoveHeader (h2); |
|
115 |
NS_TEST_EXPECT_MSG_EQ (bytes, 1, "Type header is 1 byte long"); |
|
116 |
NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); |
|
117 |
return GetErrorStatus (); |
|
118 |
} |
|
119 |
}; |
|
120 |
//----------------------------------------------------------------------------- |
|
121 |
/// Unit test for RREQ |
|
122 |
struct RreqHeaderTest : public TestCase |
|
123 |
{ |
|
124 |
RreqHeaderTest () : TestCase ("AODV RREQ") |
|
125 |
{ |
|
126 |
} |
|
127 |
virtual bool DoRun () |
|
128 |
{ |
|
129 |
RreqHeader h (/*flags*/0, /*reserved*/0, /*hopCount*/6, /*requestID*/1, /*dst*/Ipv4Address ("1.2.3.4"), |
|
130 |
/*dstSeqNo*/40, /*origin*/Ipv4Address ("4.3.2.1"), /*originSeqNo*/10); |
|
131 |
NS_TEST_EXPECT_MSG_EQ (h.GetGratiousRrep (), false, "trivial"); |
|
132 |
NS_TEST_EXPECT_MSG_EQ (h.GetDestinationOnly (), false, "trivial"); |
|
133 |
NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 6, "trivial"); |
|
134 |
NS_TEST_EXPECT_MSG_EQ (h.GetId (), 1, "trivial"); |
|
135 |
NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.2.3.4"), "trivial"); |
|
136 |
NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 40, "trivial"); |
|
137 |
NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.3.2.1"), "trivial"); |
|
138 |
NS_TEST_EXPECT_MSG_EQ (h.GetOriginSeqno (), 10, "trivial"); |
|
139 |
||
140 |
h.SetGratiousRrep (true); |
|
141 |
NS_TEST_EXPECT_MSG_EQ (h.GetGratiousRrep (), true, "trivial"); |
|
142 |
h.SetDestinationOnly (true); |
|
143 |
NS_TEST_EXPECT_MSG_EQ (h.GetDestinationOnly (), true, "trivial"); |
|
144 |
h.SetUnknownSeqno (true); |
|
145 |
NS_TEST_EXPECT_MSG_EQ (h.GetUnknownSeqno (), true, "trivial"); |
|
146 |
h.SetDst (Ipv4Address ("1.1.1.1")); |
|
147 |
NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.1.1.1"), "trivial"); |
|
148 |
h.SetDstSeqno (5); |
|
149 |
NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 5, "trivial"); |
|
150 |
h.SetHopCount (7); |
|
151 |
NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 7, "trivial"); |
|
152 |
h.SetId (55); |
|
153 |
NS_TEST_EXPECT_MSG_EQ (h.GetId (), 55, "trivial"); |
|
154 |
h.SetOrigin (Ipv4Address ("4.4.4.4")); |
|
155 |
NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.4.4.4"), "trivial"); |
|
156 |
h.SetOriginSeqno (23); |
|
157 |
NS_TEST_EXPECT_MSG_EQ (h.GetOriginSeqno (), 23, "trivial"); |
|
158 |
||
159 |
Ptr<Packet> p = Create<Packet> (); |
|
160 |
p->AddHeader (h); |
|
161 |
RreqHeader h2; |
|
162 |
uint32_t bytes = p->RemoveHeader (h2); |
|
163 |
NS_TEST_EXPECT_MSG_EQ (bytes, 23, "RREP is 23 bytes long"); |
|
164 |
NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); |
|
165 |
||
166 |
return GetErrorStatus (); |
|
167 |
} |
|
168 |
}; |
|
169 |
//----------------------------------------------------------------------------- |
|
170 |
/// Unit test for RREP |
|
171 |
struct RrepHeaderTest : public TestCase |
|
172 |
{ |
|
173 |
RrepHeaderTest () : TestCase ("AODV RREP") {} |
|
174 |
virtual bool DoRun () |
|
175 |
{ |
|
176 |
RrepHeader h (/*prefixSize*/0, /*hopCount*/12, /*dst*/Ipv4Address ("1.2.3.4"), /*dstSeqNo*/2, |
|
177 |
/*origin*/Ipv4Address ("4.3.2.1"), /*lifetime*/Seconds (3)); |
|
178 |
NS_TEST_EXPECT_MSG_EQ (h.GetPrefixSize (), 0, "trivial"); |
|
179 |
NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 12, "trivial"); |
|
180 |
NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.2.3.4"), "trivial"); |
|
181 |
NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 2, "trivial"); |
|
182 |
NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.3.2.1"), "trivial"); |
|
183 |
NS_TEST_EXPECT_MSG_EQ (h.GetLifeTime (), Seconds (3), "trivial"); |
|
184 |
h.SetDst (Ipv4Address ("1.1.1.1")); |
|
185 |
NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.1.1.1"), "trivial"); |
|
186 |
h.SetDstSeqno (123); |
|
187 |
NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 123, "trivial"); |
|
188 |
h.SetOrigin (Ipv4Address ("4.4.4.4")); |
|
189 |
NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.4.4.4"), "trivial"); |
|
190 |
h.SetLifeTime (MilliSeconds (1200)); |
|
191 |
NS_TEST_EXPECT_MSG_EQ (h.GetLifeTime (), MilliSeconds (1200), "trivial"); |
|
192 |
h.SetAckRequired (true); |
|
193 |
NS_TEST_EXPECT_MSG_EQ (h.GetAckRequired (), true, "trivial"); |
|
194 |
h.SetAckRequired (false); |
|
195 |
NS_TEST_EXPECT_MSG_EQ (h.GetAckRequired (), false, "trivial"); |
|
196 |
h.SetPrefixSize (2); |
|
197 |
NS_TEST_EXPECT_MSG_EQ (h.GetPrefixSize (), 2, "trivial"); |
|
198 |
h.SetHopCount (15); |
|
199 |
NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 15, "trivial"); |
|
200 |
||
201 |
h.SetHello (Ipv4Address ("10.0.0.2"), 9, Seconds (15)); |
|
202 |
NS_TEST_EXPECT_MSG_EQ (h.GetDst (), h.GetOrigin (), "trivial"); |
|
203 |
NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 9, "trivial"); |
|
204 |
NS_TEST_EXPECT_MSG_EQ (h.GetLifeTime (), Seconds (15), "trivial"); |
|
205 |
||
206 |
Ptr<Packet> p = Create<Packet> (); |
|
207 |
p->AddHeader (h); |
|
208 |
RrepHeader h2; |
|
209 |
uint32_t bytes = p->RemoveHeader (h2); |
|
210 |
NS_TEST_EXPECT_MSG_EQ (bytes, 19, "RREP is 19 bytes long"); |
|
211 |
NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); |
|
212 |
return GetErrorStatus (); |
|
213 |
} |
|
214 |
}; |
|
215 |
//----------------------------------------------------------------------------- |
|
216 |
/// Unit test for RREP-ACK |
|
217 |
struct RrepAckHeaderTest : public TestCase |
|
218 |
{ |
|
219 |
RrepAckHeaderTest () : TestCase ("AODV RREP-ACK") |
|
220 |
{ |
|
221 |
} |
|
222 |
virtual bool DoRun() |
|
223 |
{ |
|
224 |
RrepAckHeader h; |
|
225 |
Ptr<Packet> p = Create<Packet> (); |
|
226 |
p->AddHeader (h); |
|
227 |
RrepAckHeader h2; |
|
228 |
uint32_t bytes = p->RemoveHeader(h2); |
|
229 |
NS_TEST_EXPECT_MSG_EQ (bytes, 1, "ACK is 1 byte long"); |
|
230 |
NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); |
|
231 |
return GetErrorStatus (); |
|
232 |
} |
|
233 |
}; |
|
234 |
//----------------------------------------------------------------------------- |
|
235 |
/// Unit test for RERR |
|
236 |
struct RerrHeaderTest : public TestCase |
|
237 |
{ |
|
238 |
RerrHeaderTest () : TestCase ("AODV RERR") |
|
239 |
{ |
|
240 |
} |
|
241 |
virtual bool DoRun() |
|
242 |
{ |
|
243 |
RerrHeader h; |
|
244 |
h.SetNoDelete(true); |
|
245 |
NS_TEST_EXPECT_MSG_EQ(h.GetNoDelete(), true, "trivial"); |
|
246 |
Ipv4Address dst = Ipv4Address("1.2.3.4"); |
|
247 |
NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 12), true, "trivial"); |
|
248 |
NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 1, "trivial"); |
|
249 |
NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 13), true, "trivial"); |
|
250 |
Ipv4Address dst2 = Ipv4Address("4.3.2.1"); |
|
251 |
NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst2, 12), true, "trivial"); |
|
252 |
NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 2, "trivial"); |
|
253 |
||
254 |
Ptr<Packet> p = Create<Packet> (); |
|
255 |
p->AddHeader (h); |
|
256 |
RerrHeader h2; |
|
257 |
uint32_t bytes = p->RemoveHeader(h2); |
|
258 |
NS_TEST_EXPECT_MSG_EQ (bytes, h.GetSerializedSize(), "(De)Serialized size match"); |
|
259 |
NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); |
|
260 |
return GetErrorStatus (); |
|
261 |
} |
|
262 |
}; |
|
263 |
//----------------------------------------------------------------------------- |
|
264 |
/// Unit test for AODV routing table entry |
|
265 |
struct QueueEntryTest : public TestCase |
|
266 |
{ |
|
267 |
QueueEntryTest () : TestCase ("QueueEntry") {} |
|
268 |
void Unicast (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header) {} |
|
269 |
void Error (Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno) {} |
|
270 |
void Unicast2 (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header) {} |
|
271 |
void Error2 (Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno) {} |
|
272 |
virtual bool DoRun() |
|
273 |
{ |
|
274 |
Ptr<const Packet> packet = Create<Packet> (); |
|
275 |
Ipv4Header h; |
|
276 |
h.SetDestination (Ipv4Address ("1.2.3.4")); |
|
277 |
h.SetSource (Ipv4Address ("4.3.2.1")); |
|
278 |
Ipv4RoutingProtocol::UnicastForwardCallback ucb = MakeCallback (&QueueEntryTest::Unicast, this); |
|
279 |
Ipv4RoutingProtocol::ErrorCallback ecb = MakeCallback (&QueueEntryTest::Error, this); |
|
280 |
QueueEntry entry (packet, h, ucb, ecb, Seconds (1)); |
|
281 |
NS_TEST_EXPECT_MSG_EQ (h.GetDestination (), entry.GetIpv4Header ().GetDestination (), "trivial"); |
|
282 |
NS_TEST_EXPECT_MSG_EQ (h.GetSource (), entry.GetIpv4Header ().GetSource (), "trivial"); |
|
283 |
NS_TEST_EXPECT_MSG_EQ (ucb.IsEqual(entry.GetUnicastForwardCallback ()), true, "trivial"); |
|
284 |
NS_TEST_EXPECT_MSG_EQ (ecb.IsEqual(entry.GetErrorCallback ()), true, "trivial"); |
|
285 |
NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (1), "trivial"); |
|
286 |
NS_TEST_EXPECT_MSG_EQ (entry.GetPacket (), packet, "trivial"); |
|
287 |
entry.SetExpireTime (Seconds (3)); |
|
288 |
NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (3), "trivial"); |
|
289 |
Ipv4Header h2; |
|
290 |
h2.SetDestination(Ipv4Address ("1.1.1.1")); |
|
291 |
entry.SetIpv4Header (h2); |
|
292 |
NS_TEST_EXPECT_MSG_EQ (entry.GetIpv4Header ().GetDestination (), Ipv4Address ("1.1.1.1"), "trivial"); |
|
293 |
Ipv4RoutingProtocol::UnicastForwardCallback ucb2 = MakeCallback (&QueueEntryTest::Unicast2, this); |
|
294 |
Ipv4RoutingProtocol::ErrorCallback ecb2 = MakeCallback (&QueueEntryTest::Error2, this); |
|
295 |
entry.SetErrorCallback (ecb2); |
|
296 |
NS_TEST_EXPECT_MSG_EQ (ecb2.IsEqual (entry.GetErrorCallback ()), true, "trivial"); |
|
297 |
entry.SetUnicastForwardCallback (ucb2); |
|
298 |
NS_TEST_EXPECT_MSG_EQ (ucb2.IsEqual (entry.GetUnicastForwardCallback ()), true, "trivial"); |
|
299 |
||
300 |
return GetErrorStatus(); |
|
301 |
} |
|
302 |
}; |
|
303 |
//----------------------------------------------------------------------------- |
|
5713
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
304 |
/// Unit test for RequestQueue |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
305 |
struct AodvRqueueTest : public TestCase |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
306 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
307 |
AodvRqueueTest () : TestCase ("Rqueue"), q (64, Seconds (30)) {} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
308 |
virtual bool DoRun (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
309 |
void Unicast (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header) {} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
310 |
void Error (Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno) {} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
311 |
void CheckSizeLimit (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
312 |
void CheckTimeout (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
313 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
314 |
RequestQueue q; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
315 |
}; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
316 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
317 |
bool |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
318 |
AodvRqueueTest::DoRun () |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
319 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
320 |
NS_TEST_EXPECT_MSG_EQ (q.GetMaxQueueLen (), 64, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
321 |
q.SetMaxQueueLen (32); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
322 |
NS_TEST_EXPECT_MSG_EQ (q.GetMaxQueueLen (), 32, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
323 |
NS_TEST_EXPECT_MSG_EQ (q.GetQueueTimeout (), Seconds (30), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
324 |
q.SetQueueTimeout (Seconds(10)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
325 |
NS_TEST_EXPECT_MSG_EQ (q.GetQueueTimeout (), Seconds (10), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
326 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
327 |
Ptr<const Packet> packet = Create<Packet> (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
328 |
Ipv4Header h; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
329 |
h.SetDestination (Ipv4Address ("1.2.3.4")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
330 |
h.SetSource (Ipv4Address ("4.3.2.1")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
331 |
Ipv4RoutingProtocol::UnicastForwardCallback ucb = MakeCallback (&AodvRqueueTest::Unicast, this); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
332 |
Ipv4RoutingProtocol::ErrorCallback ecb = MakeCallback (&AodvRqueueTest::Error, this); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
333 |
QueueEntry e1 (packet, h, ucb, ecb, Seconds (1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
334 |
q.Enqueue (e1); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
335 |
q.Enqueue (e1); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
336 |
q.Enqueue (e1); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
337 |
NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("1.2.3.4")), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
338 |
NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("1.1.1.1")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
339 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 1, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
340 |
q.DropPacketWithDst (Ipv4Address ("1.2.3.4")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
341 |
NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("1.2.3.4")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
342 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 0, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
343 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
344 |
h.SetDestination (Ipv4Address ("2.2.2.2")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
345 |
QueueEntry e2 (packet, h, ucb, ecb, Seconds (1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
346 |
q.Enqueue (e1); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
347 |
q.Enqueue (e2); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
348 |
Ptr<Packet> packet2 = Create<Packet> (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
349 |
QueueEntry e3 (packet2, h, ucb, ecb, Seconds (1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
350 |
NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address("3.3.3.3"), e3), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
351 |
NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("2.2.2.2"), e3), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
352 |
NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("2.2.2.2")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
353 |
q.Enqueue (e2); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
354 |
q.Enqueue (e3); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
355 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
356 |
Ptr<Packet> packet4 = Create<Packet> (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
357 |
h.SetDestination (Ipv4Address ("1.2.3.4")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
358 |
QueueEntry e4 (packet4, h, ucb, ecb, Seconds (20)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
359 |
q.Enqueue (e4); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
360 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 3, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
361 |
q.DropPacketWithDst (Ipv4Address ("1.2.3.4")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
362 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize(), 1, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
363 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
364 |
CheckSizeLimit (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
365 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
366 |
Ipv4Header header2; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
367 |
Ipv4Address dst2 ("1.2.3.4"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
368 |
header2.SetDestination (dst2); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
369 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
370 |
Simulator::Schedule (q.GetQueueTimeout () + Seconds (1), &AodvRqueueTest::CheckTimeout, this); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
371 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
372 |
Simulator::Run (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
373 |
Simulator::Destroy (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
374 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
375 |
return GetErrorStatus (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
376 |
} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
377 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
378 |
void |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
379 |
AodvRqueueTest::CheckSizeLimit () |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
380 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
381 |
Ptr<Packet> packet = Create<Packet> (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
382 |
Ipv4Header header; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
383 |
Ipv4RoutingProtocol::UnicastForwardCallback ucb = MakeCallback (&AodvRqueueTest::Unicast, this); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
384 |
Ipv4RoutingProtocol::ErrorCallback ecb = MakeCallback (&AodvRqueueTest::Error, this); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
385 |
QueueEntry e1 (packet, header, ucb, ecb, Seconds (1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
386 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
387 |
for (uint32_t i = 0; i < q.GetMaxQueueLen (); ++i) |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
388 |
q.Enqueue (e1); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
389 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
390 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
391 |
for (uint32_t i = 0; i < q.GetMaxQueueLen (); ++i) |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
392 |
q.Enqueue (e1); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
393 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
394 |
} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
395 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
396 |
void |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
397 |
AodvRqueueTest::CheckTimeout () |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
398 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
399 |
NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 0, "Must be empty now"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
400 |
} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
401 |
//----------------------------------------------------------------------------- |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
402 |
/// Unit test for AODV routing table entry |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
403 |
struct AodvRtableEntryTest : public TestCase |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
404 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
405 |
AodvRtableEntryTest () : TestCase ("RtableEntry") {} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
406 |
virtual bool DoRun() |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
407 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
408 |
Ptr<NetDevice> dev; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
409 |
Ipv4InterfaceAddress iface; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
410 |
RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10, |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
411 |
/*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("3.3.3.3"), /*lifetime*/Seconds(10)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
412 |
NS_TEST_EXPECT_MSG_EQ (rt.GetOutputDevice (), dev, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
413 |
NS_TEST_EXPECT_MSG_EQ (rt.GetDestination (), Ipv4Address ("1.2.3.4"), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
414 |
NS_TEST_EXPECT_MSG_EQ (rt.GetValidSeqNo (), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
415 |
NS_TEST_EXPECT_MSG_EQ (rt.GetSeqNo (), 10, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
416 |
NS_TEST_EXPECT_MSG_EQ (rt.GetInterface (), iface, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
417 |
NS_TEST_EXPECT_MSG_EQ (rt.GetHop (), 5, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
418 |
NS_TEST_EXPECT_MSG_EQ (rt.GetNextHop (), Ipv4Address ("3.3.3.3"), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
419 |
NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), Seconds (10), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
420 |
NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), VALID, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
421 |
NS_TEST_EXPECT_MSG_EQ (rt.GetRreqCnt (), 0, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
422 |
NS_TEST_EXPECT_MSG_EQ (rt.IsPrecursorListEmpty (), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
423 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
424 |
Ptr<NetDevice> dev2; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
425 |
Ipv4InterfaceAddress iface2; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
426 |
rt.SetOutputDevice (dev2); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
427 |
NS_TEST_EXPECT_MSG_EQ (rt.GetOutputDevice (), dev2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
428 |
rt.SetInterface (iface2); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
429 |
NS_TEST_EXPECT_MSG_EQ (rt.GetInterface (), iface2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
430 |
rt.SetValidSeqNo (false); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
431 |
NS_TEST_EXPECT_MSG_EQ (rt.GetValidSeqNo (), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
432 |
rt.SetFlag (INVALID); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
433 |
NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), INVALID, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
434 |
rt.SetFlag (IN_SEARCH); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
435 |
NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), IN_SEARCH, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
436 |
rt.SetHop (12); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
437 |
NS_TEST_EXPECT_MSG_EQ (rt.GetHop (), 12, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
438 |
rt.SetLifeTime (Seconds (1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
439 |
NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), Seconds (1), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
440 |
rt.SetNextHop (Ipv4Address ("1.1.1.1")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
441 |
NS_TEST_EXPECT_MSG_EQ (rt.GetNextHop (), Ipv4Address ("1.1.1.1"), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
442 |
rt.SetUnidirectional (true); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
443 |
NS_TEST_EXPECT_MSG_EQ (rt.IsUnidirectional (), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
444 |
rt.SetBalcklistTimeout (Seconds (7)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
445 |
NS_TEST_EXPECT_MSG_EQ (rt.GetBlacklistTimeout (), Seconds (7), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
446 |
rt.SetRreqCnt (2); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
447 |
NS_TEST_EXPECT_MSG_EQ (rt.GetRreqCnt (), 2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
448 |
rt.IncrementRreqCnt (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
449 |
NS_TEST_EXPECT_MSG_EQ (rt.GetRreqCnt (), 3, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
450 |
rt.Invalidate (Seconds (13)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
451 |
NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), INVALID, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
452 |
NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), Seconds (13), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
453 |
rt.SetLifeTime (Seconds (0.1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
454 |
NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), Seconds (0.1), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
455 |
Ptr<Ipv4Route> route = rt.GetRoute (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
456 |
NS_TEST_EXPECT_MSG_EQ (route->GetDestination (), Ipv4Address ("1.2.3.4"), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
457 |
|
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
458 |
NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.1")), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
459 |
NS_TEST_EXPECT_MSG_EQ (rt.IsPrecursorListEmpty (), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
460 |
NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.2")), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
461 |
NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.2")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
462 |
NS_TEST_EXPECT_MSG_EQ (rt.LookupPrecursor (Ipv4Address ("10.0.0.3")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
463 |
NS_TEST_EXPECT_MSG_EQ (rt.LookupPrecursor (Ipv4Address ("10.0.0.1")), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
464 |
NS_TEST_EXPECT_MSG_EQ (rt.DeletePrecursor (Ipv4Address ("10.0.0.2")), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
465 |
NS_TEST_EXPECT_MSG_EQ (rt.LookupPrecursor (Ipv4Address ("10.0.0.2")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
466 |
std::vector<Ipv4Address> prec; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
467 |
rt.GetPrecursors (prec); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
468 |
NS_TEST_EXPECT_MSG_EQ (prec.size (), 1, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
469 |
NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.4")), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
470 |
NS_TEST_EXPECT_MSG_EQ (rt.DeletePrecursor (Ipv4Address ("10.0.0.5")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
471 |
rt.GetPrecursors (prec); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
472 |
NS_TEST_EXPECT_MSG_EQ (prec.size (), 2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
473 |
rt.DeleteAllPrecursors (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
474 |
NS_TEST_EXPECT_MSG_EQ (rt.IsPrecursorListEmpty (), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
475 |
rt.GetPrecursors (prec); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
476 |
NS_TEST_EXPECT_MSG_EQ (prec.size (), 2, "trivial"); |
5919
b89ce2e9eed5
Bug 793: remove remaining memory leaks due to not cleaned Simulator
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
5749
diff
changeset
|
477 |
Simulator::Destroy (); |
5713
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
478 |
return GetErrorStatus (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
479 |
} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
480 |
}; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
481 |
//----------------------------------------------------------------------------- |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
482 |
/// Unit test for AODV routing table |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
483 |
struct AodvRtableTest : public TestCase |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
484 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
485 |
AodvRtableTest () : TestCase ("Rtable") {} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
486 |
virtual bool DoRun() |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
487 |
{ |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
488 |
RoutingTable rtable (Seconds (2)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
489 |
NS_TEST_EXPECT_MSG_EQ (rtable.GetBadLinkLifetime (), Seconds (2), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
490 |
rtable.SetBadLinkLifetime (Seconds (1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
491 |
NS_TEST_EXPECT_MSG_EQ (rtable.GetBadLinkLifetime (), Seconds (1), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
492 |
Ptr<NetDevice> dev; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
493 |
Ipv4InterfaceAddress iface; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
494 |
RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10, |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
495 |
/*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(10)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
496 |
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
497 |
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
498 |
RoutingTableEntry rt2 (/*output device*/dev, /*dst*/Ipv4Address("4.3.2.1"), /*validSeqNo*/false, /*seqNo*/0, |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
499 |
/*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(1)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
500 |
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt2), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
501 |
NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (rt2.GetDestination (), rt), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
502 |
NS_TEST_EXPECT_MSG_EQ (rt2.GetDestination (), rt.GetDestination (), "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
503 |
rt.SetHop (20); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
504 |
rt.InsertPrecursor (Ipv4Address ("10.0.0.3")); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
505 |
NS_TEST_EXPECT_MSG_EQ (rtable.Update (rt), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
506 |
RoutingTableEntry rt3; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
507 |
NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("10.0.0.1"), rt), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
508 |
NS_TEST_EXPECT_MSG_EQ (rtable.Update (rt3), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
509 |
NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("10.0.0.1"), INVALID), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
510 |
NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("1.2.3.4"), IN_SEARCH), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
511 |
NS_TEST_EXPECT_MSG_EQ (rtable.DeleteRoute (Ipv4Address ("5.5.5.5")), false, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
512 |
RoutingTableEntry rt4 (/*output device*/dev, /*dst*/Ipv4Address ("5.5.5.5"), /*validSeqNo*/false, /*seqNo*/0, |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
513 |
/*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address ("1.1.1.1"), /*lifetime*/Seconds (-10)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
514 |
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt4), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
515 |
NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("5.5.5.5"), INVALID), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
516 |
NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("5.5.5.5"), rt), false, "trivial"); |
5729
3fe43de9a826
[aodv] braces for loops added
Elena Buchatskaia <borovkovaes@iitp.ru>
parents:
5719
diff
changeset
|
517 |
NS_TEST_EXPECT_MSG_EQ (rtable.MarkLinkAsUnidirectional (Ipv4Address ("1.2.3.4"), Seconds (2)), true, "trivial"); |
5713
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
518 |
NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("1.2.3.4"), rt), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
519 |
NS_TEST_EXPECT_MSG_EQ (rt.IsUnidirectional (), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
520 |
rt.SetLifeTime (Seconds (-5)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
521 |
NS_TEST_EXPECT_MSG_EQ (rtable.Update (rt), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
522 |
std::map<Ipv4Address, uint32_t> unreachable; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
523 |
rtable.GetListOfDestinationWithNextHop (Ipv4Address ("1.1.1.1"), unreachable); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
524 |
NS_TEST_EXPECT_MSG_EQ (unreachable.size (), 2, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
525 |
unreachable.insert (std::make_pair (Ipv4Address ("4.3.2.1"), 3)); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
526 |
rtable.InvalidateRoutesWithDst (unreachable); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
527 |
NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("4.3.2.1"), rt), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
528 |
NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), INVALID, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
529 |
NS_TEST_EXPECT_MSG_EQ (rtable.DeleteRoute (Ipv4Address ("1.2.3.4")), true, "trivial"); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
530 |
NS_TEST_EXPECT_MSG_EQ (rtable.DeleteRoute (Ipv4Address ("1.2.3.4")), false, "trivial"); |
5919
b89ce2e9eed5
Bug 793: remove remaining memory leaks due to not cleaned Simulator
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
5749
diff
changeset
|
531 |
Simulator::Destroy (); |
5713
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
532 |
return GetErrorStatus (); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
533 |
} |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
534 |
}; |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
535 |
//----------------------------------------------------------------------------- |
5712 | 536 |
class AodvTestSuite : public TestSuite |
537 |
{ |
|
538 |
public: |
|
539 |
AodvTestSuite () : TestSuite ("routing-aodv", UNIT) |
|
540 |
{ |
|
541 |
AddTestCase (new NeighborTest); |
|
542 |
AddTestCase (new TypeHeaderTest); |
|
543 |
AddTestCase (new RreqHeaderTest); |
|
544 |
AddTestCase (new RrepHeaderTest); |
|
545 |
AddTestCase (new RrepAckHeaderTest); |
|
546 |
AddTestCase (new RerrHeaderTest); |
|
547 |
AddTestCase (new QueueEntryTest); |
|
5713
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
548 |
AddTestCase (new AodvRqueueTest); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
549 |
AddTestCase (new AodvRtableEntryTest); |
836cd50558d2
[aodv] Test rewrite in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5712
diff
changeset
|
550 |
AddTestCase (new AodvRtableTest); |
5712 | 551 |
} |
552 |
} g_aodvTestSuite; |
|
553 |
||
554 |
}} |