A Discrete-Event Network Simulator
API
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
49{
51
57 void DoSendDatav4(Ptr<Socket> socket, Ipv4Address to);
58
64 void DoSendDatav6(Ptr<Socket> socket, Ipv6Address to);
65
71 void SendData(Ptr<Socket> socket, Ipv4Address to);
72
78 void SendData(Ptr<Socket> socket, Ipv6Address to);
79
85 void AddIpv4Address(Ptr<Ipv4Interface> ipv4Interface, Ipv4InterfaceAddress ifaceAddr);
86
92 void AddIpv6Address(Ptr<Ipv6Interface> ipv6Interface, Ipv6InterfaceAddress ifaceAddr);
93
99 void RemoveIpv4Address(Ptr<Ipv4Interface> ipv4Interface, uint32_t index);
100
106 void RemoveIpv6Address(Ptr<Ipv6Interface> ipv6Interface, uint32_t index);
107
108 public:
109 void DoRun() override;
110
112
117 void ReceivePkt(Ptr<Socket> socket);
118
119 std::vector<uint32_t> m_receivedPacketSizes;
120};
121
123 : TestCase(
124 "The DynamicNeighborCacheTestPopulate checks if neighbor caches are correctly populated "
125 "in global scope and updated when there is an IP address added or removed.")
126{
127}
128
129void
131{
132 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
134 NS_TEST_ASSERT_MSG_EQ(availableData,
136 "Received Packet size is not equal to the Rx buffer size");
138}
139
140void
142{
143 Address realTo = InetSocketAddress(to, 1234);
144 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
145}
146
147void
149{
150 Address realTo = Inet6SocketAddress(to, 1234);
151 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
152}
153
154void
156{
157 m_receivedPacket = Create<Packet>();
158 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
159 Seconds(60),
161 this,
162 socket,
163 to);
164}
165
166void
168{
169 m_receivedPacket = Create<Packet>();
170 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
171 Seconds(60),
173 this,
174 socket,
175 to);
176}
177
178void
180 Ipv4InterfaceAddress ifaceAddr)
181{
182 ipv4Interface->AddAddress(ifaceAddr);
183}
184
185void
187 Ipv6InterfaceAddress ifaceAddr)
188{
189 ipv6Interface->AddAddress(ifaceAddr);
190}
191
192void
194{
195 ipv4Interface->RemoveAddress(index);
196}
197
198void
200{
201 ipv6Interface->RemoveAddress(index);
202}
203
204void
206{
207 Ptr<Node> tx1Node = CreateObject<Node>();
208 Ptr<Node> tx2Node = CreateObject<Node>();
209 Ptr<Node> rxNode = CreateObject<Node>();
210 Ptr<Node> snifferNode = CreateObject<Node>();
211
212 NodeContainer all(tx1Node, tx2Node, rxNode, snifferNode);
213
214 std::ostringstream stringStream1v4;
215 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
216 std::ostringstream stringStream1v6;
217 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
218
219 InternetStackHelper internetNodes;
220 internetNodes.Install(all);
221
223 // Sender Node
225 {
226 tx1Dev = CreateObject<SimpleNetDevice>();
227 tx1Dev->SetAddress(Mac48Address("00:00:00:00:00:01"));
228 tx1Node->AddDevice(tx1Dev);
229 }
230 net.Add(tx1Dev);
231
233 {
234 tx2Dev = CreateObject<SimpleNetDevice>();
235 tx2Dev->SetAddress(Mac48Address("00:00:00:00:00:02"));
236 tx2Node->AddDevice(tx2Dev);
237 }
238 net.Add(tx2Dev);
239
240 // Recieve node
242 {
243 rxDev = CreateObject<SimpleNetDevice>();
244 rxDev->SetAddress(Mac48Address("00:00:00:00:00:03"));
245 rxNode->AddDevice(rxDev);
246 }
247 net.Add(rxDev);
248
249 // Sniffer node
250 Ptr<SimpleNetDevice> snifferDev;
251 {
252 snifferDev = CreateObject<SimpleNetDevice>();
253 snifferDev->SetAddress(Mac48Address("00:00:00:00:00:04"));
254 snifferNode->AddDevice(snifferDev);
255 }
256 net.Add(snifferDev);
257
258 // link the channels
259 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
260 tx1Dev->SetChannel(channel);
261 tx2Dev->SetChannel(channel);
262 rxDev->SetChannel(channel);
263 snifferDev->SetChannel(channel);
264
265 // Setup IPv4 addresses
267 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
268 Ipv4InterfaceContainer icv4 = ipv4.Assign(net);
269
270 // Add address 10.1.1.5 to rxNode in 0.5 seconds
271 Ptr<Node> n1 = rxNode;
272 uint32_t ipv4ifIndex = 1;
273 Ptr<Ipv4Interface> ipv4Interface = n1->GetObject<Ipv4L3Protocol>()->GetInterface(ipv4ifIndex);
274 Ipv4InterfaceAddress ifaceAddr = Ipv4InterfaceAddress("10.0.1.5", "255.255.255.0");
275 Simulator::Schedule(Seconds(0.5),
277 this,
278 ipv4Interface,
279 ifaceAddr);
280
281 // Remove the first address (10.1.1.3) from rxNode in 1.5 seconds
282 uint32_t addressIndex = 0;
283 Simulator::Schedule(Seconds(1.5),
285 this,
286 ipv4Interface,
287 addressIndex);
288
289 // Setup IPv6 addresses
291 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
292 Ipv6InterfaceContainer icv6 = ipv6.Assign(net);
293
294 // Add address 2001:1::200:ff:fe00:5 to rxNode in 0.5 seconds
295 uint32_t ipv6ifIndex = 1;
296 Ptr<Ipv6Interface> ipv6Interface = n1->GetObject<Ipv6L3Protocol>()->GetInterface(ipv6ifIndex);
297 Ipv6InterfaceAddress ifaceAddrv6 =
298 Ipv6InterfaceAddress("2001:0::200:ff:fe00:5", Ipv6Prefix(64));
299 Simulator::Schedule(Seconds(0.5),
301 this,
302 ipv6Interface,
303 ifaceAddrv6);
304
305 // Remove the second address (2001:1::200:ff:fe00:3) from rxNode in 1.5 seconds
306 addressIndex = 1;
307 Simulator::Schedule(Seconds(1.5),
309 this,
310 ipv6Interface,
311 addressIndex);
312
313 // Populate neighbor caches.
314 NeighborCacheHelper neighborCache;
315 neighborCache.SetDynamicNeighborCache(true);
316 neighborCache.PopulateNeighborCache();
317
318 // Print cache.
319 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), arpStream);
320 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), ndiscStream);
321 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(1), arpStream);
322 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(1), ndiscStream);
323 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(2), arpStream);
324 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(2), ndiscStream);
325
326 // Create the UDP sockets
327 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
328 Ptr<Socket> rxSocketv4 = rxSocketFactory->CreateSocket();
329 Ptr<Socket> rxSocketv6 = rxSocketFactory->CreateSocket();
330 NS_TEST_EXPECT_MSG_EQ(rxSocketv4->Bind(InetSocketAddress(Ipv4Address("10.0.1.5"), 1234)),
331 0,
332 "trivial");
334 rxSocketv6->Bind(Inet6SocketAddress(Ipv6Address("2001:0::200:ff:fe00:5"), 1234)),
335 0,
336 "trivial");
337 rxSocketv4->SetRecvCallback(MakeCallback(&DynamicNeighborCacheTest::ReceivePkt, this));
339
340 Ptr<SocketFactory> snifferSocketFactory = snifferNode->GetObject<UdpSocketFactory>();
341 Ptr<Socket> snifferSocketv4 = snifferSocketFactory->CreateSocket();
342 Ptr<Socket> snifferSocketv6 = snifferSocketFactory->CreateSocket();
343 NS_TEST_EXPECT_MSG_EQ(snifferSocketv4->Bind(InetSocketAddress(Ipv4Address("10.0.1.4"), 1234)),
344 0,
345 "trivial");
347 snifferSocketv6->Bind(Inet6SocketAddress(Ipv6Address("2001:0::200:ff:fe00:4"), 1234)),
348 0,
349 "trivial");
350 snifferSocketv4->SetRecvCallback(MakeCallback(&DynamicNeighborCacheTest::ReceivePkt, this));
352
353 Ptr<SocketFactory> tx1SocketFactory = tx1Node->GetObject<UdpSocketFactory>();
354 Ptr<Socket> tx1Socket = tx1SocketFactory->CreateSocket();
355 tx1Socket->SetAllowBroadcast(true);
356
357 Ptr<SocketFactory> tx2SocketFactory = tx2Node->GetObject<UdpSocketFactory>();
358 Ptr<Socket> tx2Socket = tx2SocketFactory->CreateSocket();
359 tx2Socket->SetAllowBroadcast(true);
360
361 // ------ Now the tests ------------
362
363 // Unicast test
364
365 // send data to the added address
366 SendData(tx1Socket, Ipv4Address("10.0.1.5"));
367 SendData(tx1Socket, Ipv6Address("2001:0::200:ff:fe00:5"));
368
369 // send data to the removed address
370 SendData(tx1Socket, Ipv4Address("10.0.1.3"));
371 SendData(tx1Socket, Ipv6Address("2001:0::200:ff:fe00:3"));
372
373 Simulator::Stop(Seconds(66));
374 Simulator::Run();
375
376 // Check if all packet are correctly received.
378 123,
379 "Should receive packet sending to the added IPv4 address.");
381 123,
382 "Should receive packet sending to the added IPv6 address.");
385 2,
386 "Should receive only 1 packet from IPv4 interface and only 1 packet from IPv6 interface.");
387
388 // Check if the arp caches are populated correctly at time 0,
389 // Check if the arp caches are updated correctly at time 1 after new IP address is added,
390 // Check if the arp caches are updated correctly at time 2 after an IP address is removed.
391 constexpr auto arpCache =
392 "ARP Cache of node 0 at time 0\n"
393 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
394 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
395 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
396 "ARP Cache of node 1 at time 0\n"
397 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
398 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
399 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
400 "ARP Cache of node 2 at time 0\n"
401 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
402 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
403 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
404 "ARP Cache of node 3 at time 0\n"
405 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
406 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
407 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
408 "ARP Cache of node 0 at time 1\n"
409 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
410 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
411 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
412 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
413 "ARP Cache of node 1 at time 1\n"
414 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
415 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
416 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
417 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
418 "ARP Cache of node 2 at time 1\n"
419 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
420 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
421 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
422 "ARP Cache of node 3 at time 1\n"
423 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
424 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
425 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
426 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
427 "ARP Cache of node 0 at time 2\n"
428 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
429 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
430 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
431 "ARP Cache of node 1 at time 2\n"
432 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
433 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
434 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
435 "ARP Cache of node 2 at time 2\n"
436 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
437 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
438 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
439 "ARP Cache of node 3 at time 2\n"
440 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
441 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
442 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
443 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
444
445 // Check if the ndisc caches are populated correctly at time 0,
446 // Check if the ndisc caches are updated correctly at time 1 after new IP address is added,
447 // Check if the ndisc caches are updated correctly at time 2 after an IP address is removed.
448 constexpr auto NdiscCache =
449 "NDISC Cache of node 0 at time +0s\n"
450 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
451 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
452 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
453 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
454 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
455 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
456 "NDISC Cache of node 1 at time +0s\n"
457 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
458 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
459 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
460 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
461 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
462 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
463 "NDISC Cache of node 2 at time +0s\n"
464 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
465 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
466 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
467 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
468 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
469 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
470 "NDISC Cache of node 3 at time +0s\n"
471 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
472 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
473 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
474 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
475 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
476 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
477 "NDISC Cache of node 0 at time +1s\n"
478 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
479 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
480 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
481 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
482 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
483 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
484 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
485 "NDISC Cache of node 1 at time +1s\n"
486 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
487 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
488 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
489 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
490 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
491 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
492 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
493 "NDISC Cache of node 2 at time +1s\n"
494 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
495 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
496 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
497 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
498 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
499 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
500 "NDISC Cache of node 3 at time +1s\n"
501 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
502 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
503 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
504 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
505 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
506 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
507 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
508 "NDISC Cache of node 0 at time +2s\n"
509 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
510 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
511 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
512 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
513 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
514 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
515 "NDISC Cache of node 1 at time +2s\n"
516 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
517 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
518 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
519 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
520 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
521 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
522 "NDISC Cache of node 2 at time +2s\n"
523 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
524 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
525 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
526 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
527 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
528 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
529 "NDISC Cache of node 3 at time +2s\n"
530 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
531 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
532 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
533 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
534 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
535 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
536 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
537
539
540 Simulator::Destroy();
541}
542
549class ChannelTest : public TestCase
550{
551 public:
552 void DoRun() override;
553 ChannelTest();
554
555 private:
557};
558
560 : TestCase(
561 "The ChannelTest Check if neighbor caches are correctly populated on specific channel.")
562{
563}
564
565void
567{
568 m_nodes.Create(3);
569
570 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
571 SimpleNetDeviceHelper simpleHelper;
572 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
573 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
574
575 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
576 SimpleNetDeviceHelper simpleHelper2;
577 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
578 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
579
580 InternetStackHelper internet;
581 internet.Install(m_nodes);
582
583 // Setup IPv4 addresses
585 ipv4.SetBase("10.1.1.0", "255.255.255.252");
586 Ipv4InterfaceContainer i = ipv4.Assign(net);
587 ipv4.SetBase("10.1.2.0", "255.255.255.252");
588 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
589
590 // Setup IPv6 addresses
592 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
593 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
594 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
595 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
596
597 // Populate neighbor caches on the first channel
598 NeighborCacheHelper neighborCache;
599 neighborCache.PopulateNeighborCache(channel);
600
601 std::ostringstream stringStream1v4;
602 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
603 std::ostringstream stringStream1v6;
604 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
605
606 // Print cache.
607 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), arpStream);
608 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), ndiscStream);
609
610 Simulator::Run();
611
612 // Check if arp caches are populated correctly in the first channel
613 constexpr auto arpCache = "ARP Cache of node 0 at time 0\n"
614 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
615 "ARP Cache of node 1 at time 0\n"
616 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
617 "ARP Cache of node 2 at time 0\n";
618 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
619
620 // Check if ndisc caches are populated correctly in the first channel
621 constexpr auto NdiscCache =
622 "NDISC Cache of node 0 at time +0s\n"
623 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
624 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
625 "NDISC Cache of node 1 at time +0s\n"
626 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
627 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
628 "NDISC Cache of node 2 at time +0s\n";
629 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
630 Simulator::Destroy();
631}
632
640{
641 public:
642 void DoRun() override;
644
645 private:
647};
648
650 : TestCase("The NetDeviceContainerTest check if neighbor caches are populated correctly on "
651 "specific netDeviceContainer.")
652{
653}
654
655void
657{
658 m_nodes.Create(3);
659
660 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
661 SimpleNetDeviceHelper simpleHelper;
662 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
663 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
664
665 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
666 SimpleNetDeviceHelper simpleHelper2;
667 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
668 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
669
670 InternetStackHelper internet;
671 internet.Install(m_nodes);
672
673 // Setup IPv4 addresses
675 ipv4.SetBase("10.1.1.0", "255.255.255.252");
676 Ipv4InterfaceContainer i = ipv4.Assign(net);
677 ipv4.SetBase("10.1.2.0", "255.255.255.252");
678 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
679
680 // Setup IPv6 addresses
682 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
683 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
684 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
685 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
686
687 // Populate neighbor caches on NetDeviceContainer net2.
688 NeighborCacheHelper neighborCache;
689 neighborCache.PopulateNeighborCache(net2);
690
691 std::ostringstream stringStream1v4;
692 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
693 std::ostringstream stringStream1v6;
694 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
695
696 // Print cache.
697 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), arpStream);
698 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), ndiscStream);
699
700 Simulator::Run();
701
702 // Check if arp caches are populated correctly on NetDeviceContainer net2.
703 constexpr auto arpCache =
704 "ARP Cache of node 0 at time 0\n"
705 "ARP Cache of node 1 at time 0\n"
706 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
707 "ARP Cache of node 2 at time 0\n"
708 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
709 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
710
711 // Check if ndisc caches are populated correctly on NetDeviceContainer net2.
712 constexpr auto NdiscCache =
713 "NDISC Cache of node 0 at time +0s\n"
714 "NDISC Cache of node 1 at time +0s\n"
715 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
716 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
717 "NDISC Cache of node 2 at time +0s\n"
718 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
719 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
720 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
721 Simulator::Destroy();
722}
723
731{
732 public:
733 void DoRun() override;
735
736 private:
738};
739
741 : TestCase("The InterfaceContainerTest check if neighbor caches are populated correctly on "
742 "specific interfaceContainer.")
743{
744}
745
746void
748{
749 m_nodes.Create(3);
750
751 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
752 SimpleNetDeviceHelper simpleHelper;
753 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
754 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
755
756 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
757 SimpleNetDeviceHelper simpleHelper2;
758 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
759 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
760
761 InternetStackHelper internet;
762 internet.Install(m_nodes);
763
764 // Setup IPv4 addresses
766 ipv4.SetBase("10.1.1.0", "255.255.255.252");
767 Ipv4InterfaceContainer i = ipv4.Assign(net);
768 ipv4.SetBase("10.1.2.0", "255.255.255.252");
769 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
770
771 // Setup IPv6 addresses
773 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
774 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
775 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
776 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
777
778 // Populate neighbor caches on Ipv4InterfaceContainer i and Ipv6InterfaceContainer icv62.
779 NeighborCacheHelper neighborCache;
780 neighborCache.PopulateNeighborCache(i);
781 neighborCache.PopulateNeighborCache(icv62);
782
783 std::ostringstream stringStream1v4;
784 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
785 std::ostringstream stringStream1v6;
786 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
787
788 // Print cache.
789 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), arpStream);
790 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), ndiscStream);
791
792 Simulator::Run();
793
794 // Check if arp caches are populated correctly on Ipv4InterfaceContainer i.
795 constexpr auto arpCache = "ARP Cache of node 0 at time 0\n"
796 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
797 "ARP Cache of node 1 at time 0\n"
798 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
799 "ARP Cache of node 2 at time 0\n";
800 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), arpCache, "Arp cache is incorrect.");
801
802 // Check if ndisc caches are populated correctly on Ipv6InterfaceContainer icv62.
803 constexpr auto NdiscCache =
804 "NDISC Cache of node 0 at time +0s\n"
805 "NDISC Cache of node 1 at time +0s\n"
806 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
807 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
808 "NDISC Cache of node 2 at time +0s\n"
809 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
810 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
811 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
812 Simulator::Destroy();
813}
814
821class FlushTest : public TestCase
822{
823 public:
824 void DoRun() override;
825 FlushTest();
826
827 private:
829};
830
832 : TestCase("The FlushTest checks that FlushAutoGenerated() will only remove "
833 "STATIC_AUTOGENERATED entries.")
834{
835}
836
837void
839{
840 m_nodes.Create(3);
841
842 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
843 SimpleNetDeviceHelper simpleHelper;
844 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
845 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
846
847 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
848 SimpleNetDeviceHelper simpleHelper2;
849 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
850 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
851
852 InternetStackHelper internet;
853 internet.Install(m_nodes);
854
855 // Setup IPv4 addresses
857 ipv4.SetBase("10.1.1.0", "255.255.255.252");
858 Ipv4InterfaceContainer i = ipv4.Assign(net);
859 ipv4.SetBase("10.1.2.0", "255.255.255.252");
860 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
861
862 // Setup IPv6 addresses
864 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
865 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
866 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
867 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
868
869 // Populate STATIC_AUTOGENERATED neighbor cache
870 NeighborCacheHelper neighborCache;
871 neighborCache.PopulateNeighborCache();
872
873 // Manually add an PERMANENT arp cache entry
874 std::pair<Ptr<Ipv4>, uint32_t> returnValue = i.Get(0);
875 Ptr<Ipv4> v4 = returnValue.first;
876 uint32_t index = returnValue.second;
877 Ptr<Ipv4Interface> iface = DynamicCast<Ipv4L3Protocol>(v4)->GetInterface(index);
878 Ptr<ArpCache> arpCache = iface->GetArpCache();
879 ArpCache::Entry* arpCacheEntry = arpCache->Add(Ipv4Address("10.1.1.4"));
880 arpCacheEntry->SetMacAddress(Mac48Address("04-06-00:00:00:00:00:01"));
881 arpCacheEntry->MarkPermanent();
882
883 // Manually add an PERMANENT ndisc entry
884 std::pair<Ptr<Ipv6>, uint32_t> returnValue2 = icv61.Get(0);
885 Ptr<Ipv6> v6 = returnValue2.first;
886 index = returnValue2.second;
887 Ptr<Ipv6Interface> ifacev6 = DynamicCast<Ipv6L3Protocol>(v6)->GetInterface(index);
888 Ptr<NdiscCache> ndiscCache = ifacev6->GetNdiscCache();
889 NdiscCache::Entry* ndiscCacheEntry = ndiscCache->Add(Ipv6Address("2001::200:ff:fe00:4"));
890 ndiscCacheEntry->SetMacAddress(Mac48Address("04-06-00:00:00:00:00:01"));
891 ndiscCacheEntry->MarkPermanent();
892
893 // flush auto-generated cache
894 neighborCache.FlushAutoGenerated();
895
896 std::ostringstream stringStream1v4;
897 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
898 std::ostringstream stringStream1v6;
899 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
900
901 // Print cache.
902 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), arpStream);
903 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), ndiscStream);
904
905 Simulator::Run();
906 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
907 constexpr auto ArpCache = "ARP Cache of node 0 at time 0\n"
908 "10.1.1.4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
909 "ARP Cache of node 1 at time 0\n"
910 "ARP Cache of node 2 at time 0\n";
911 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), ArpCache, "Arp cache is incorrect.");
912
913 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
914 constexpr auto NdiscCache =
915 "NDISC Cache of node 0 at time +0s\n"
916 "2001::200:ff:fe00:4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
917 "NDISC Cache of node 1 at time +0s\n"
918 "NDISC Cache of node 2 at time +0s\n";
919 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
920 Simulator::Destroy();
921}
922
930{
931 public:
932 void DoRun() override;
934
935 private:
937};
938
940 : TestCase("The DuplicateTest checks that populate neighbor caches in overlapped scope does "
941 "not raise an error or generate duplicate entries.")
942{
943}
944
945void
947{
948 m_nodes.Create(3);
949
950 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
951 SimpleNetDeviceHelper simpleHelper;
952 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
953 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
954
955 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
956 SimpleNetDeviceHelper simpleHelper2;
957 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
958 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
959
960 InternetStackHelper internet;
961 internet.Install(m_nodes);
962
963 // Setup IPv4 addresses
965 ipv4.SetBase("10.1.1.0", "255.255.255.252");
966 Ipv4InterfaceContainer i = ipv4.Assign(net);
967 ipv4.SetBase("10.1.2.0", "255.255.255.252");
968 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
969
970 // Setup IPv6 addresses
972 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
973 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
974 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
975 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
976
977 // Populate neighbor cache in overlapped scope.
978 NeighborCacheHelper neighborCache;
979 neighborCache.PopulateNeighborCache();
980 neighborCache.PopulateNeighborCache(channel);
981 neighborCache.PopulateNeighborCache(net2);
982 neighborCache.PopulateNeighborCache(icv61);
983 neighborCache.PopulateNeighborCache();
984
985 std::ostringstream stringStream1v4;
986 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
987 std::ostringstream stringStream1v6;
988 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
989
990 // Print cache.
991 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), arpStream);
992 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), ndiscStream);
993
994 Simulator::Run();
995 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
996 constexpr auto ArpCache =
997 "ARP Cache of node 0 at time 0\n"
998 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
999 "ARP Cache of node 1 at time 0\n"
1000 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1001 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1002 "ARP Cache of node 2 at time 0\n"
1003 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
1004 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), ArpCache, "Arp cache is incorrect.");
1005
1006 // Check if the STATIC_AUTOGENERATED entries are flushed and the PERMANENT entry is left.
1007 constexpr auto NdiscCache =
1008 "NDISC Cache of node 0 at time +0s\n"
1009 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1010 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1011 "NDISC Cache of node 1 at time +0s\n"
1012 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1013 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1014 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1015 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1016 "NDISC Cache of node 2 at time +0s\n"
1017 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
1018 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
1019 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
1020 Simulator::Destroy();
1021}
1022
1030{
1031 public:
1032 void DoRun() override;
1034
1040 void AddIpv4Address(Ptr<Ipv4Interface> ipv4Interface, Ipv4InterfaceAddress ifaceAddr);
1041
1047 void AddIpv6Address(Ptr<Ipv6Interface> ipv6Interface, Ipv6InterfaceAddress ifaceAddr);
1048
1054 void RemoveIpv4Address(Ptr<Ipv4Interface> ipv4Interface, uint32_t index);
1055
1061 void RemoveIpv6Address(Ptr<Ipv6Interface> ipv6Interface, uint32_t index);
1062
1063 private:
1065};
1066
1068 : TestCase("The DynamicPartialTest checks if dynamic neighbor cache update correctly when "
1069 "generating on a non-global scope.")
1070{
1071}
1072
1073void
1075{
1076 ipv4Interface->AddAddress(ifaceAddr);
1077}
1078
1079void
1081{
1082 ipv6Interface->AddAddress(ifaceAddr);
1083}
1084
1085void
1087{
1088 ipv4Interface->RemoveAddress(index);
1089}
1090
1091void
1093{
1094 ipv6Interface->RemoveAddress(index);
1095}
1096
1097void
1099{
1100 m_nodes.Create(3);
1101
1102 Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
1103 SimpleNetDeviceHelper simpleHelper;
1104 NetDeviceContainer net = simpleHelper.Install(m_nodes.Get(0), channel);
1105 net.Add(simpleHelper.Install(m_nodes.Get(1), channel));
1106
1107 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
1108 SimpleNetDeviceHelper simpleHelper2;
1109 NetDeviceContainer net2 = simpleHelper.Install(m_nodes.Get(1), channel2);
1110 net2.Add(simpleHelper2.Install(m_nodes.Get(2), channel2));
1111
1112 InternetStackHelper internet;
1113 internet.Install(m_nodes);
1114
1115 // Setup IPv4 addresses
1116 Ipv4AddressHelper ipv4;
1117 ipv4.SetBase("10.1.1.0", "255.255.255.252");
1118 Ipv4InterfaceContainer i = ipv4.Assign(net);
1119 ipv4.SetBase("10.1.2.0", "255.255.255.252");
1120 Ipv4InterfaceContainer i2 = ipv4.Assign(net2);
1121
1122 // Add address 10.1.1.5 to n1 in 0.5 seconds
1123 Ptr<Node> n1 = m_nodes.Get(0);
1124 uint32_t ipv4ifIndex = 1;
1125 Ptr<Ipv4Interface> ipv4Interface = n1->GetObject<Ipv4L3Protocol>()->GetInterface(ipv4ifIndex);
1126 Ipv4InterfaceAddress ifaceAddr = Ipv4InterfaceAddress("10.1.1.5", "255.255.255.0");
1127 Simulator::Schedule(Seconds(0.5),
1129 this,
1130 ipv4Interface,
1131 ifaceAddr);
1132
1133 // Remove the first address (10.1.1.1) from n1 in 1.5 seconds
1134 uint32_t addressIndex = 0;
1135 Simulator::Schedule(Seconds(1.5),
1137 this,
1138 ipv4Interface,
1139 addressIndex);
1140
1141 // Setup IPv6 addresses
1142 Ipv6AddressHelper ipv6;
1143 ipv6.SetBase(Ipv6Address("2001:0::"), Ipv6Prefix(64));
1144 Ipv6InterfaceContainer icv61 = ipv6.Assign(net);
1145 ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
1146 Ipv6InterfaceContainer icv62 = ipv6.Assign(net2);
1147
1148 // Add address 2001:1::200:ff:fe00:5 to n1 in 0.5 seconds
1149 uint32_t ipv6ifIndex = 1;
1150 Ptr<Ipv6Interface> ipv6Interface = n1->GetObject<Ipv6L3Protocol>()->GetInterface(ipv6ifIndex);
1151 Ipv6InterfaceAddress ifaceAddrv6 =
1152 Ipv6InterfaceAddress("2001:0::200:ff:fe00:5", Ipv6Prefix(64));
1153 Simulator::Schedule(Seconds(0.5),
1155 this,
1156 ipv6Interface,
1157 ifaceAddrv6);
1158
1159 // Remove the second address (2001:1::200:ff:fe00:1) from n1 in 1.5 seconds
1160 addressIndex = 1;
1161 Simulator::Schedule(Seconds(1.5),
1163 this,
1164 ipv6Interface,
1165 addressIndex);
1166
1167 // Populate dynamic neighbor cache on the first channel
1168 NeighborCacheHelper neighborCache;
1169 neighborCache.SetDynamicNeighborCache(true);
1170 neighborCache.PopulateNeighborCache(channel);
1171
1172 std::ostringstream stringStream1v4;
1173 Ptr<OutputStreamWrapper> arpStream = Create<OutputStreamWrapper>(&stringStream1v4);
1174 std::ostringstream stringStream1v6;
1175 Ptr<OutputStreamWrapper> ndiscStream = Create<OutputStreamWrapper>(&stringStream1v6);
1176
1177 // Print cache.
1178 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), arpStream);
1179 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(0), ndiscStream);
1180 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(1), arpStream);
1181 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(1), ndiscStream);
1182 Ipv4RoutingHelper::PrintNeighborCacheAllAt(Seconds(2), arpStream);
1183 Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(2), ndiscStream);
1184
1185 Simulator::Run();
1186 // Check if the dynamic neighbor cache doesn't change after an Ip address is added,
1187 // Check if the dynamic neighbor cache update correctly after an Ip address is removed.
1188 constexpr auto ArpCache = "ARP Cache of node 0 at time 0\n"
1189 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1190 "ARP Cache of node 1 at time 0\n"
1191 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1192 "ARP Cache of node 2 at time 0\n"
1193 "ARP Cache of node 0 at time 1\n"
1194 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1195 "ARP Cache of node 1 at time 1\n"
1196 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1197 "ARP Cache of node 2 at time 1\n"
1198 "ARP Cache of node 0 at time 2\n"
1199 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1200 "ARP Cache of node 1 at time 2\n"
1201 "ARP Cache of node 2 at time 2\n";
1202 NS_TEST_EXPECT_MSG_EQ(stringStream1v4.str(), ArpCache, "Arp cache is incorrect.");
1203
1204 // Check if the dynamic neighbor cache doesn't change after an Ip address is added,
1205 // Check if the dynamic neighbor cache update correctly after an Ip address is removed.
1206 constexpr auto NdiscCache =
1207 "NDISC Cache of node 0 at time +0s\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 +0s\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 +0s\n"
1214 "NDISC Cache of node 0 at time +1s\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 +1s\n"
1218 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1219 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1220 "NDISC Cache of node 2 at time +1s\n"
1221 "NDISC Cache of node 0 at time +2s\n"
1222 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1223 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1224 "NDISC Cache of node 1 at time +2s\n"
1225 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1226 "NDISC Cache of node 2 at time +2s\n";
1227 NS_TEST_EXPECT_MSG_EQ(stringStream1v6.str(), NdiscCache, "Ndisc cache is incorrect.");
1228 Simulator::Destroy();
1229}
1230
1238{
1239 public:
1241 : TestSuite("neighbor-cache", UNIT)
1242 {
1243 AddTestCase(new DynamicNeighborCacheTest, TestCase::QUICK);
1244 AddTestCase(new ChannelTest, TestCase::QUICK);
1245 AddTestCase(new NetDeviceContainerTest, TestCase::QUICK);
1246 AddTestCase(new InterfaceContainerTest, TestCase::QUICK);
1247 AddTestCase(new FlushTest, TestCase::QUICK);
1248 AddTestCase(new DuplicateTest, TestCase::QUICK);
1249 AddTestCase(new DynamicPartialTest, TestCase::QUICK);
1250 }
1251};
1252
#define max(a, b)
Definition: 80211b.c:43
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:92
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:447
void SetMacAddress(Address macAddress)
Definition: arp-cache.cc:507
An ARP cache.
Definition: arp-cache.h:53
ArpCache::Entry * Add(Ipv4Address to)
Add an Ipv4Address to this ARP cache.
Definition: arp-cache.cc:353
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.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
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.
bool AddAddress(Ipv4InterfaceAddress address)
Ptr< ArpCache > GetArpCache() const
Ipv4InterfaceAddress RemoveAddress(uint32_t index)
Implement the IPv4 layer.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
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:50
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.
Ipv6InterfaceAddress RemoveAddress(uint32_t index)
Remove an address from interface.
bool AddAddress(Ipv6InterfaceAddress iface)
Add an IPv6 address.
Ptr< NdiscCache > GetNdiscCache() const
IPv6 layer implementation.
Describes an IPv6 prefix.
Definition: ipv6-address.h:456
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
virtual NdiscCache::Entry * Add(Ipv6Address to)
Add an entry.
Definition: ndisc-cache.cc:134
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
void SetDynamicNeighborCache(bool enable)
Enable/diable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses chang...
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 AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:138
uint32_t GetId() const
Definition: node.cc:117
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:863
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Definition: packet.cc:393
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...
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:126
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1265
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:144
#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:251
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
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:691
channel
Definition: third.py:81
static NeighborCacheTestSuite g_neighborcacheTestSuite
Static variable for test initialization.