A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
aodv-regression.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Pavel Boyko <boyko@iitp.ru>
7 */
8
9#ifndef AODV_REGRESSION_H
10#define AODV_REGRESSION_H
11
12#include "ns3/node-container.h"
13#include "ns3/nstime.h"
14#include "ns3/socket.h"
15#include "ns3/test.h"
16
17using namespace ns3;
18
19/**
20 * \ingroup aodv
21 *
22 * \brief AODV chain regression test
23 *
24 * This script creates 1-dimensional grid topology and then ping last node from the first one:
25 */
26// clang-format off
27/**
28 * [10.1.1.1] <-- step --> [10.1.1.2] <-- step --> [10.1.1.3] <-- step --> [10.1.1.4] <-- step --> [10.1.1.5]
29 */
30// clang-format on
31/**
32 * Each node can hear only his right and his left neighbor, if they exist.
33 * When one third of total time expired, central node moves away.
34 * After this, node 3 doesn't hear any packets from other nodes and nobody hears his packets.
35 * We want to demonstrate in this script
36 * 1) route establishing
37 * 2) broken link detection both from layer 2 information and hello messages.
38 *
39 */
40// clang-format off
41/**
42 * \verbatim
43 Expected packets time diagram.
44
45 1 2 3 4 5
46 <-------|------>| | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, U=1, hop=0, ID=1, org_seqno=1) src = 10.1.1.1
47 |<------|------>| | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, U=1, hop=1, ID=1, org_seqno=1) src = 10.1.1.2
48 | |<------|------>| | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, U=1, hop=2, ID=1, org_seqno=1) src = 10.1.1.3
49 | | |<------|------>| RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, U=1, hop=3, ID=1, org_seqno=1) src = 10.1.1.4
50 | | | |<------|------> ARP request. Who has 10.1.1.4? Tell 10.1.1.5
51 | | | |======>| ARP reply
52 | | | |<======| RREP (orig 10.1.1.1, dst 10.1.1.5, hop=0, dst_seqno=0) src=10.1.1.5
53 | | |<------|------>| ARP request. Who has 10.1.1.3? Tell 10.1.1.4
54 | | |======>| | ARP reply
55 | | |<======| | RREP (orig 10.1.1.1, dst 10.1.1.5, hop=1, dst_seqno=0) src=10.1.1.4
56 | |<------|------>| | ARP request. Who has 10.1.1.2? Tell 10.1.1.3
57 | |======>| | | ARP reply
58 | |<======| | | RREP (orig 10.1.1.1, dst 10.1.1.5, hop=2, dst_seqno=0) src=10.1.1.3
59 |<------|------>| | | ARP request. Who has 10.1.1.1? Tell 10.1.1.2
60 |======>| | | | ARP reply
61 |<======| | | | RREP (orig 10.1.1.1, dst 10.1.1.5, hop=3, dst_seqno=0) src=10.1.1.2
62 <-------|------>| | | | ARP request. Who has 10.1.1.2? Tell 10.1.1.1
63 |<======| | | |
64 |======>| | | | ICMP (ping) request 0 from 10.1.1.1 to 10.1.1.5; src=10.1.1.1 next_hop=10.1.1.2
65 |<------|------>| | | ARP request. Who has 10.1.1.3? Tell 10.1.1.2
66 | |<======| | | ARP reply
67 | |======>| | | ICMP (ping) request 0 from 10.1.1.1 to 10.1.1.5; src=10.1.1.2 next_hop=10.1.1.3
68 | |<------|------>| | ARP request. Who has 10.1.1.4? Tell 10.1.1.3
69 | | |<======| | ARP reply
70 | | |======>| | ICMP (ping) request 0 from 10.1.1.1 to 10.1.1.5; src=10.1.1.3 next_hop=10.1.1.4
71 | | |<------|------>| ARP request. Who has 10.1.1.5? Tell 10.1.1.4
72 | | | |<======| ARP reply
73 | | | |======>| ICMP (ping) request 0; src=10.1.1.4 next_hop=10.1.1.5
74 | | | |<======| ICMP (ping) reply 0; src=10.1.1.5 next_hop=10.1.1.4
75 | | |<======| | ICMP (ping) reply 0; src=10.1.1.4 next_hop=10.1.1.3
76 | |<======| | | ICMP (ping) reply 0; src=10.1.1.3 next_hop=10.1.1.2
77 |<======| | | | ICMP (ping) reply 0; src=10.1.1.2 next_hop=10.1.1.1
78 | | | |<------|------> Hello
79 |<------|------>| | | Hello
80 <-------|------>| | | | Hello
81 | |<------|------>| | Hello
82 |======>| | | | ICMP (ping) request 1; src=10.1.1.1 next_hop=10.1.1.2
83 | | |<------|------>| Hello
84 | |======>| | | ICMP (ping) request 1; src=10.1.1.2 next_hop=10.1.1.3
85 | | |======>| | ICMP (ping) request 1; src=10.1.1.3 next_hop=10.1.1.4
86 | | | |======>| ICMP (ping) request 1; src=10.1.1.4 next_hop=10.1.1.5
87 | | | |<======| ICMP (ping) reply 1; src=10.1.1.5 next_hop=10.1.1.4
88 | | |<======| | ICMP (ping) reply 1; src=10.1.1.4 next_hop=10.1.1.3
89 | |<======| | | ICMP (ping) reply 11; src=10.1.1.3 next_hop=10.1.1.2
90 |<======| | | | ICMP (ping) reply 1; src=10.1.1.2 next_hop=10.1.1.1
91 | | | |<------|------> Hello
92 |<------|------>| | | Hello
93 <-------|------>| | | | Hello
94 | | |<------|------>| Hello
95 | |<------|------>| | Hello
96 |======>| | | | ICMP (ping) request 2; src=10.1.1.1 next_hop=10.1.1.2
97 | |======>| | | ICMP (ping) request 2; src=10.1.1.2 next_hop=10.1.1.3
98 | | |======>| | ICMP (ping) request 2; src=10.1.1.3 next_hop=10.1.1.4
99 | | | |======>| ICMP (ping) request 2; src=10.1.1.4 next_hop=10.1.1.5
100 | | | |<======| ICMP (ping) reply 2; src=10.1.1.5 next_hop=10.1.1.4
101 | | |<======| | ICMP (ping) reply 2; src=10.1.1.4 next_hop=10.1.1.3
102 | |<======| | | ICMP (ping) reply 2; src=10.1.1.3 next_hop=10.1.1.2
103 |<======| | | | ICMP (ping) reply 2; src=10.1.1.2 next_hop=10.1.1.1
104 | | | |<------|------> Hello
105 <-------|------>| | | | Hello
106 | |<------|------>| | Hello
107 |<------|------>| | | Hello
108 | | |<------|------>| Hello
109 |======>| | | | ICMP (ping) request 3; src=10.1.1.1 next_hop=10.1.1.2
110 | |======>| | | ICMP (ping) request 3; src=10.1.1.2 next_hop=10.1.1.3
111 | | |======>| | ICMP (ping) request 3; src=10.1.1.3 next_hop=10.1.1.4
112 | | | |======>| ICMP (ping) request 3; src=10.1.1.4 next_hop=10.1.1.5
113 | | | |<======| ICMP (ping) reply 3; src=10.1.1.5 next_hop=10.1.1.4
114 | | |<======| | ICMP (ping) reply 3; src=10.1.1.4 next_hop=10.1.1.3
115 | |<======| | | ICMP (ping) reply 3; src=10.1.1.3 next_hop=10.1.1.2
116 |<======| | | | ICMP (ping) reply 3; src=10.1.1.2 next_hop=10.1.1.1
117 | | | |<------|------> Hello
118 <-------|------>| | | | Hello
119 |<------|--> | | | Hello |
120 | | <--|--> | | Hello |Node 3 move away => nobody hear his packets and node 3 doesn't hear anything !
121 | | | <--|------>| Hello |
122 |======>| | | | ICMP (ping) request 4; src=10.1.1.1 next_hop=10.1.1.2
123 | |==> | | | ICMP (ping) request 4; src=10.1.1.2 next_hop=10.1.1.3. 7 retries.
124 |<======| | | | RERR (unreachable dst 10.1.1.3 & 10.1.1.5) src=10.1.1.2
125 | | | |<------|------> Hello
126 <-------|------>| | | | Hello
127 |<------|--> | | | Hello
128 | | <--|--> | | Hello
129 | | | <--|------>| Hello
130 <-------|------>| | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=0, ID=2, org_seqno=2) src = 10.1.1.1
131 |<------|--> | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=1, ID=2, org_seqno=2) src = 10.1.1.2
132 | | | |<------|------> Hello
133 | | | <--|------>| Hello
134 | | <--|--> | | Hello
135 |<------|--> | | | Hello
136 <-------|------>| | | | Hello
137 | | | |======>| RERR (unreachable dst 10.1.1.1 & 10.1.1.3) src=10.1.1.4
138 | | | |<------|------> Hello
139 | | | <--|------>| Hello
140 | | <--|--> | | Hello
141 |<------|--> | | | Hello
142 <-------|------>| | | | Hello
143 | | | |<------|------> Hello
144 <-------|------>| | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=0, ID=4, org_seqno=3) src = 10.1.1.1
145 |<------|--> | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=1, ID=4, org_seqno=3) src = 10.1.1.2
146 .................................................
147 \endverbatim
148 */
149//clang-format on
151{
152 public:
153 /**
154 * Create test case
155 *
156 * \param prefix Unique file names prefix
157 * \param size Number of nodes in the chain
158 * \param time Simulation time
159 * \param arpAliveTimeout ARP alive timeout, this is used to check that ARP and routing do
160 * not interfere
161 */
162 ChainRegressionTest(const char* const prefix,
163 Time time = Seconds(10),
164 uint32_t size = 5,
165 Time arpAliveTimeout = Seconds(120));
166 ~ChainRegressionTest() override;
167
168 private:
169 /// \internal It is important to have pointers here
171
172 /// PCAP file names prefix
173 const std::string m_prefix;
174 /// Total simulation time
176 /// Chain size
178 /// Chain step, meters
179 const double m_step;
180 /// ARP alive timeout
182 /// Socket
184 /// Sequence number
185 uint16_t m_seq;
186
187 /// Create test topology
188 void CreateNodes();
189 /// Create devices, install TCP/IP stack and applications
190 void CreateDevices();
191 /// Compare traces with reference ones
192 void CheckResults();
193 /// Go
194 void DoRun() override;
195 /// Send one ping
196 void SendPing();
197};
198
199#endif /* AODV_REGRESSION_H */
AODV chain regression test.
const uint32_t m_size
Chain size.
void CreateNodes()
Create test topology.
void DoRun() override
Go.
uint16_t m_seq
Sequence number.
void SendPing()
Send one ping.
const Time m_arpAliveTimeout
ARP alive timeout.
const double m_step
Chain step, meters.
~ChainRegressionTest() override
NodeContainer * m_nodes
void CheckResults()
Compare traces with reference ones.
const Time m_time
Total simulation time.
const std::string m_prefix
PCAP file names prefix.
Ptr< Socket > m_socket
Socket.
void CreateDevices()
Create devices, install TCP/IP stack and applications.
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
encapsulates test code
Definition test.h:1050
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
ChainRegressionTest(const char *const prefix, Time time=Seconds(10), uint32_t size=5, Time arpAliveTimeout=Seconds(120))
Create test case.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.