A Discrete-Event Network Simulator
API
aodv-test-suite.cc
Go to the documentation of this file.
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 "ns3/aodv-neighbor.h"
22 #include "ns3/aodv-packet.h"
23 #include "ns3/aodv-rqueue.h"
24 #include "ns3/aodv-rtable.h"
25 #include "ns3/ipv4-route.h"
26 
27 namespace ns3 {
28 namespace aodv {
29 
36 struct NeighborTest : public TestCase
37 {
38  NeighborTest () : TestCase ("Neighbor"),
39  neighbor (0)
40  {
41  }
42  virtual void DoRun ();
47  void Handler (Ipv4Address addr);
49  void CheckTimeout1 ();
51  void CheckTimeout2 ();
53  void CheckTimeout3 ();
56 };
57 
58 void
60 {
61 }
62 
63 void
65 {
66  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), true, "Neighbor exists");
67  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.1.1.1")), true, "Neighbor exists");
68  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("2.2.2.2")), true, "Neighbor exists");
69  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("3.3.3.3")), true, "Neighbor exists");
70 }
71 void
73 {
74  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), false, "Neighbor doesn't exist");
75  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.1.1.1")), false, "Neighbor doesn't exist");
76  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("2.2.2.2")), false, "Neighbor doesn't exist");
77  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("3.3.3.3")), true, "Neighbor exists");
78 }
79 void
81 {
82  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), false, "Neighbor doesn't exist");
83  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.1.1.1")), false, "Neighbor doesn't exist");
84  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("2.2.2.2")), false, "Neighbor doesn't exist");
85  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("3.3.3.3")), false, "Neighbor doesn't exist");
86 }
87 
88 void
90 {
91  Neighbors nb (Seconds (1));
92  neighbor = &nb;
94  neighbor->Update (Ipv4Address ("1.2.3.4"), Seconds (1));
95  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), true, "Neighbor exists");
96  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("4.3.2.1")), false, "Neighbor doesn't exist");
97  neighbor->Update (Ipv4Address ("1.2.3.4"), Seconds (10));
98  NS_TEST_EXPECT_MSG_EQ (neighbor->IsNeighbor (Ipv4Address ("1.2.3.4")), true, "Neighbor exists");
99  NS_TEST_EXPECT_MSG_EQ (neighbor->GetExpireTime (Ipv4Address ("1.2.3.4")), Seconds (10), "Known expire time");
100  NS_TEST_EXPECT_MSG_EQ (neighbor->GetExpireTime (Ipv4Address ("4.3.2.1")), Seconds (0), "Known expire time");
101  neighbor->Update (Ipv4Address ("1.1.1.1"), Seconds (5));
102  neighbor->Update (Ipv4Address ("2.2.2.2"), Seconds (10));
103  neighbor->Update (Ipv4Address ("3.3.3.3"), Seconds (20));
104 
108  Simulator::Run ();
110 }
111 
118 struct TypeHeaderTest : public TestCase
119 {
120  TypeHeaderTest () : TestCase ("AODV TypeHeader")
121  {
122  }
123  virtual void DoRun ()
124  {
126  NS_TEST_EXPECT_MSG_EQ (h.IsValid (), true, "Default header is valid");
127  NS_TEST_EXPECT_MSG_EQ (h.Get (), AODVTYPE_RREQ, "Default header is RREQ");
128 
129  Ptr<Packet> p = Create<Packet> ();
130  p->AddHeader (h);
132  uint32_t bytes = p->RemoveHeader (h2);
133  NS_TEST_EXPECT_MSG_EQ (bytes, 1, "Type header is 1 byte long");
134  NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works");
135  }
136 };
137 
144 struct RreqHeaderTest : public TestCase
145 {
146  RreqHeaderTest () : TestCase ("AODV RREQ")
147  {
148  }
149  virtual void DoRun ()
150  {
151  RreqHeader h (/*flags*/ 0, /*reserved*/ 0, /*hopCount*/ 6, /*requestID*/ 1, /*dst*/ Ipv4Address ("1.2.3.4"),
152  /*dstSeqNo*/ 40, /*origin*/ Ipv4Address ("4.3.2.1"), /*originSeqNo*/ 10);
153  NS_TEST_EXPECT_MSG_EQ (h.GetGratuitousRrep (), false, "trivial");
154  NS_TEST_EXPECT_MSG_EQ (h.GetDestinationOnly (), false, "trivial");
155  NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 6, "trivial");
156  NS_TEST_EXPECT_MSG_EQ (h.GetId (), 1, "trivial");
157  NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.2.3.4"), "trivial");
158  NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 40, "trivial");
159  NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.3.2.1"), "trivial");
160  NS_TEST_EXPECT_MSG_EQ (h.GetOriginSeqno (), 10, "trivial");
161 
162  h.SetGratuitousRrep (true);
163  NS_TEST_EXPECT_MSG_EQ (h.GetGratuitousRrep (), true, "trivial");
164  h.SetDestinationOnly (true);
165  NS_TEST_EXPECT_MSG_EQ (h.GetDestinationOnly (), true, "trivial");
166  h.SetUnknownSeqno (true);
167  NS_TEST_EXPECT_MSG_EQ (h.GetUnknownSeqno (), true, "trivial");
168  h.SetDst (Ipv4Address ("1.1.1.1"));
169  NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.1.1.1"), "trivial");
170  h.SetDstSeqno (5);
171  NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 5, "trivial");
172  h.SetHopCount (7);
173  NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 7, "trivial");
174  h.SetId (55);
175  NS_TEST_EXPECT_MSG_EQ (h.GetId (), 55, "trivial");
176  h.SetOrigin (Ipv4Address ("4.4.4.4"));
177  NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.4.4.4"), "trivial");
178  h.SetOriginSeqno (23);
179  NS_TEST_EXPECT_MSG_EQ (h.GetOriginSeqno (), 23, "trivial");
180 
181  Ptr<Packet> p = Create<Packet> ();
182  p->AddHeader (h);
183  RreqHeader h2;
184  uint32_t bytes = p->RemoveHeader (h2);
185  NS_TEST_EXPECT_MSG_EQ (bytes, 23, "RREP is 23 bytes long");
186  NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works");
187 
188  }
189 };
190 
197 struct RrepHeaderTest : public TestCase
198 {
199  RrepHeaderTest () : TestCase ("AODV RREP")
200  {
201  }
202  virtual void DoRun ()
203  {
204  RrepHeader h (/*prefixSize*/ 0, /*hopCount*/ 12, /*dst*/ Ipv4Address ("1.2.3.4"), /*dstSeqNo*/ 2,
205  /*origin*/ Ipv4Address ("4.3.2.1"), /*lifetime*/ Seconds (3));
206  NS_TEST_EXPECT_MSG_EQ (h.GetPrefixSize (), 0, "trivial");
207  NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 12, "trivial");
208  NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.2.3.4"), "trivial");
209  NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 2, "trivial");
210  NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.3.2.1"), "trivial");
211  NS_TEST_EXPECT_MSG_EQ (h.GetLifeTime (), Seconds (3), "trivial");
212  h.SetDst (Ipv4Address ("1.1.1.1"));
213  NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.1.1.1"), "trivial");
214  h.SetDstSeqno (123);
215  NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 123, "trivial");
216  h.SetOrigin (Ipv4Address ("4.4.4.4"));
217  NS_TEST_EXPECT_MSG_EQ (h.GetOrigin (), Ipv4Address ("4.4.4.4"), "trivial");
218  h.SetLifeTime (MilliSeconds (1200));
219  NS_TEST_EXPECT_MSG_EQ (h.GetLifeTime (), MilliSeconds (1200), "trivial");
220  h.SetAckRequired (true);
221  NS_TEST_EXPECT_MSG_EQ (h.GetAckRequired (), true, "trivial");
222  h.SetAckRequired (false);
223  NS_TEST_EXPECT_MSG_EQ (h.GetAckRequired (), false, "trivial");
224  h.SetPrefixSize (2);
225  NS_TEST_EXPECT_MSG_EQ (h.GetPrefixSize (), 2, "trivial");
226  h.SetHopCount (15);
227  NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 15, "trivial");
228 
229  h.SetHello (Ipv4Address ("10.0.0.2"), 9, Seconds (15));
230  NS_TEST_EXPECT_MSG_EQ (h.GetDst (), h.GetOrigin (), "trivial");
231  NS_TEST_EXPECT_MSG_EQ (h.GetDstSeqno (), 9, "trivial");
232  NS_TEST_EXPECT_MSG_EQ (h.GetLifeTime (), Seconds (15), "trivial");
233 
234  Ptr<Packet> p = Create<Packet> ();
235  p->AddHeader (h);
236  RrepHeader h2;
237  uint32_t bytes = p->RemoveHeader (h2);
238  NS_TEST_EXPECT_MSG_EQ (bytes, 19, "RREP is 19 bytes long");
239  NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works");
240  }
241 };
242 
250 {
251  RrepAckHeaderTest () : TestCase ("AODV RREP-ACK")
252  {
253  }
254  virtual void DoRun ()
255  {
256  RrepAckHeader h;
257  Ptr<Packet> p = Create<Packet> ();
258  p->AddHeader (h);
259  RrepAckHeader h2;
260  uint32_t bytes = p->RemoveHeader (h2);
261  NS_TEST_EXPECT_MSG_EQ (bytes, 1, "ACK is 1 byte long");
262  NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works");
263  }
264 };
265 
272 struct RerrHeaderTest : public TestCase
273 {
274  RerrHeaderTest () : TestCase ("AODV RERR")
275  {
276  }
277  virtual void DoRun ()
278  {
279  RerrHeader h;
280  h.SetNoDelete (true);
281  NS_TEST_EXPECT_MSG_EQ (h.GetNoDelete (), true, "trivial");
282  Ipv4Address dst = Ipv4Address ("1.2.3.4");
283  NS_TEST_EXPECT_MSG_EQ (h.AddUnDestination (dst, 12), true, "trivial");
284  NS_TEST_EXPECT_MSG_EQ (h.GetDestCount (), 1, "trivial");
285  NS_TEST_EXPECT_MSG_EQ (h.AddUnDestination (dst, 13), true, "trivial");
286  Ipv4Address dst2 = Ipv4Address ("4.3.2.1");
287  NS_TEST_EXPECT_MSG_EQ (h.AddUnDestination (dst2, 12), true, "trivial");
288  NS_TEST_EXPECT_MSG_EQ (h.GetDestCount (), 2, "trivial");
289 
290  Ptr<Packet> p = Create<Packet> ();
291  p->AddHeader (h);
292  RerrHeader h2;
293  uint32_t bytes = p->RemoveHeader (h2);
294  NS_TEST_EXPECT_MSG_EQ (bytes, h.GetSerializedSize (), "(De)Serialized size match");
295  NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works");
296  }
297 };
298 
305 struct QueueEntryTest : public TestCase
306 {
307  QueueEntryTest () : TestCase ("QueueEntry")
308  {
309  }
316  void Unicast (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header)
317  {
318  }
326  {
327  }
334  void Unicast2 (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header)
335  {
336  }
344  {
345  }
346  virtual void DoRun ()
347  {
348  Ptr<const Packet> packet = Create<Packet> ();
349  Ipv4Header h;
350  h.SetDestination (Ipv4Address ("1.2.3.4"));
351  h.SetSource (Ipv4Address ("4.3.2.1"));
354  QueueEntry entry (packet, h, ucb, ecb, Seconds (1));
355  NS_TEST_EXPECT_MSG_EQ (h.GetDestination (), entry.GetIpv4Header ().GetDestination (), "trivial");
356  NS_TEST_EXPECT_MSG_EQ (h.GetSource (), entry.GetIpv4Header ().GetSource (), "trivial");
357  NS_TEST_EXPECT_MSG_EQ (ucb.IsEqual (entry.GetUnicastForwardCallback ()), true, "trivial");
358  NS_TEST_EXPECT_MSG_EQ (ecb.IsEqual (entry.GetErrorCallback ()), true, "trivial");
359  NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (1), "trivial");
360  NS_TEST_EXPECT_MSG_EQ (entry.GetPacket (), packet, "trivial");
361  entry.SetExpireTime (Seconds (3));
362  NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (3), "trivial");
363  Ipv4Header h2;
364  h2.SetDestination (Ipv4Address ("1.1.1.1"));
365  entry.SetIpv4Header (h2);
366  NS_TEST_EXPECT_MSG_EQ (entry.GetIpv4Header ().GetDestination (), Ipv4Address ("1.1.1.1"), "trivial");
369  entry.SetErrorCallback (ecb2);
370  NS_TEST_EXPECT_MSG_EQ (ecb2.IsEqual (entry.GetErrorCallback ()), true, "trivial");
371  entry.SetUnicastForwardCallback (ucb2);
372  NS_TEST_EXPECT_MSG_EQ (ucb2.IsEqual (entry.GetUnicastForwardCallback ()), true, "trivial");
373  }
374 };
375 //-----------------------------------------------------------------------------
377 struct AodvRqueueTest : public TestCase
378 {
379  AodvRqueueTest () : TestCase ("Rqueue"),
380  q (64, Seconds (30))
381  {
382  }
383  virtual void DoRun ();
390  void Unicast (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header)
391  {
392  }
400  {
401  }
403  void CheckSizeLimit ();
405  void CheckTimeout ();
406 
409 };
410 
411 void
413 {
414  NS_TEST_EXPECT_MSG_EQ (q.GetMaxQueueLen (), 64, "trivial");
415  q.SetMaxQueueLen (32);
416  NS_TEST_EXPECT_MSG_EQ (q.GetMaxQueueLen (), 32, "trivial");
417  NS_TEST_EXPECT_MSG_EQ (q.GetQueueTimeout (), Seconds (30), "trivial");
418  q.SetQueueTimeout (Seconds (10));
419  NS_TEST_EXPECT_MSG_EQ (q.GetQueueTimeout (), Seconds (10), "trivial");
420 
421  Ptr<const Packet> packet = Create<Packet> ();
422  Ipv4Header h;
423  h.SetDestination (Ipv4Address ("1.2.3.4"));
424  h.SetSource (Ipv4Address ("4.3.2.1"));
427  QueueEntry e1 (packet, h, ucb, ecb, Seconds (1));
428  q.Enqueue (e1);
429  q.Enqueue (e1);
430  q.Enqueue (e1);
431  NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("1.2.3.4")), true, "trivial");
432  NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("1.1.1.1")), false, "trivial");
433  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 1, "trivial");
434  q.DropPacketWithDst (Ipv4Address ("1.2.3.4"));
435  NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("1.2.3.4")), false, "trivial");
436  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 0, "trivial");
437 
438  h.SetDestination (Ipv4Address ("2.2.2.2"));
439  QueueEntry e2 (packet, h, ucb, ecb, Seconds (1));
440  q.Enqueue (e1);
441  q.Enqueue (e2);
442  Ptr<Packet> packet2 = Create<Packet> ();
443  QueueEntry e3 (packet2, h, ucb, ecb, Seconds (1));
444  NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("3.3.3.3"), e3), false, "trivial");
445  NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("2.2.2.2"), e3), true, "trivial");
446  NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("2.2.2.2")), false, "trivial");
447  q.Enqueue (e2);
448  q.Enqueue (e3);
449  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial");
450  Ptr<Packet> packet4 = Create<Packet> ();
451  h.SetDestination (Ipv4Address ("1.2.3.4"));
452  QueueEntry e4 (packet4, h, ucb, ecb, Seconds (20));
453  q.Enqueue (e4);
454  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 3, "trivial");
455  q.DropPacketWithDst (Ipv4Address ("1.2.3.4"));
456  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 1, "trivial");
457 
458  CheckSizeLimit ();
459 
460  Ipv4Header header2;
461  Ipv4Address dst2 ("1.2.3.4");
462  header2.SetDestination (dst2);
463 
465 
466  Simulator::Run ();
468 }
469 
470 void
472 {
473  Ptr<Packet> packet = Create<Packet> ();
474  Ipv4Header header;
477  QueueEntry e1 (packet, header, ucb, ecb, Seconds (1));
478 
479  for (uint32_t i = 0; i < q.GetMaxQueueLen (); ++i)
480  {
481  q.Enqueue (e1);
482  }
483  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial");
484 
485  for (uint32_t i = 0; i < q.GetMaxQueueLen (); ++i)
486  {
487  q.Enqueue (e1);
488  }
489  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial");
490 }
491 
492 void
494 {
495  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 0, "Must be empty now");
496 }
497 
505 {
506  AodvRtableEntryTest () : TestCase ("RtableEntry")
507  {
508  }
509  virtual void DoRun ()
510  {
511  Ptr<NetDevice> dev;
512  Ipv4InterfaceAddress iface;
513  RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address ("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10,
514  /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address ("3.3.3.3"), /*lifetime*/ Seconds (10));
515  NS_TEST_EXPECT_MSG_EQ (rt.GetOutputDevice (), dev, "trivial");
516  NS_TEST_EXPECT_MSG_EQ (rt.GetDestination (), Ipv4Address ("1.2.3.4"), "trivial");
517  NS_TEST_EXPECT_MSG_EQ (rt.GetValidSeqNo (), true, "trivial");
518  NS_TEST_EXPECT_MSG_EQ (rt.GetSeqNo (), 10, "trivial");
519  NS_TEST_EXPECT_MSG_EQ (rt.GetInterface (), iface, "trivial");
520  NS_TEST_EXPECT_MSG_EQ (rt.GetHop (), 5, "trivial");
521  NS_TEST_EXPECT_MSG_EQ (rt.GetNextHop (), Ipv4Address ("3.3.3.3"), "trivial");
522  NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), Seconds (10), "trivial");
523  NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), VALID, "trivial");
524  NS_TEST_EXPECT_MSG_EQ (rt.GetRreqCnt (), 0, "trivial");
525  NS_TEST_EXPECT_MSG_EQ (rt.IsPrecursorListEmpty (), true, "trivial");
526 
527  Ptr<NetDevice> dev2;
528  Ipv4InterfaceAddress iface2;
529  rt.SetOutputDevice (dev2);
530  NS_TEST_EXPECT_MSG_EQ (rt.GetOutputDevice (), dev2, "trivial");
531  rt.SetInterface (iface2);
532  NS_TEST_EXPECT_MSG_EQ (rt.GetInterface (), iface2, "trivial");
533  rt.SetValidSeqNo (false);
534  NS_TEST_EXPECT_MSG_EQ (rt.GetValidSeqNo (), false, "trivial");
535  rt.SetFlag (INVALID);
536  NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), INVALID, "trivial");
537  rt.SetFlag (IN_SEARCH);
538  NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), IN_SEARCH, "trivial");
539  rt.SetHop (12);
540  NS_TEST_EXPECT_MSG_EQ (rt.GetHop (), 12, "trivial");
541  rt.SetLifeTime (Seconds (1));
542  NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), Seconds (1), "trivial");
543  rt.SetNextHop (Ipv4Address ("1.1.1.1"));
544  NS_TEST_EXPECT_MSG_EQ (rt.GetNextHop (), Ipv4Address ("1.1.1.1"), "trivial");
545  rt.SetUnidirectional (true);
546  NS_TEST_EXPECT_MSG_EQ (rt.IsUnidirectional (), true, "trivial");
547  rt.SetBlacklistTimeout (Seconds (7));
548  NS_TEST_EXPECT_MSG_EQ (rt.GetBlacklistTimeout (), Seconds (7), "trivial");
549  rt.SetRreqCnt (2);
550  NS_TEST_EXPECT_MSG_EQ (rt.GetRreqCnt (), 2, "trivial");
551  rt.IncrementRreqCnt ();
552  NS_TEST_EXPECT_MSG_EQ (rt.GetRreqCnt (), 3, "trivial");
553  rt.Invalidate (Seconds (13));
554  NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), INVALID, "trivial");
555  NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), Seconds (13), "trivial");
556  rt.SetLifeTime (MilliSeconds (100));
557  NS_TEST_EXPECT_MSG_EQ (rt.GetLifeTime (), MilliSeconds (100), "trivial");
558  Ptr<Ipv4Route> route = rt.GetRoute ();
559  NS_TEST_EXPECT_MSG_EQ (route->GetDestination (), Ipv4Address ("1.2.3.4"), "trivial");
560 
561  NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.1")), true, "trivial");
562  NS_TEST_EXPECT_MSG_EQ (rt.IsPrecursorListEmpty (), false, "trivial");
563  NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.2")), true, "trivial");
564  NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.2")), false, "trivial");
565  NS_TEST_EXPECT_MSG_EQ (rt.LookupPrecursor (Ipv4Address ("10.0.0.3")), false, "trivial");
566  NS_TEST_EXPECT_MSG_EQ (rt.LookupPrecursor (Ipv4Address ("10.0.0.1")), true, "trivial");
567  NS_TEST_EXPECT_MSG_EQ (rt.DeletePrecursor (Ipv4Address ("10.0.0.2")), true, "trivial");
568  NS_TEST_EXPECT_MSG_EQ (rt.LookupPrecursor (Ipv4Address ("10.0.0.2")), false, "trivial");
569  std::vector<Ipv4Address> prec;
570  rt.GetPrecursors (prec);
571  NS_TEST_EXPECT_MSG_EQ (prec.size (), 1, "trivial");
572  NS_TEST_EXPECT_MSG_EQ (rt.InsertPrecursor (Ipv4Address ("10.0.0.4")), true, "trivial");
573  NS_TEST_EXPECT_MSG_EQ (rt.DeletePrecursor (Ipv4Address ("10.0.0.5")), false, "trivial");
574  rt.GetPrecursors (prec);
575  NS_TEST_EXPECT_MSG_EQ (prec.size (), 2, "trivial");
576  rt.DeleteAllPrecursors ();
577  NS_TEST_EXPECT_MSG_EQ (rt.IsPrecursorListEmpty (), true, "trivial");
578  rt.GetPrecursors (prec);
579  NS_TEST_EXPECT_MSG_EQ (prec.size (), 2, "trivial");
581  }
582 };
583 
590 struct AodvRtableTest : public TestCase
591 {
592  AodvRtableTest () : TestCase ("Rtable")
593  {
594  }
595  virtual void DoRun ()
596  {
597  RoutingTable rtable (Seconds (2));
598  NS_TEST_EXPECT_MSG_EQ (rtable.GetBadLinkLifetime (), Seconds (2), "trivial");
599  rtable.SetBadLinkLifetime (Seconds (1));
600  NS_TEST_EXPECT_MSG_EQ (rtable.GetBadLinkLifetime (), Seconds (1), "trivial");
601  Ptr<NetDevice> dev;
602  Ipv4InterfaceAddress iface;
603  RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address ("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10,
604  /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address ("1.1.1.1"), /*lifetime*/ Seconds (10));
605  NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), true, "trivial");
606  NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), false, "trivial");
607  RoutingTableEntry rt2 (/*output device*/ dev, /*dst*/ Ipv4Address ("4.3.2.1"), /*validSeqNo*/ false, /*seqNo*/ 0,
608  /*interface*/ iface, /*hop*/ 15, /*next hop*/ Ipv4Address ("1.1.1.1"), /*lifetime*/ Seconds (1));
609  NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt2), true, "trivial");
610  NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (rt2.GetDestination (), rt), true, "trivial");
611  NS_TEST_EXPECT_MSG_EQ (rt2.GetDestination (), rt.GetDestination (), "trivial");
612  rt.SetHop (20);
613  rt.InsertPrecursor (Ipv4Address ("10.0.0.3"));
614  NS_TEST_EXPECT_MSG_EQ (rtable.Update (rt), true, "trivial");
615  RoutingTableEntry rt3;
616  NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("10.0.0.1"), rt), false, "trivial");
617  NS_TEST_EXPECT_MSG_EQ (rtable.Update (rt3), false, "trivial");
618  NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("10.0.0.1"), INVALID), false, "trivial");
619  NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("1.2.3.4"), IN_SEARCH), true, "trivial");
620  NS_TEST_EXPECT_MSG_EQ (rtable.DeleteRoute (Ipv4Address ("5.5.5.5")), false, "trivial");
621  RoutingTableEntry rt4 (/*output device*/ dev, /*dst*/ Ipv4Address ("5.5.5.5"), /*validSeqNo*/ false, /*seqNo*/ 0,
622  /*interface*/ iface, /*hop*/ 15, /*next hop*/ Ipv4Address ("1.1.1.1"), /*lifetime*/ Seconds (-10));
623  NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt4), true, "trivial");
624  NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("5.5.5.5"), INVALID), true, "trivial");
625  NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("5.5.5.5"), rt), false, "trivial");
626  NS_TEST_EXPECT_MSG_EQ (rtable.MarkLinkAsUnidirectional (Ipv4Address ("1.2.3.4"), Seconds (2)), true, "trivial");
627  NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("1.2.3.4"), rt), true, "trivial");
628  NS_TEST_EXPECT_MSG_EQ (rt.IsUnidirectional (), true, "trivial");
629  rt.SetLifeTime (Seconds (-5));
630  NS_TEST_EXPECT_MSG_EQ (rtable.Update (rt), true, "trivial");
631  std::map<Ipv4Address, uint32_t> unreachable;
632  rtable.GetListOfDestinationWithNextHop (Ipv4Address ("1.1.1.1"), unreachable);
633  NS_TEST_EXPECT_MSG_EQ (unreachable.size (), 2, "trivial");
634  unreachable.insert (std::make_pair (Ipv4Address ("4.3.2.1"), 3));
635  rtable.InvalidateRoutesWithDst (unreachable);
636  NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("4.3.2.1"), rt), true, "trivial");
637  NS_TEST_EXPECT_MSG_EQ (rt.GetFlag (), INVALID, "trivial");
638  NS_TEST_EXPECT_MSG_EQ (rtable.DeleteRoute (Ipv4Address ("1.2.3.4")), true, "trivial");
639  NS_TEST_EXPECT_MSG_EQ (rtable.DeleteRoute (Ipv4Address ("1.2.3.4")), false, "trivial");
641  }
642 };
643 
650 class AodvTestSuite : public TestSuite
651 {
652 public:
653  AodvTestSuite () : TestSuite ("routing-aodv", UNIT)
654  {
665  }
667 
668 } // namespace aodv
669 } // namespace ns3
ns3::aodv::RrepHeader::GetLifeTime
Time GetLifeTime() const
Get the lifetime.
Definition: aodv-packet.cc:385
ns3::aodv::RequestQueue::SetQueueTimeout
void SetQueueTimeout(Time t)
Set queue timeout.
Definition: aodv-rqueue.h:254
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::aodv::RreqHeader::SetDestinationOnly
void SetDestinationOnly(bool f)
Set the Destination only flag.
Definition: aodv-packet.cc:249
ns3::aodv::AodvRtableEntryTest
Unit test for AODV routing table entry.
Definition: aodv-test-suite.cc:505
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
ns3::aodv::Neighbors::Update
void Update(Ipv4Address addr, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry.
Definition: aodv-neighbor.cc:78
ns3::aodv::RoutingTableEntry::IsUnidirectional
bool IsUnidirectional() const
Get the unidirectional flag.
Definition: aodv-rtable.h:308
ns3::aodv::TypeHeader::Get
MessageType Get() const
Definition: aodv-packet.h:80
ns3::aodv::RoutingTableEntry::GetNextHop
Ipv4Address GetNextHop() const
Get next hop address.
Definition: aodv-rtable.h:157
ns3::aodv::RoutingTable::InvalidateRoutesWithDst
void InvalidateRoutesWithDst(std::map< Ipv4Address, uint32_t > const &unreachable)
Update routing entries with this destination as follows:
Definition: aodv-rtable.cc:344
ns3::aodv::QueueEntry::GetExpireTime
Time GetExpireTime() const
Get expire time.
Definition: aodv-rqueue.h:157
ns3::aodv::RreqHeader::SetOriginSeqno
void SetOriginSeqno(uint32_t s)
Set the origin sequence number.
Definition: aodv-packet.h:247
ns3::aodv::NeighborTest::CheckTimeout3
void CheckTimeout3()
Check timeout function 3.
Definition: aodv-test-suite.cc:80
ns3::aodv::RoutingTableEntry::SetValidSeqNo
void SetValidSeqNo(bool s)
Set the valid sequence number.
Definition: aodv-rtable.h:197
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
ns3::Socket::SocketErrno
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::aodv::TypeHeader::IsValid
bool IsValid() const
Check that type if valid.
Definition: aodv-packet.h:88
ns3::aodv::RrepHeader::GetHopCount
uint8_t GetHopCount() const
Get the hop count.
Definition: aodv-packet.h:375
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::aodv::AodvRqueueTest::CheckTimeout
void CheckTimeout()
Check timeout function.
Definition: aodv-test-suite.cc:493
ns3::aodv::RequestQueue::DropPacketWithDst
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
Definition: aodv-rqueue.cc:72
ns3::aodv::NeighborTest::CheckTimeout2
void CheckTimeout2()
Check timeout function 2.
Definition: aodv-test-suite.cc:72
ns3::aodv::AODVTYPE_RREP
@ AODVTYPE_RREP
AODVTYPE_RREP.
Definition: aodv-packet.h:48
ns3::aodv::RrepHeaderTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:202
ns3::aodv::VALID
@ VALID
VALID.
Definition: aodv-rtable.h:50
ns3::aodv::AodvRqueueTest::Unicast
void Unicast(Ptr< Ipv4Route > route, Ptr< const Packet > packet, const Ipv4Header &header)
Unicast test function.
Definition: aodv-test-suite.cc:390
ns3::aodv::RoutingTable::Update
bool Update(RoutingTableEntry &rt)
Update routing table.
Definition: aodv-rtable.cc:290
ns3::aodv::RoutingTableEntry::SetInterface
void SetInterface(Ipv4InterfaceAddress iface)
Set the Ipv4InterfaceAddress.
Definition: aodv-rtable.h:189
ns3::aodv::RoutingTableEntry::GetRreqCnt
uint8_t GetRreqCnt() const
Get the RREQ count.
Definition: aodv-rtable.h:285
ns3::aodv::RoutingTable::GetBadLinkLifetime
Time GetBadLinkLifetime() const
Get the lifetime of a bad link.
Definition: aodv-rtable.h:404
ns3::aodv::RrepHeader::SetHello
void SetHello(Ipv4Address src, uint32_t srcSeqNo, Time lifetime)
Configure RREP to be a Hello message.
Definition: aodv-packet.cc:431
ns3::aodv::NeighborTest::Handler
void Handler(Ipv4Address addr)
Handler test function.
Definition: aodv-test-suite.cc:59
ns3::aodv::RrepHeader::GetOrigin
Ipv4Address GetOrigin() const
Get the origin address.
Definition: aodv-packet.h:423
ns3::aodv::RreqHeaderTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:149
ns3::aodv::RoutingTableEntry::GetValidSeqNo
bool GetValidSeqNo() const
Get the valid sequence number.
Definition: aodv-rtable.h:205
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::aodv::RoutingTableEntry::GetBlacklistTimeout
Time GetBlacklistTimeout() const
Get the blacklist timeout value.
Definition: aodv-rtable.h:324
ns3::aodv::RrepAckHeaderTest
Unit test for RREP-ACK.
Definition: aodv-test-suite.cc:250
ns3::aodv::RrepHeader::SetOrigin
void SetOrigin(Ipv4Address a)
Set the origin address.
Definition: aodv-packet.h:415
ns3::aodv::RrepHeaderTest
Unit test for RREP.
Definition: aodv-test-suite.cc:198
ns3::aodv::RrepHeader::GetDst
Ipv4Address GetDst() const
Get the destination address.
Definition: aodv-packet.h:391
ns3::aodv::RequestQueue::Dequeue
bool Dequeue(Ipv4Address dst, QueueEntry &entry)
Return first found (the earliest) entry for given destination.
Definition: aodv-rqueue.cc:90
ns3::aodv::IN_SEARCH
@ IN_SEARCH
IN_SEARCH.
Definition: aodv-rtable.h:52
ns3::aodv::NeighborTest::NeighborTest
NeighborTest()
Definition: aodv-test-suite.cc:38
ns3::aodv::RreqHeader::GetHopCount
uint8_t GetHopCount() const
Get the hop count.
Definition: aodv-packet.h:175
ns3::aodv::AodvTestSuite::AodvTestSuite
AodvTestSuite()
Definition: aodv-test-suite.cc:653
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
ns3::aodv::AodvRqueueTest::q
RequestQueue q
Request queue.
Definition: aodv-test-suite.cc:408
ns3::aodv::RrepHeader::SetDst
void SetDst(Ipv4Address a)
Set the destination address.
Definition: aodv-packet.h:383
ns3::aodv::RoutingTableEntry::SetUnidirectional
void SetUnidirectional(bool u)
Set the unidirectional flag.
Definition: aodv-rtable.h:300
ns3::aodv::RoutingTableEntry
Routing table entry.
Definition: aodv-rtable.h:60
ns3::aodv::QueueEntry::SetErrorCallback
void SetErrorCallback(ErrorCallback ecb)
Set error callback.
Definition: aodv-rqueue.h:109
ns3::aodv::RerrHeader::AddUnDestination
bool AddUnDestination(Ipv4Address dst, uint32_t seqNo)
Add unreachable node address and its sequence number in RERR header.
Definition: aodv-packet.cc:619
ns3::aodv::RrepHeader::SetHopCount
void SetHopCount(uint8_t count)
Set the hop count.
Definition: aodv-packet.h:367
ns3::aodv::RreqHeader::SetDstSeqno
void SetDstSeqno(uint32_t s)
Set the destination sequence number.
Definition: aodv-packet.h:215
ns3::TestCase
encapsulates test code
Definition: test.h:1154
ns3::aodv::QueueEntryTest::Error
void Error(Ptr< const Packet > p, const Ipv4Header &h, Socket::SocketErrno e)
Error test function.
Definition: aodv-test-suite.cc:325
ns3::aodv::RreqHeader::GetUnknownSeqno
bool GetUnknownSeqno() const
Get the unknown sequence number flag.
Definition: aodv-packet.cc:281
ns3::aodv::QueueEntry::GetUnicastForwardCallback
UnicastForwardCallback GetUnicastForwardCallback() const
Get unicast forward callback.
Definition: aodv-rqueue.h:85
ns3::aodv::RrepHeader::GetAckRequired
bool GetAckRequired() const
get the ack required flag
Definition: aodv-packet.cc:405
ns3::aodv::AodvRqueueTest::AodvRqueueTest
AodvRqueueTest()
Definition: aodv-test-suite.cc:379
ns3::Ptr< Packet >
ns3::aodv::QueueEntry::SetUnicastForwardCallback
void SetUnicastForwardCallback(UnicastForwardCallback ucb)
Set unicast forward callback.
Definition: aodv-rqueue.h:93
ns3::aodv::RoutingTableEntry::SetRreqCnt
void SetRreqCnt(uint8_t n)
Set the RREQ count.
Definition: aodv-rtable.h:277
ns3::aodv::RreqHeader::SetGratuitousRrep
void SetGratuitousRrep(bool f)
Set the gratuitous RREP flag.
Definition: aodv-packet.cc:230
ns3::aodv::RequestQueue::Find
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue.
Definition: aodv-rqueue.cc:106
ns3::aodv::QueueEntryTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:346
ns3::aodv::RreqHeader
Route Request (RREQ) Message Format.
Definition: aodv-packet.h:132
ns3::aodv::TypeHeader
AODV types.
Definition: aodv-packet.h:58
ns3::aodv::RerrHeaderTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:277
ns3::aodv::RerrHeaderTest
Unit test for RERR.
Definition: aodv-test-suite.cc:273
ns3::aodv::RreqHeaderTest
Unit test for RREQ.
Definition: aodv-test-suite.cc:145
ns3::aodv::RoutingTableEntry::GetRoute
Ptr< Ipv4Route > GetRoute() const
Get route function.
Definition: aodv-rtable.h:133
ns3::aodv::AodvRqueueTest
Unit test for RequestQueue.
Definition: aodv-test-suite.cc:378
ns3::aodv::RerrHeader
Route Error (RERR) Message Format.
Definition: aodv-packet.h:558
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition: ipv4-interface-address.h:44
ns3::aodv::RoutingTableEntry::Invalidate
void Invalidate(Time badLinkLifetime)
Mark entry as "down" (i.e.
Definition: aodv-rtable.cc:161
ns3::aodv::AodvRtableTest::AodvRtableTest
AodvRtableTest()
Definition: aodv-test-suite.cc:592
ns3::aodv::QueueEntry::SetExpireTime
void SetExpireTime(Time exp)
Set expire time.
Definition: aodv-rqueue.h:149
ns3::aodv::RrepHeader::SetDstSeqno
void SetDstSeqno(uint32_t s)
Set the destination sequence number.
Definition: aodv-packet.h:399
ns3::aodv::RerrHeaderTest::RerrHeaderTest
RerrHeaderTest()
Definition: aodv-test-suite.cc:274
ns3::aodv::AodvRqueueTest::Error
void Error(Ptr< const Packet > p, const Ipv4Header &h, Socket::SocketErrno e)
Error test function.
Definition: aodv-test-suite.cc:399
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
ns3::aodv::TypeHeaderTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:123
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
ns3::aodv::RreqHeader::GetGratuitousRrep
bool GetGratuitousRrep() const
Get the gratuitous RREP flag.
Definition: aodv-packet.cc:243
ns3::aodv::RequestQueue::GetSize
uint32_t GetSize()
Definition: aodv-rqueue.cc:41
ns3::aodv::AODVTYPE_RREQ
@ AODVTYPE_RREQ
AODVTYPE_RREQ.
Definition: aodv-packet.h:47
ns3::aodv::RoutingTableEntry::GetLifeTime
Time GetLifeTime() const
Get the lifetime.
Definition: aodv-rtable.h:253
ns3::aodv::RequestQueue
AODV route request queue.
Definition: aodv-rqueue.h:181
ns3::aodv::QueueEntry::GetIpv4Header
Ipv4Header GetIpv4Header() const
Get IPv4 header.
Definition: aodv-rqueue.h:133
ns3::aodv::RerrHeader::GetNoDelete
bool GetNoDelete() const
Get the no delete flag.
Definition: aodv-packet.cc:613
ns3::aodv::AodvRtableEntryTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:509
ns3::aodv::RoutingTableEntry::GetHop
uint16_t GetHop() const
Get the number of hops.
Definition: aodv-rtable.h:237
ns3::aodv::QueueEntry::GetPacket
Ptr< const Packet > GetPacket() const
Get packet from entry.
Definition: aodv-rqueue.h:117
ns3::aodv::RoutingTable::SetEntryState
bool SetEntryState(Ipv4Address dst, RouteFlags state)
Set routing table entry flags.
Definition: aodv-rtable.cc:310
ns3::aodv::Neighbors::IsNeighbor
bool IsNeighbor(Ipv4Address addr)
Check that node with address addr is neighbor.
Definition: aodv-neighbor.cc:48
NS_TEST_EXPECT_MSG_EQ
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
ns3::aodv::RoutingTableEntry::SetBlacklistTimeout
void SetBlacklistTimeout(Time t)
Set the blacklist timeout.
Definition: aodv-rtable.h:316
ns3::aodv::RreqHeader::GetDestinationOnly
bool GetDestinationOnly() const
Get the Destination only flag.
Definition: aodv-packet.cc:262
ns3::aodv::NeighborTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:89
ns3::aodv::RoutingTableEntry::GetSeqNo
uint32_t GetSeqNo() const
Get the sequence number.
Definition: aodv-rtable.h:221
ns3::aodv::NeighborTest
Unit test for neighbors.
Definition: aodv-test-suite.cc:37
ns3::aodv::RreqHeader::SetUnknownSeqno
void SetUnknownSeqno(bool f)
Set the unknown sequence number flag.
Definition: aodv-packet.cc:268
ns3::aodv::RoutingTableEntry::DeletePrecursor
bool DeletePrecursor(Ipv4Address id)
Delete precursor.
Definition: aodv-rtable.cc:102
ns3::aodv::RequestQueue::SetMaxQueueLen
void SetMaxQueueLen(uint32_t len)
Set maximum queue length.
Definition: aodv-rqueue.h:238
ns3::Ipv4Header::SetSource
void SetSource(Ipv4Address source)
Definition: ipv4-header.cc:285
ns3::aodv::RrepHeader::GetPrefixSize
uint8_t GetPrefixSize() const
Set the pefix size.
Definition: aodv-packet.cc:417
ns3::aodv::QueueEntryTest::Unicast
void Unicast(Ptr< Ipv4Route > route, Ptr< const Packet > packet, const Ipv4Header &header)
Unicast test function.
Definition: aodv-test-suite.cc:316
ns3::aodv::RoutingTableEntry::GetOutputDevice
Ptr< NetDevice > GetOutputDevice() const
Get output device.
Definition: aodv-rtable.h:173
ns3::MakeCallback
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
ns3::aodv::RoutingTableEntry::IsPrecursorListEmpty
bool IsPrecursorListEmpty() const
Check that precursor list is empty.
Definition: aodv-rtable.cc:128
ns3::Simulator::Run
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
ns3::aodv::g_aodvTestSuite
ns3::aodv::AodvTestSuite g_aodvTestSuite
the test suite
ns3::aodv::RrepHeader::SetLifeTime
void SetLifeTime(Time t)
Set the lifetime.
Definition: aodv-packet.cc:379
ns3::aodv::AodvRtableTest
Unit test for AODV routing table.
Definition: aodv-test-suite.cc:591
ns3::aodv::INVALID
@ INVALID
INVALID.
Definition: aodv-rtable.h:51
ns3::aodv::RrepAckHeaderTest::RrepAckHeaderTest
RrepAckHeaderTest()
Definition: aodv-test-suite.cc:251
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
ns3::aodv::RrepHeader
Route Reply (RREP) Message Format.
Definition: aodv-packet.h:336
ns3::aodv::RequestQueue::Enqueue
bool Enqueue(QueueEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue.
Definition: aodv-rqueue.cc:48
ns3::aodv::RoutingTable::GetListOfDestinationWithNextHop
void GetListOfDestinationWithNextHop(Ipv4Address nextHop, std::map< Ipv4Address, uint32_t > &unreachable)
Lookup routing entries with next hop Address dst and not empty list of precursors.
Definition: aodv-rtable.cc:327
ns3::aodv::RreqHeader::SetOrigin
void SetOrigin(Ipv4Address a)
Set the origin address.
Definition: aodv-packet.h:231
ns3::aodv::RreqHeader::GetDstSeqno
uint32_t GetDstSeqno() const
Get the destination sequence number.
Definition: aodv-packet.h:223
ns3::aodv::RreqHeaderTest::RreqHeaderTest
RreqHeaderTest()
Definition: aodv-test-suite.cc:146
ns3::aodv::RoutingTable::SetBadLinkLifetime
void SetBadLinkLifetime(Time t)
Set the lifetime of a bad link.
Definition: aodv-rtable.h:413
ns3::aodv::RrepHeaderTest::RrepHeaderTest
RrepHeaderTest()
Definition: aodv-test-suite.cc:199
ns3::aodv::RrepHeader::GetDstSeqno
uint32_t GetDstSeqno() const
Get the destination sequence number.
Definition: aodv-packet.h:407
ns3::aodv::RoutingTable::MarkLinkAsUnidirectional
bool MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout)
Mark entry as unidirectional (e.g.
Definition: aodv-rtable.cc:462
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1353
ns3::aodv::RrepHeader::SetPrefixSize
void SetPrefixSize(uint8_t sz)
Set the prefix size.
Definition: aodv-packet.cc:411
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::aodv::NeighborTest::neighbor
Neighbors * neighbor
The Neighbors.
Definition: aodv-test-suite.cc:55
ns3::Ipv4Header::GetSource
Ipv4Address GetSource(void) const
Definition: ipv4-header.cc:291
ns3::aodv::RreqHeader::SetHopCount
void SetHopCount(uint8_t count)
Set the hop count.
Definition: aodv-packet.h:167
ns3::aodv::RrepAckHeaderTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:254
ns3::aodv::RerrHeader::GetDestCount
uint8_t GetDestCount() const
Definition: aodv-packet.h:604
ns3::Simulator::Destroy
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
ns3::aodv::RoutingTableEntry::SetHop
void SetHop(uint16_t hop)
Set the number of hops.
Definition: aodv-rtable.h:229
ns3::aodv::RequestQueue::GetMaxQueueLen
uint32_t GetMaxQueueLen() const
Get maximum queue length.
Definition: aodv-rqueue.h:230
ns3::aodv::RoutingTableEntry::LookupPrecursor
bool LookupPrecursor(Ipv4Address id)
Lookup precursor by address.
Definition: aodv-rtable.cc:85
ns3::aodv::RoutingTableEntry::InsertPrecursor
bool InsertPrecursor(Ipv4Address id)
Insert precursor in precursor list if it doesn't yet exist in the list.
Definition: aodv-rtable.cc:70
ns3::aodv::RoutingTableEntry::GetFlag
RouteFlags GetFlag() const
Get the route flags.
Definition: aodv-rtable.h:269
ns3::aodv::RreqHeader::GetOriginSeqno
uint32_t GetOriginSeqno() const
Get the origin sequence number.
Definition: aodv-packet.h:255
ns3::aodv::RreqHeader::GetOrigin
Ipv4Address GetOrigin() const
Get the origin address.
Definition: aodv-packet.h:239
ns3::aodv::RoutingTable
The Routing table used by AODV protocol.
Definition: aodv-rtable.h:390
ns3::aodv::RoutingTable::DeleteRoute
bool DeleteRoute(Ipv4Address dst)
Delete routing table entry with destination address dst, if it exists.
Definition: aodv-rtable.cc:262
ns3::aodv::RreqHeader::GetDst
Ipv4Address GetDst() const
Get the destination address.
Definition: aodv-packet.h:207
ns3::aodv::QueueEntryTest::Error2
void Error2(Ptr< const Packet > p, const Ipv4Header &h, Socket::SocketErrno e)
Error2 test function.
Definition: aodv-test-suite.cc:343
ns3::aodv::QueueEntry::GetErrorCallback
ErrorCallback GetErrorCallback() const
Get error callback.
Definition: aodv-rqueue.h:101
ns3::aodv::NeighborTest::CheckTimeout1
void CheckTimeout1()
Check timeout function 1.
Definition: aodv-test-suite.cc:64
ns3::aodv::TypeHeaderTest::TypeHeaderTest
TypeHeaderTest()
Definition: aodv-test-suite.cc:120
ns3::aodv::RreqHeader::SetId
void SetId(uint32_t id)
Set the request ID.
Definition: aodv-packet.h:183
ns3::aodv::RoutingTableEntry::DeleteAllPrecursors
void DeleteAllPrecursors()
Delete all precursors.
Definition: aodv-rtable.cc:121
ns3::aodv::Neighbors::SetCallback
void SetCallback(Callback< void, Ipv4Address > cb)
Set link failure callback.
Definition: aodv-neighbor.h:137
ns3::aodv::AodvRtableEntryTest::AodvRtableEntryTest
AodvRtableEntryTest()
Definition: aodv-test-suite.cc:506
ns3::aodv::RerrHeader::SetNoDelete
void SetNoDelete(bool f)
Set the no delete flag.
Definition: aodv-packet.cc:600
ns3::aodv::QueueEntry
AODV Queue Entry.
Definition: aodv-rqueue.h:44
ns3::aodv::RoutingTableEntry::GetDestination
Ipv4Address GetDestination() const
Get destination address function.
Definition: aodv-rtable.h:125
ns3::aodv::RrepAckHeader
Route Reply Acknowledgment (RREP-ACK) Message Format.
Definition: aodv-packet.h:504
ns3::Callback::IsEqual
bool IsEqual(const CallbackBase &other) const
Equality test.
Definition: callback.h:1521
ns3::aodv::RrepHeader::SetAckRequired
void SetAckRequired(bool f)
Set the ack required flag.
Definition: aodv-packet.cc:392
ns3::aodv::RoutingTableEntry::SetNextHop
void SetNextHop(Ipv4Address nextHop)
Set next hop address.
Definition: aodv-rtable.h:149
ns3::aodv::RreqHeader::GetId
uint32_t GetId() const
Get the request ID.
Definition: aodv-packet.h:191
ns3::TestCase::QUICK
@ QUICK
Fast test.
Definition: test.h:1159
ns3::aodv::AodvRqueueTest::CheckSizeLimit
void CheckSizeLimit()
Check size limit function.
Definition: aodv-test-suite.cc:471
ns3::aodv::RoutingTableEntry::SetLifeTime
void SetLifeTime(Time lt)
Set the lifetime.
Definition: aodv-rtable.h:245
ns3::aodv::RoutingTableEntry::IncrementRreqCnt
void IncrementRreqCnt()
Increment the RREQ count.
Definition: aodv-rtable.h:292
ns3::Ipv4Header::SetDestination
void SetDestination(Ipv4Address destination)
Definition: ipv4-header.cc:298
ns3::aodv::QueueEntryTest::Unicast2
void Unicast2(Ptr< Ipv4Route > route, Ptr< const Packet > packet, const Ipv4Header &header)
Unicast 2 testfunction.
Definition: aodv-test-suite.cc:334
ns3::aodv::AodvTestSuite
AODV test suite.
Definition: aodv-test-suite.cc:651
ns3::aodv::RoutingTableEntry::GetPrecursors
void GetPrecursors(std::vector< Ipv4Address > &prec) const
Inserts precursors in output parameter prec if they do not yet exist in vector.
Definition: aodv-rtable.cc:134
ns3::Ipv4Header::GetDestination
Ipv4Address GetDestination(void) const
Definition: ipv4-header.cc:304
ns3::aodv::RoutingTable::AddRoute
bool AddRoute(RoutingTableEntry &r)
Add routing table entry if it doesn't yet exist in routing table.
Definition: aodv-rtable.cc:276
ns3::aodv::AodvRqueueTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:412
ns3::aodv::RequestQueue::GetQueueTimeout
Time GetQueueTimeout() const
Get queue timeout.
Definition: aodv-rqueue.h:246
ns3::aodv::QueueEntryTest::QueueEntryTest
QueueEntryTest()
Definition: aodv-test-suite.cc:307
ns3::aodv::RoutingTableEntry::SetFlag
void SetFlag(RouteFlags flag)
Set the route flags.
Definition: aodv-rtable.h:261
ns3::aodv::Neighbors
maintain list of active neighbors
Definition: aodv-neighbor.h:52
ns3::aodv::RoutingTableEntry::GetInterface
Ipv4InterfaceAddress GetInterface() const
Get the Ipv4InterfaceAddress.
Definition: aodv-rtable.h:181
ns3::aodv::RoutingTable::LookupRoute
bool LookupRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup routing table entry with destination address dst.
Definition: aodv-rtable.cc:227
ns3::aodv::QueueEntry::SetIpv4Header
void SetIpv4Header(Ipv4Header h)
Set IPv4 header.
Definition: aodv-rqueue.h:141
ns3::aodv::Neighbors::GetExpireTime
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0.
Definition: aodv-neighbor.cc:63
ns3::aodv::QueueEntryTest
Unit test for AODV routing table entry.
Definition: aodv-test-suite.cc:306
ns3::aodv::TypeHeaderTest
Type header test case.
Definition: aodv-test-suite.cc:119
ns3::aodv::RoutingTableEntry::SetOutputDevice
void SetOutputDevice(Ptr< NetDevice > dev)
Set output device.
Definition: aodv-rtable.h:165
ns3::aodv::RreqHeader::SetDst
void SetDst(Ipv4Address a)
Set the destination address.
Definition: aodv-packet.h:199
ns3::aodv::AodvRtableTest::DoRun
virtual void DoRun()
Implementation to actually run this TestCase.
Definition: aodv-test-suite.cc:595
ns3::aodv::RerrHeader::GetSerializedSize
uint32_t GetSerializedSize() const
Definition: aodv-packet.cc:546