A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
neighbor-cache-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 ZHIHENG DONG
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Zhiheng Dong <dzh2077@gmail.com>
18 */
19
20#include "ns3/icmpv4-l4-protocol.h"
21#include "ns3/icmpv6-l4-protocol.h"
22#include "ns3/internet-stack-helper.h"
23#include "ns3/ipv4-address-helper.h"
24#include "ns3/ipv4-l3-protocol.h"
25#include "ns3/ipv4-routing-helper.h"
26#include "ns3/ipv6-address-helper.h"
27#include "ns3/ipv6-l3-protocol.h"
28#include "ns3/ipv6-routing-helper.h"
29#include "ns3/neighbor-cache-helper.h"
30#include "ns3/simple-channel.h"
31#include "ns3/simple-net-device-helper.h"
32#include "ns3/simple-net-device.h"
33#include "ns3/simulator.h"
34#include "ns3/socket-factory.h"
35#include "ns3/socket.h"
36#include "ns3/test.h"
37#include "ns3/udp-l4-protocol.h"
38#include "ns3/udp-socket-factory.h"
39
40using namespace ns3;
41
42/**
43 * \ingroup internet-test
44 *
45 * \brief Dynamic Neighbor Cache Test
46 */
48{
49 Ptr<Packet> m_receivedPacket; //!< Received packet
50
51 /**
52 * \brief Send data immediately after being called.
53 * \param socket The sending socket.
54 * \param to IPv4 Destination address.
55 */
56 void DoSendDatav4(Ptr<Socket> socket, Ipv4Address to);
57
58 /**
59 * \brief Send data immediately after being called.
60 * \param socket The sending socket.
61 * \param to IPv6 Destination address.
62 */
63 void DoSendDatav6(Ptr<Socket> socket, Ipv6Address to);
64
65 /**
66 * \brief Schedules the DoSendData () function to send the data.
67 * \param socket The sending socket.
68 * \param to IPv4 Destination address.
69 */
70 void SendData(Ptr<Socket> socket, Ipv4Address to);
71
72 /**
73 * \brief Schedules the DoSendData () function to send the data.
74 * \param socket The sending socket.
75 * \param to IPv6 Destination address.
76 */
77 void SendData(Ptr<Socket> socket, Ipv6Address to);
78
79 /**
80 * \brief Add an IPv4 address to an IPv4 interface
81 * \param ipv4Interface The interface that address will be added.
82 * \param ifaceAddr The added IPv4 address.
83 */
84 void AddIpv4Address(Ptr<Ipv4Interface> ipv4Interface, Ipv4InterfaceAddress ifaceAddr);
85
86 /**
87 * \brief Add an IPv6 address to an IPv6 interface
88 * \param ipv6Interface The interface that address will be added.
89 * \param ifaceAddr The added IPv6 address.
90 */
91 void AddIpv6Address(Ptr<Ipv6Interface> ipv6Interface, Ipv6InterfaceAddress ifaceAddr);
92
93 /**
94 * \brief Remove an IPv4 address from an IPv4 interface
95 * \param ipv4Interface The interface that address will be removed from.
96 * \param index The index of IPv4 address that will be removed.
97 */
98 void RemoveIpv4Address(Ptr<Ipv4Interface> ipv4Interface, uint32_t index);
99
100 /**
101 * \brief Remove an IPv6 address from an IPv6 interface
102 * \param ipv6Interface The interface that address will be removed from.
103 * \param index The index of IPv6 address that will be removed.
104 */
105 void RemoveIpv6Address(Ptr<Ipv6Interface> ipv6Interface, uint32_t index);
106
107 public:
108 void DoRun() override;
109
111
112 /**
113 * \brief Receive data.
114 * \param socket The receiving socket.
115 */
116 void ReceivePkt(Ptr<Socket> socket);
117
118 std::vector<uint32_t> m_receivedPacketSizes; //!< Received packet sizes
119};
120
122 : TestCase(
123 "The DynamicNeighborCacheTestPopulate checks if neighbor caches are correctly populated "
124 "in global scope and updated when there is an IP address added or removed.")
125{
126}
127
128void
130{
131 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
132 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
133 NS_TEST_ASSERT_MSG_EQ(availableData,
135 "Received Packet size is not equal to the Rx buffer size");
137}
138
139void
141{
142 Address realTo = InetSocketAddress(to, 1234);
143 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
144}
145
146void
148{
149 Address realTo = Inet6SocketAddress(to, 1234);
150 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
151}
152
153void
155{
156 m_receivedPacket = Create<Packet>();
157 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
158 Seconds(60),
160 this,
161 socket,
162 to);
163}
164
165void
167{
168 m_receivedPacket = Create<Packet>();
169 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
170 Seconds(60),
172 this,
173 socket,
174 to);
175}
176
177void
179 Ipv4InterfaceAddress ifaceAddr)
180{
181 ipv4Interface->AddAddress(ifaceAddr);
182}
183
184void
186 Ipv6InterfaceAddress ifaceAddr)
187{
188 ipv6Interface->AddAddress(ifaceAddr);
189}
190
191void
193{
194 ipv4Interface->RemoveAddress(index);
195}
196
197void
199{
200 ipv6Interface->RemoveAddress(index);
201}
202
203void
205{
206 Ptr<Node> tx1Node = CreateObject<Node>();
207 Ptr<Node> tx2Node = CreateObject<Node>();
208 Ptr<Node> rxNode = CreateObject<Node>();
209 Ptr<Node> snifferNode = CreateObject<Node>();
210
211 NodeContainer all(tx1Node, tx2Node, rxNode, snifferNode);
212
213 std::ostringstream stringStream1v4;
214 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
215 std::ostringstream stringStream1v6;
216 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
217
218 InternetStackHelper internetNodes;
219 internetNodes.Install(all);
220
222 // Sender Node
224 {
225 tx1Dev = CreateObject<SimpleNetDevice>();
226 tx1Dev->SetAddress(Mac48Address("00:00:00:00:00:01"));
227 tx1Node->AddDevice(tx1Dev);
228 }
229 net.Add(tx1Dev);
230
232 {
233 tx2Dev = CreateObject<SimpleNetDevice>();
234 tx2Dev->SetAddress(Mac48Address("00:00:00:00:00:02"));
235 tx2Node->AddDevice(tx2Dev);
236 }
237 net.Add(tx2Dev);
238
239 // Receive node
241 {
242 rxDev = CreateObject<SimpleNetDevice>();
243 rxDev->SetAddress(Mac48Address("00:00:00:00:00:03"));
244 rxNode->AddDevice(rxDev);
245 }
246 net.Add(rxDev);
247
248 // Sniffer node
249 Ptr<SimpleNetDevice> snifferDev;
250 {
251 snifferDev = CreateObject<SimpleNetDevice>();
252 snifferDev->SetAddress(Mac48Address("00:00:00:00:00:04"));
253 snifferNode->AddDevice(snifferDev);
254 }
255 net.Add(snifferDev);
256
257 // link the channels
258 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
259 tx1Dev->SetChannel(channel);
260 tx2Dev->SetChannel(channel);
261 rxDev->SetChannel(channel);
262 snifferDev->SetChannel(channel);
263
264 // Setup IPv4 addresses
266 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
267 Ipv4InterfaceContainer icv4 = ipv4.Assign(net);
268
269 // Add address 10.1.1.5 to rxNode in 0.5 seconds
270 Ptr<Node> n1 = rxNode;
271 uint32_t ipv4ifIndex = 1;
272 Ptr<Ipv4Interface> ipv4Interface = n1->GetObject<Ipv4L3Protocol>()->GetInterface(ipv4ifIndex);
273 Ipv4InterfaceAddress ifaceAddr = Ipv4InterfaceAddress("10.0.1.5", "255.255.255.0");
276 this,
277 ipv4Interface,
278 ifaceAddr);
279
280 // Remove the first address (10.1.1.3) from rxNode in 1.5 seconds
281 uint32_t addressIndex = 0;
284 this,
285 ipv4Interface,
286 addressIndex);
287
288 // Setup IPv6 addresses
290 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
291 Ipv6InterfaceContainer icv6 = ipv6.Assign(net);
292
293 // Add address 2001:1::200:ff:fe00:5 to rxNode in 0.5 seconds
294 uint32_t ipv6ifIndex = 1;
295 Ptr<Ipv6Interface> ipv6Interface = n1->GetObject<Ipv6L3Protocol>()->GetInterface(ipv6ifIndex);
296 Ipv6InterfaceAddress ifaceAddrv6 =
297 Ipv6InterfaceAddress("2001:0::200:ff:fe00:5", Ipv6Prefix(64));
300 this,
301 ipv6Interface,
302 ifaceAddrv6);
303
304 // Remove the second address (2001:1::200:ff:fe00:3) from rxNode in 1.5 seconds
305 addressIndex = 1;
308 this,
309 ipv6Interface,
310 addressIndex);
311
312 // Populate neighbor caches.
313 NeighborCacheHelper neighborCache;
314 neighborCache.SetDynamicNeighborCache(true);
315 neighborCache.PopulateNeighborCache();
316
317 // Print cache.
324
325 // Create the UDP sockets
326 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
327 Ptr<Socket> rxSocketv4 = rxSocketFactory->CreateSocket();
328 Ptr<Socket> rxSocketv6 = rxSocketFactory->CreateSocket();
329 NS_TEST_EXPECT_MSG_EQ(rxSocketv4->Bind(InetSocketAddress(Ipv4Address("10.0.1.5"), 1234)),
330 0,
331 "trivial");
333 rxSocketv6->Bind(Inet6SocketAddress(Ipv6Address("2001:0::200:ff:fe00:5"), 1234)),
334 0,
335 "trivial");
336 rxSocketv4->SetRecvCallback(MakeCallback(&DynamicNeighborCacheTest::ReceivePkt, this));
337 rxSocketv6->SetRecvCallback(MakeCallback(&DynamicNeighborCacheTest::ReceivePkt, this));
338
339 Ptr<SocketFactory> snifferSocketFactory = snifferNode->GetObject<UdpSocketFactory>();
340 Ptr<Socket> snifferSocketv4 = snifferSocketFactory->CreateSocket();
341 Ptr<Socket> snifferSocketv6 = snifferSocketFactory->CreateSocket();
342 NS_TEST_EXPECT_MSG_EQ(snifferSocketv4->Bind(InetSocketAddress(Ipv4Address("10.0.1.4"), 1234)),
343 0,
344 "trivial");
346 snifferSocketv6->Bind(Inet6SocketAddress(Ipv6Address("2001:0::200:ff:fe00:4"), 1234)),
347 0,
348 "trivial");
349 snifferSocketv4->SetRecvCallback(MakeCallback(&DynamicNeighborCacheTest::ReceivePkt, this));
350 snifferSocketv6->SetRecvCallback(MakeCallback(&DynamicNeighborCacheTest::ReceivePkt, this));
351
352 Ptr<SocketFactory> tx1SocketFactory = tx1Node->GetObject<UdpSocketFactory>();
353 Ptr<Socket> tx1Socket = tx1SocketFactory->CreateSocket();
354 tx1Socket->SetAllowBroadcast(true);
355
356 Ptr<SocketFactory> tx2SocketFactory = tx2Node->GetObject<UdpSocketFactory>();
357 Ptr<Socket> tx2Socket = tx2SocketFactory->CreateSocket();
358 tx2Socket->SetAllowBroadcast(true);
359
360 // ------ Now the tests ------------
361
362 // Unicast test
363
364 // send data to the added address
365 SendData(tx1Socket, Ipv4Address("10.0.1.5"));
366 SendData(tx1Socket, Ipv6Address("2001:0::200:ff:fe00:5"));
367
368 // send data to the removed address
369 SendData(tx1Socket, Ipv4Address("10.0.1.3"));
370 SendData(tx1Socket, Ipv6Address("2001:0::200:ff:fe00:3"));
371
374
375 // Check if all packet are correctly received.
377 123,
378 "Should receive packet sending to the added IPv4 address.");
380 123,
381 "Should receive packet sending to the added IPv6 address.");
384 2,
385 "Should receive only 1 packet from IPv4 interface and only 1 packet from IPv6 interface.");
386
387 // Check if the arp caches are populated correctly at time 0,
388 // Check if the arp caches are updated correctly at time 1 after new IP address is added,
389 // Check if the arp caches are updated correctly at time 2 after an IP address is removed.
390 constexpr auto arpCache =
391 "ARP Cache of node 0 at time 0\n"
392 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
393 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
394 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
395 "ARP Cache of node 1 at time 0\n"
396 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
397 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
398 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
399 "ARP Cache of node 2 at time 0\n"
400 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
401 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
402 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
403 "ARP Cache of node 3 at time 0\n"
404 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
405 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
406 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
407 "ARP Cache of node 0 at time 1\n"
408 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
409 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
410 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
411 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
412 "ARP Cache of node 1 at time 1\n"
413 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
414 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
415 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
416 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
417 "ARP Cache of node 2 at time 1\n"
418 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
419 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
420 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
421 "ARP Cache of node 3 at time 1\n"
422 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
423 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
424 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
425 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
426 "ARP Cache of node 0 at time 2\n"
427 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
428 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
429 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
430 "ARP Cache of node 1 at time 2\n"
431 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
432 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
433 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
434 "ARP Cache of node 2 at time 2\n"
435 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
436 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
437 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
438 "ARP Cache of node 3 at time 2\n"
439 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
440 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
441 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
442 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
443
444 // Check if the ndisc caches are populated correctly at time 0,
445 // Check if the ndisc caches are updated correctly at time 1 after new IP address is added,
446 // Check if the ndisc caches are updated correctly at time 2 after an IP address is removed.
447 constexpr auto NdiscCache =
448 "NDISC Cache of node 0 at time +0s\n"
449 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
450 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
451 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
452 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
453 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
454 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
455 "NDISC Cache of node 1 at time +0s\n"
456 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
457 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
458 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
459 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
460 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
461 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
462 "NDISC Cache of node 2 at time +0s\n"
463 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
464 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
465 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
466 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
467 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
468 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
469 "NDISC Cache of node 3 at time +0s\n"
470 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
471 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
472 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
473 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
474 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
475 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
476 "NDISC Cache of node 0 at time +1s\n"
477 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
478 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
479 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
480 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
481 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
482 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
483 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
484 "NDISC Cache of node 1 at time +1s\n"
485 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
486 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
487 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
488 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
489 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
490 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
491 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
492 "NDISC Cache of node 2 at time +1s\n"
493 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
494 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
495 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
496 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
497 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
498 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
499 "NDISC Cache of node 3 at time +1s\n"
500 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
501 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
502 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
503 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
504 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
505 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
506 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
507 "NDISC Cache of node 0 at time +2s\n"
508 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
509 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
510 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
511 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
512 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
513 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
514 "NDISC Cache of node 1 at time +2s\n"
515 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
516 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
517 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
518 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
519 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
520 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
521 "NDISC Cache of node 2 at time +2s\n"
522 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
523 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
524 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
525 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
526 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
527 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
528 "NDISC Cache of node 3 at time +2s\n"
529 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
530 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
531 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
532 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
533 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
534 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
535 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
536
538
540}
541
542/**
543 * \ingroup internet-test
544 *
545 * \brief Neighbor cache on Channel Test
546 */
547class ChannelTest : public TestCase
548{
549 public:
550 void DoRun() override;
551 ChannelTest();
552
553 private:
554 NodeContainer m_nodes; //!< Nodes used in the test.
555};
556
558 : TestCase(
559 "The ChannelTest Check if neighbor caches are correctly populated on specific channel.")
560{
561}
562
563void
565{
566 m_nodes.Create(3);
567
568 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
569 SimpleNetDeviceHelper simpleHelper;
570 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
571 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
572
573 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
574 SimpleNetDeviceHelper simpleHelper2;
575 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
576 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
577
578 InternetStackHelper internet;
579 internet.Install(m_nodes);
580
581 // Setup IPv4 addresses
583 ipv4.SetBase("10.1.1.0", "255.255.255.252");
584 Ipv4InterfaceContainer i = ipv4.Assign(net);
585 ipv4.SetBase("10.1.2.0", "255.255.255.252");
586 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
587
588 // Setup IPv6 addresses
590 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
591 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
592 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
593 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
594
595 // Populate neighbor caches on the first channel
596 NeighborCacheHelper neighborCache;
597 neighborCache.PopulateNeighborCache(channel);
598
599 std::ostringstream stringStream1v4;
600 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
601 std::ostringstream stringStream1v6;
602 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
603
604 // Print cache.
607
609
610 // Check if arp caches are populated correctly in the first channel
611 constexpr auto arpCache = "ARP Cache of node 0 at time 0\n"
612 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
613 "ARP Cache of node 1 at time 0\n"
614 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
615 "ARP Cache of node 2 at time 0\n";
616 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
617
618 // Check if ndisc caches are populated correctly in the first channel
619 constexpr auto NdiscCache =
620 "NDISC Cache of node 0 at time +0s\n"
621 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
622 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
623 "NDISC Cache of node 1 at time +0s\n"
624 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
625 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
626 "NDISC Cache of node 2 at time +0s\n";
627 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
629}
630
631/**
632 * \ingroup internet-test
633 *
634 * \brief Neighbor Cache on NetDeviceContainer Test
635 */
637{
638 public:
639 void DoRun() override;
641
642 private:
643 NodeContainer m_nodes; //!< Nodes used in the test.
644};
645
647 : TestCase("The NetDeviceContainerTest check if neighbor caches are populated correctly on "
648 "specific netDeviceContainer.")
649{
650}
651
652void
654{
655 m_nodes.Create(3);
656
657 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
658 SimpleNetDeviceHelper simpleHelper;
659 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
660 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
661
662 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
663 SimpleNetDeviceHelper simpleHelper2;
664 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
665 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
666
667 InternetStackHelper internet;
668 internet.Install(m_nodes);
669
670 // Setup IPv4 addresses
672 ipv4.SetBase("10.1.1.0", "255.255.255.252");
673 Ipv4InterfaceContainer i = ipv4.Assign(net);
674 ipv4.SetBase("10.1.2.0", "255.255.255.252");
675 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
676
677 // Setup IPv6 addresses
679 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
680 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
681 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
682 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
683
684 // Populate neighbor caches on NetDeviceContainer net2.
685 NeighborCacheHelper neighborCache;
686 neighborCache.PopulateNeighborCache(net2);
687
688 std::ostringstream stringStream1v4;
689 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
690 std::ostringstream stringStream1v6;
691 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
692
693 // Print cache.
696
698
699 // Check if arp caches are populated correctly on NetDeviceContainer net2.
700 constexpr auto arpCache =
701 "ARP Cache of node 0 at time 0\n"
702 "ARP Cache of node 1 at time 0\n"
703 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
704 "ARP Cache of node 2 at time 0\n"
705 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
706 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
707
708 // Check if ndisc caches are populated correctly on NetDeviceContainer net2.
709 constexpr auto NdiscCache =
710 "NDISC Cache of node 0 at time +0s\n"
711 "NDISC Cache of node 1 at time +0s\n"
712 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
713 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
714 "NDISC Cache of node 2 at time +0s\n"
715 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
716 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
717 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
719}
720
721/**
722 * \ingroup internet-test
723 *
724 * \brief Neighbor Cache on InterfaceContainer Test
725 */
727{
728 public:
729 void DoRun() override;
731
732 private:
733 NodeContainer m_nodes; //!< Nodes used in the test.
734};
735
737 : TestCase("The InterfaceContainerTest check if neighbor caches are populated correctly on "
738 "specific interfaceContainer.")
739{
740}
741
742void
744{
745 m_nodes.Create(3);
746
747 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
748 SimpleNetDeviceHelper simpleHelper;
749 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
750 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
751
752 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
753 SimpleNetDeviceHelper simpleHelper2;
754 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
755 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
756
757 InternetStackHelper internet;
758 internet.Install(m_nodes);
759
760 // Setup IPv4 addresses
762 ipv4.SetBase("10.1.1.0", "255.255.255.252");
763 Ipv4InterfaceContainer i = ipv4.Assign(net);
764 ipv4.SetBase("10.1.2.0", "255.255.255.252");
765 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
766
767 // Setup IPv6 addresses
769 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
770 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
771 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
772 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
773
774 // Populate neighbor caches on Ipv4InterfaceContainer i and Ipv6InterfaceContainer icv62.
775 NeighborCacheHelper neighborCache;
776 neighborCache.PopulateNeighborCache(i);
777 neighborCache.PopulateNeighborCache(icv62);
778
779 std::ostringstream stringStream1v4;
780 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
781 std::ostringstream stringStream1v6;
782 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
783
784 // Print cache.
787
789
790 // Check if arp caches are populated correctly on Ipv4InterfaceContainer i.
791 constexpr auto arpCache = "ARP Cache of node 0 at time 0\n"
792 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
793 "ARP Cache of node 1 at time 0\n"
794 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
795 "ARP Cache of node 2 at time 0\n";
796 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
797
798 // Check if ndisc caches are populated correctly on Ipv6InterfaceContainer icv62.
799 constexpr auto NdiscCache =
800 "NDISC Cache of node 0 at time +0s\n"
801 "NDISC Cache of node 1 at time +0s\n"
802 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
803 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
804 "NDISC Cache of node 2 at time +0s\n"
805 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
806 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
807 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
809}
810
811/**
812 * \ingroup internet-test
813 *
814 * \brief Neighbor Cache Flush Test
815 */
816class FlushTest : public TestCase
817{
818 public:
819 void DoRun() override;
820 FlushTest();
821
822 private:
823 NodeContainer m_nodes; //!< Nodes used in the test.
824};
825
827 : TestCase("The FlushTest checks that FlushAutoGenerated() will only remove "
828 "STATIC_AUTOGENERATED entries.")
829{
830}
831
832void
834{
835 m_nodes.Create(3);
836
837 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
838 SimpleNetDeviceHelper simpleHelper;
839 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
840 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
841
842 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
843 SimpleNetDeviceHelper simpleHelper2;
844 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
845 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
846
847 InternetStackHelper internet;
848 internet.Install(m_nodes);
849
850 // Setup IPv4 addresses
852 ipv4.SetBase("10.1.1.0", "255.255.255.252");
853 Ipv4InterfaceContainer i = ipv4.Assign(net);
854 ipv4.SetBase("10.1.2.0", "255.255.255.252");
855 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
856
857 // Setup IPv6 addresses
859 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
860 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
861 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
862 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
863
864 // Populate STATIC_AUTOGENERATED neighbor cache
865 NeighborCacheHelper neighborCache;
866 neighborCache.PopulateNeighborCache();
867
868 // Manually add an PERMANENT arp cache entry
869 std::pair<Ptr<Ipv4>, uint32_t> returnValue = i.Get(0);
870 Ptr<Ipv4> v4 = returnValue.first;
871 uint32_t index = returnValue.second;
872 Ptr<Ipv4Interface> iface = DynamicCast<Ipv4L3Protocol>(v4)->GetInterface(index);
873 Ptr<ArpCache> arpCache = iface->GetArpCache();
874 ArpCache::Entry* arpCacheEntry = arpCache->Add(Ipv4Address("10.1.1.4"));
875 arpCacheEntry->SetMacAddress(Mac48Address("00:00:00:00:00:01"));
876 arpCacheEntry->MarkPermanent();
877
878 // Manually add an PERMANENT ndisc entry
879 std::pair<Ptr<Ipv6>, uint32_t> returnValue2 = icv61.Get(0);
880 Ptr<Ipv6> v6 = returnValue2.first;
881 index = returnValue2.second;
882 Ptr<Ipv6Interface> ifacev6 = DynamicCast<Ipv6L3Protocol>(v6)->GetInterface(index);
883 Ptr<NdiscCache> ndiscCache = ifacev6->GetNdiscCache();
884 NdiscCache::Entry* ndiscCacheEntry = ndiscCache->Add(Ipv6Address("2001::200:ff:fe00:4"));
885 ndiscCacheEntry->SetMacAddress(Mac48Address("00:00:00:00:00:01"));
886 ndiscCacheEntry->MarkPermanent();
887
888 // flush auto-generated cache
889 neighborCache.FlushAutoGenerated();
890
891 std::ostringstream stringStream1v4;
892 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
893 std::ostringstream stringStream1v6;
894 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
895
896 // Print cache.
899
901 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
902 constexpr auto ArpCache = "ARP Cache of node 0 at time 0\n"
903 "10.1.1.4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
904 "ARP Cache of node 1 at time 0\n"
905 "ARP Cache of node 2 at time 0\n";
906 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), ArpCache, "Arp cache is incorrect.");
907
908 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
909 constexpr auto NdiscCache =
910 "NDISC Cache of node 0 at time +0s\n"
911 "2001::200:ff:fe00:4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
912 "NDISC Cache of node 1 at time +0s\n"
913 "NDISC Cache of node 2 at time +0s\n";
914 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
916}
917
918/**
919 * \ingroup internet-test
920 *
921 * \brief Neighbor Cache on Overlapped Scope Test
922 */
924{
925 public:
926 void DoRun() override;
928
929 private:
930 NodeContainer m_nodes; //!< Nodes used in the test.
931};
932
934 : TestCase("The DuplicateTest checks that populate neighbor caches in overlapped scope does "
935 "not raise an error or generate duplicate entries.")
936{
937}
938
939void
941{
942 m_nodes.Create(3);
943
944 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
945 SimpleNetDeviceHelper simpleHelper;
946 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
947 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
948
949 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
950 SimpleNetDeviceHelper simpleHelper2;
951 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
952 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
953
954 InternetStackHelper internet;
955 internet.Install(m_nodes);
956
957 // Setup IPv4 addresses
959 ipv4.SetBase("10.1.1.0", "255.255.255.252");
960 Ipv4InterfaceContainer i = ipv4.Assign(net);
961 ipv4.SetBase("10.1.2.0", "255.255.255.252");
962 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
963
964 // Setup IPv6 addresses
966 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
967 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
968 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
969 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
970
971 // Populate neighbor cache in overlapped scope.
972 NeighborCacheHelper neighborCache;
973 neighborCache.PopulateNeighborCache();
974 neighborCache.PopulateNeighborCache(channel);
975 neighborCache.PopulateNeighborCache(net2);
976 neighborCache.PopulateNeighborCache(icv61);
977 neighborCache.PopulateNeighborCache();
978
979 std::ostringstream stringStream1v4;
980 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
981 std::ostringstream stringStream1v6;
982 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
983
984 // Print cache.
987
989 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
990 constexpr auto ArpCache =
991 "ARP Cache of node 0 at time 0\n"
992 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
993 "ARP Cache of node 1 at time 0\n"
994 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
995 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
996 "ARP Cache of node 2 at time 0\n"
997 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
998 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), ArpCache, "Arp cache is incorrect.");
999
1000 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
1001 constexpr auto NdiscCache =
1002 "NDISC Cache of node 0 at time +0s\n"
1003 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1004 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1005 "NDISC Cache of node 1 at time +0s\n"
1006 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1007 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1008 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1009 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1010 "NDISC Cache of node 2 at time +0s\n"
1011 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
1012 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
1013 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
1015}
1016
1017/**
1018 * \ingroup internet-test
1019 *
1020 * \brief Dynamic Neighbor Cache on Reduced Scope Test
1021 */
1023{
1024 public:
1025 void DoRun() override;
1027
1028 /**
1029 * \brief Add an IPv4 address to an IPv4 interface
1030 * \param ipv4Interface The interface that address will be added.
1031 * \param ifaceAddr The added IPv4 address.
1032 */
1033 void AddIpv4Address(Ptr<Ipv4Interface> ipv4Interface, Ipv4InterfaceAddress ifaceAddr);
1034
1035 /**
1036 * \brief Add an IPv6 address to an IPv6 interface
1037 * \param ipv6Interface The interface that address will be added.
1038 * \param ifaceAddr The added IPv6 address.
1039 */
1040 void AddIpv6Address(Ptr<Ipv6Interface> ipv6Interface, Ipv6InterfaceAddress ifaceAddr);
1041
1042 /**
1043 * \brief Remove an IPv4 address from an IPv4 interface
1044 * \param ipv4Interface The interface that address will be removed from.
1045 * \param index The index of IPv4 address that will be removed.
1046 */
1047 void RemoveIpv4Address(Ptr<Ipv4Interface> ipv4Interface, uint32_t index);
1048
1049 /**
1050 * \brief Remove an IPv6 address from an IPv6 interface
1051 * \param ipv6Interface The interface that address will be removed from.
1052 * \param index The index of IPv6 address that will be removed.
1053 */
1054 void RemoveIpv6Address(Ptr<Ipv6Interface> ipv6Interface, uint32_t index);
1055
1056 private:
1057 NodeContainer m_nodes; //!< Nodes used in the test.
1058};
1059
1061 : TestCase("The DynamicPartialTest checks if dynamic neighbor cache update correctly when "
1062 "generating on a non-global scope.")
1063{
1064}
1065
1066void
1068{
1069 ipv4Interface->AddAddress(ifaceAddr);
1070}
1071
1072void
1074{
1075 ipv6Interface->AddAddress(ifaceAddr);
1076}
1077
1078void
1080{
1081 ipv4Interface->RemoveAddress(index);
1082}
1083
1084void
1086{
1087 ipv6Interface->RemoveAddress(index);
1088}
1089
1090void
1092{
1093 m_nodes.Create(3);
1094
1095 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
1096 SimpleNetDeviceHelper simpleHelper;
1097 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
1098 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
1099
1100 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
1101 SimpleNetDeviceHelper simpleHelper2;
1102 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
1103 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
1104
1105 InternetStackHelper internet;
1106 internet.Install(m_nodes);
1107
1108 // Setup IPv4 addresses
1109 Ipv4AddressHelper ipv4;
1110 ipv4.SetBase("10.1.1.0", "255.255.255.252");
1111 Ipv4InterfaceContainer i = ipv4.Assign(net);
1112 ipv4.SetBase("10.1.2.0", "255.255.255.252");
1113 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
1114
1115 // Add address 10.1.1.5 to n1 in 0.5 seconds
1116 Ptr<Node> n1 = m_nodes.Get(0);
1117 uint32_t ipv4ifIndex = 1;
1118 Ptr<Ipv4Interface> ipv4Interface = n1->GetObject<Ipv4L3Protocol>()->GetInterface(ipv4ifIndex);
1119 Ipv4InterfaceAddress ifaceAddr = Ipv4InterfaceAddress("10.1.1.5", "255.255.255.0");
1122 this,
1123 ipv4Interface,
1124 ifaceAddr);
1125
1126 // Remove the first address (10.1.1.1) from n1 in 1.5 seconds
1127 uint32_t addressIndex = 0;
1130 this,
1131 ipv4Interface,
1132 addressIndex);
1133
1134 // Setup IPv6 addresses
1135 Ipv6AddressHelper ipv6;
1136 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
1137 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
1138 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
1139 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
1140
1141 // Add address 2001:1::200:ff:fe00:5 to n1 in 0.5 seconds
1142 uint32_t ipv6ifIndex = 1;
1143 Ptr<Ipv6Interface> ipv6Interface = n1->GetObject<Ipv6L3Protocol>()->GetInterface(ipv6ifIndex);
1144 Ipv6InterfaceAddress ifaceAddrv6 =
1145 Ipv6InterfaceAddress("2001:0::200:ff:fe00:5", Ipv6Prefix(64));
1148 this,
1149 ipv6Interface,
1150 ifaceAddrv6);
1151
1152 // Remove the second address (2001:1::200:ff:fe00:1) from n1 in 1.5 seconds
1153 addressIndex = 1;
1156 this,
1157 ipv6Interface,
1158 addressIndex);
1159
1160 // Populate dynamic neighbor cache on the first channel
1161 NeighborCacheHelper neighborCache;
1162 neighborCache.SetDynamicNeighborCache(true);
1163 neighborCache.PopulateNeighborCache(channel);
1164
1165 std::ostringstream stringStream1v4;
1166 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
1167 std::ostringstream stringStream1v6;
1168 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
1169
1170 // Print cache.
1177
1179 // Check if the dynamic neighbor cache doesn't change after an Ip address is added,
1180 // Check if the dynamic neighbor cache update correctly after an Ip address is removed.
1181 constexpr auto ArpCache = "ARP Cache of node 0 at time 0\n"
1182 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1183 "ARP Cache of node 1 at time 0\n"
1184 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1185 "ARP Cache of node 2 at time 0\n"
1186 "ARP Cache of node 0 at time 1\n"
1187 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1188 "ARP Cache of node 1 at time 1\n"
1189 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1190 "ARP Cache of node 2 at time 1\n"
1191 "ARP Cache of node 0 at time 2\n"
1192 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1193 "ARP Cache of node 1 at time 2\n"
1194 "ARP Cache of node 2 at time 2\n";
1195 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), ArpCache, "Arp cache is incorrect.");
1196
1197 // Check if the dynamic neighbor cache doesn't change after an Ip address is added,
1198 // Check if the dynamic neighbor cache update correctly after an Ip address is removed.
1199 constexpr auto NdiscCache =
1200 "NDISC Cache of node 0 at time +0s\n"
1201 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1202 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1203 "NDISC Cache of node 1 at time +0s\n"
1204 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1205 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1206 "NDISC Cache of node 2 at time +0s\n"
1207 "NDISC Cache of node 0 at time +1s\n"
1208 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1209 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1210 "NDISC Cache of node 1 at time +1s\n"
1211 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1212 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1213 "NDISC Cache of node 2 at time +1s\n"
1214 "NDISC Cache of node 0 at time +2s\n"
1215 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1216 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1217 "NDISC Cache of node 1 at time +2s\n"
1218 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1219 "NDISC Cache of node 2 at time +2s\n";
1220 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
1222}
1223
1224/**
1225 * \ingroup internet-test
1226 *
1227 * \brief NeighborCache TestSuite
1228 */
1230{
1231 public:
1233 : TestSuite("neighbor-cache", Type::UNIT)
1234 {
1235 AddTestCase(new DynamicNeighborCacheTest, TestCase::Duration::QUICK);
1236 AddTestCase(new ChannelTest, TestCase::Duration::QUICK);
1237 AddTestCase(new NetDeviceContainerTest, TestCase::Duration::QUICK);
1238 AddTestCase(new InterfaceContainerTest, TestCase::Duration::QUICK);
1239 AddTestCase(new FlushTest, TestCase::Duration::QUICK);
1240 AddTestCase(new DuplicateTest, TestCase::Duration::QUICK);
1241 AddTestCase(new DynamicPartialTest, TestCase::Duration::QUICK);
1242 }
1243};
1244
1245static NeighborCacheTestSuite g_neighborcacheTestSuite; //!< Static variable for test initialization
Neighbor cache on Channel Test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
Neighbor Cache on Overlapped Scope Test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
Dynamic Neighbor Cache Test.
std::vector< uint32_t > m_receivedPacketSizes
Received packet sizes.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void RemoveIpv4Address(Ptr< Ipv4Interface > ipv4Interface, uint32_t index)
Remove an IPv4 address from an IPv4 interface.
void AddIpv4Address(Ptr< Ipv4Interface > ipv4Interface, Ipv4InterfaceAddress ifaceAddr)
Add an IPv4 address to an IPv4 interface.
void AddIpv6Address(Ptr< Ipv6Interface > ipv6Interface, Ipv6InterfaceAddress ifaceAddr)
Add an IPv6 address to an IPv6 interface.
void DoRun() override
Implementation to actually run this TestCase.
void DoSendDatav4(Ptr< Socket > socket, Ipv4Address to)
Send data immediately after being called.
void RemoveIpv6Address(Ptr< Ipv6Interface > ipv6Interface, uint32_t index)
Remove an IPv6 address from an IPv6 interface.
void DoSendDatav6(Ptr< Socket > socket, Ipv6Address to)
Send data immediately after being called.
void SendData(Ptr< Socket > socket, Ipv4Address to)
Schedules the DoSendData () function to send the data.
Ptr< Packet > m_receivedPacket
Received packet.
Dynamic Neighbor Cache on Reduced Scope Test.
void DoRun() override
Implementation to actually run this TestCase.
void AddIpv6Address(Ptr< Ipv6Interface > ipv6Interface, Ipv6InterfaceAddress ifaceAddr)
Add an IPv6 address to an IPv6 interface.
void RemoveIpv4Address(Ptr< Ipv4Interface > ipv4Interface, uint32_t index)
Remove an IPv4 address from an IPv4 interface.
void RemoveIpv6Address(Ptr< Ipv6Interface > ipv6Interface, uint32_t index)
Remove an IPv6 address from an IPv6 interface.
void AddIpv4Address(Ptr< Ipv4Interface > ipv4Interface, Ipv4InterfaceAddress ifaceAddr)
Add an IPv4 address to an IPv4 interface.
NodeContainer m_nodes
Nodes used in the test.
Neighbor Cache Flush Test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
Neighbor Cache on InterfaceContainer Test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
NeighborCache TestSuite.
Neighbor Cache on NetDeviceContainer Test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
a polymophic address class
Definition: address.h:101
A record that that holds information about an ArpCache entry.
Definition: arp-cache.h:184
void MarkPermanent()
Changes the state of this entry to Permanent.
Definition: arp-cache.cc:446
void SetMacAddress(Address macAddress)
Definition: arp-cache.cc:506
An ARP cache.
Definition: arp-cache.h:53
An Inet6 address class.
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
Implement the IPv4 layer.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
Definition: ipv6-address.h:49
IPv6 address associated with an interface.
Keep track of a set of IPv6 interfaces.
std::pair< Ptr< Ipv6 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv6> and interface stored at the location specified by the index.
IPv6 layer implementation.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
an EUI-48 address
Definition: mac48-address.h:46
A record that holds information about a NdiscCache entry.
Definition: ndisc-cache.h:167
void MarkPermanent()
Change the state to this entry to PERMANENT.
Definition: ndisc-cache.cc:608
void SetMacAddress(Address mac)
Set the MAC address of this entry.
Definition: ndisc-cache.cc:680
IPv6 Neighbor Discovery cache.
Definition: ndisc-cache.h:49
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
void SetDynamicNeighborCache(bool enable)
Enable/disable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses chan...
void FlushAutoGenerated() const
Remove entries generated from NeighborCacheHelper from ARP cache and NDISC cache.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Definition: packet.cc:393
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
build a set of SimpleNetDevice objects
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:588
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
static constexpr auto UNIT
Definition: test.h:1286
API to create UDP socket instances.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:145
#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:252
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:704
static NeighborCacheTestSuite g_neighborcacheTestSuite
Static variable for test initialization.