A Discrete-Event Network Simulator
API
ipv4-global-routing-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  */
16 
17 #include <vector>
18 #include "ns3/boolean.h"
19 #include "ns3/config.h"
20 #include "ns3/inet-socket-address.h"
21 #include "ns3/internet-stack-helper.h"
22 #include "ns3/ipv4-address-helper.h"
23 #include "ns3/ipv4-global-routing-helper.h"
24 #include "ns3/ipv4-static-routing-helper.h"
25 #include "ns3/node.h"
26 #include "ns3/node-container.h"
27 #include "ns3/packet.h"
28 #include "ns3/simple-net-device-helper.h"
29 #include "ns3/pointer.h"
30 #include "ns3/simulator.h"
31 #include "ns3/string.h"
32 #include "ns3/test.h"
33 #include "ns3/uinteger.h"
34 #include "ns3/ipv4-packet-info-tag.h"
35 #include "ns3/simple-net-device.h"
36 #include "ns3/simple-channel.h"
37 #include "ns3/socket-factory.h"
38 #include "ns3/udp-socket-factory.h"
39 
40 using namespace ns3;
41 
43 {
44 public:
47 
48 private:
49  void SendData (uint8_t index);
50  void ShutDownSock (uint8_t index);
51  void HandleRead (Ptr<Socket>);
52  virtual void DoRun (void);
53 
54  int m_count;
55  std::vector<std::pair<Ptr<Socket>, bool> > m_sendSocks;
57  uint16_t m_packetSize;
58  std::vector<uint8_t> m_firstInterface;
59  std::vector<uint8_t> m_secondInterface;
60 };
61 
62 // Add some help text to this case to describe what it is intended to test
64  : TestCase ("Dynamic global routing example"), m_count (0)
65 {
66  m_firstInterface.resize (16);
67  m_secondInterface.resize (16);
68  m_dataRate = DataRate ("2kbps");
69  m_packetSize = 50;
70 }
71 
73 {
74  std::vector<std::pair<Ptr<Socket>, bool> >::iterator iter;
75 
76  for (iter = m_sendSocks.begin (); iter != m_sendSocks.end (); iter++)
77  {
78  if (iter->second)
79  {
80  iter->second = false;
81  iter->first->Close ();
82  iter->first = 0;
83  }
84  }
85 }
86 
87 void
89 {
90  Ptr<Packet> packet;
91  Address from;
92  while ((packet = socket->RecvFrom (from)))
93  {
94  if (packet->GetSize () == 0)
95  { //EOF
96  break;
97  }
99  bool found;
100  found = packet->PeekPacketTag (tag);
101  uint8_t now = static_cast<uint8_t> (Simulator::Now ().GetSeconds ());
102  if (found)
103  {
104  if (tag.GetRecvIf () == 1)
105  {
106  m_firstInterface[now]++;
107  }
108  if (tag.GetRecvIf () == 2)
109  {
110  m_secondInterface[now]++;
111  }
112  m_count++;
113  }
114  }
115 }
116 
117 void
119 {
120  if (m_sendSocks[index].second == false)
121  {
122  return;
123  }
124  Ptr<Packet> packet = Create<Packet> (m_packetSize);
125  m_sendSocks[index].first->Send (packet);
126 
127  Time tNext (MicroSeconds (m_packetSize * 8 * 1e6 / m_dataRate.GetBitRate ()));
128  Simulator::Schedule (tNext, &Ipv4DynamicGlobalRoutingTestCase::SendData, this, index);
129 }
130 
131 void
133 {
134  m_sendSocks[index].second = false;
135  m_sendSocks[index].first->Close ();
136  m_sendSocks[index].first = 0;
137 }
138 
139 // Test derived from examples/routing/dynamic-global-routing.cc
140 //
141 // Network topology
142 //
143 // n0
144 // \ p-p
145 // \ (shared csma/cd)
146 // n2 -------------------------n3
147 // / | |
148 // / p-p n4 n5 ---------- n6
149 // n1 p-p
150 // | |
151 // ----------------------------------------
152 // p-p
153 //
154 // Test that for node n6, the interface facing n5 receives packets at
155 // times (1-2), (4-6), (8-10), (11-12), (14-16) and the interface
156 // facing n1 receives packets at times (2-4), (6-8), (12-13)
157 //
158 void
160 {
161  // The below value configures the default behavior of global routing.
162  // By default, it is disabled. To respond to interface events, set to true
163  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
164 
165  NodeContainer c;
166  c.Create (7);
167  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
168  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
169  NodeContainer n5n6 = NodeContainer (c.Get (5), c.Get (6));
170  NodeContainer n1n6 = NodeContainer (c.Get (1), c.Get (6));
171  NodeContainer n2345 = NodeContainer (c.Get (2), c.Get (3), c.Get (4), c.Get (5));
172 
173  InternetStackHelper internet;
174  internet.Install (c);
175 
176  // We create the channels first without any IP addressing information
177  SimpleNetDeviceHelper devHelper;
178 
179  devHelper.SetNetDevicePointToPointMode (true);
180  NetDeviceContainer d0d2 = devHelper.Install (n0n2);
181  devHelper.SetNetDevicePointToPointMode (false);
182 
183  NetDeviceContainer d1d6 = devHelper.Install (n1n6);
184  NetDeviceContainer d1d2 = devHelper.Install (n1n2);
185  NetDeviceContainer d5d6 = devHelper.Install (n5n6);
186  NetDeviceContainer d2345 = devHelper.Install (n2345);
187 
188  // Later, we add IP addresses.
189  Ipv4AddressHelper ipv4;
190  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
191  ipv4.Assign (d0d2);
192 
193  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
194  ipv4.Assign (d1d2);
195 
196  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
197  Ipv4InterfaceContainer i5i6 = ipv4.Assign (d5d6);
198 
199  ipv4.SetBase ("10.250.1.0", "255.255.255.0");
200  ipv4.Assign (d2345);
201 
202  ipv4.SetBase ("172.16.1.0", "255.255.255.0");
203  Ipv4InterfaceContainer i1i6 = ipv4.Assign (d1d6);
204 
205  // Create router nodes, initialize routing database and set up the routing
206  // tables in the nodes.
207  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
208 
209  // Create the applications to send UDP datagrams of size
210  // 50 bytes at a rate of 2 Kb/s
211  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
212  uint16_t port = 9; // Discard port (RFC 863)
213 
214  std::pair<Ptr<Socket>, bool> sendSockA;
215  sendSockA.first = Socket::CreateSocket (c.Get (1), tid);
216  sendSockA.first->Bind ();
217  sendSockA.first->Connect (InetSocketAddress (i5i6.GetAddress (1), port));
218  sendSockA.second = true;
219  m_sendSocks.push_back (sendSockA);
220  Simulator::Schedule (Seconds (1.0), &Ipv4DynamicGlobalRoutingTestCase::SendData, this, 0);
221  Simulator::Schedule (Seconds (10.0), &Ipv4DynamicGlobalRoutingTestCase::ShutDownSock, this, 0);
222 
223  std::pair<Ptr<Socket>, bool> sendSockB;
224  sendSockB.first = Socket::CreateSocket (c.Get (1), tid);
225  sendSockB.first->Bind ();
226  sendSockB.first->Connect (InetSocketAddress (i1i6.GetAddress (1), port));
227  sendSockB.second = true;
228  m_sendSocks.push_back (sendSockB);
229  Simulator::Schedule (Seconds (11.0), &Ipv4DynamicGlobalRoutingTestCase::SendData, this, 1);
230  Simulator::Schedule (Seconds (16.0), &Ipv4DynamicGlobalRoutingTestCase::ShutDownSock, this, 1);
231 
232 
233  // Create an optional packet sink to receive these packets
234  Ptr<Socket> sink2 = Socket::CreateSocket (c.Get (6), tid);
235  sink2->Bind (Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
236  sink2->Listen ();
237  sink2->ShutdownSend ();
238 
239  sink2->SetRecvPktInfo (true);
241 
242  Ptr<Node> n1 = c.Get (1);
243  Ptr<Ipv4> ipv41 = n1->GetObject<Ipv4> ();
244  // The first ifIndex is 0 for loopback, then the first p2p is numbered 1,
245  // then the next p2p is numbered 2
246  uint32_t ipv4ifIndex1 = 2;
247 
248  Simulator::Schedule (Seconds (2), &Ipv4::SetDown,ipv41, ipv4ifIndex1);
249  Simulator::Schedule (Seconds (4), &Ipv4::SetUp,ipv41, ipv4ifIndex1);
250 
251  Ptr<Node> n6 = c.Get (6);
252  Ptr<Ipv4> ipv46 = n6->GetObject<Ipv4> ();
253  // The first ifIndex is 0 for loopback, then the first p2p is numbered 1,
254  // then the next p2p is numbered 2
255  uint32_t ipv4ifIndex6 = 2;
256  Simulator::Schedule (Seconds (6), &Ipv4::SetDown,ipv46, ipv4ifIndex6);
257  Simulator::Schedule (Seconds (8), &Ipv4::SetUp,ipv46, ipv4ifIndex6);
258 
259  Simulator::Schedule (Seconds (12), &Ipv4::SetDown,ipv41, ipv4ifIndex1);
260  Simulator::Schedule (Seconds (14), &Ipv4::SetUp,ipv41, ipv4ifIndex1);
261 
262  Simulator::Run ();
263 
264  NS_TEST_ASSERT_MSG_EQ (m_count, 70, "Dynamic global routing did not deliver all packets");
265 // Test that for node n6, the interface facing n5 receives packets at
266 // times (1-2), (4-6), (8-10), (11-12), (14-16) and the interface
267 // facing n1 receives packets at times (2-4), (6-8), (12-13)
268  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[1], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[1]));
269  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[2], 5, "Dynamic global routing did not deliver all packets " << int(m_secondInterface[2]));
270  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[3], 5, "Dynamic global routing did not deliver all packets " << int(m_secondInterface[3]));
271  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[4], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[4]));
272  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[5], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[5]));
273  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[6], 5, "Dynamic global routing did not deliver all packets " << int(m_secondInterface[6]));
274  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[7], 5, "Dynamic global routing did not deliver all packets " << int(m_secondInterface[7]));
275  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[8], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[8]));
276  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[9], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[9]));
277  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[10], 0, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[10]));
278  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[11], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[11]));
279  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[12], 5, "Dynamic global routing did not deliver all packets " << int(m_secondInterface[12]));
280  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[13], 5, "Dynamic global routing did not deliver all packets " << int(m_secondInterface[13]));
281  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[14], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[14]));
282  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[15], 5, "Dynamic global routing did not deliver all packets " << int(m_firstInterface[15]));
283  Simulator::Destroy ();
284 }
285 
287 {
288 public:
291 
293  void ReceivePkt (Ptr<Socket> socket);
294  void DoSendData (Ptr<Socket> socket, std::string to);
295  void SendData (Ptr<Socket> socket, std::string to);
296 
297 private:
298  virtual void DoRun (void);
299 };
300 
301 // Add some help text to this case to describe what it is intended to test
303  : TestCase ("Slash 32 global routing example")
304 {
305 }
306 
308 {
309 }
310 
311 void
313 {
314  uint32_t availableData;
315  availableData = socket->GetRxAvailable ();
316  m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
317  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
318  //cast availableData to void, to suppress 'availableData' set but not used
319  //compiler warning
320  (void) availableData;
321 }
322 
323 void
325 {
326  Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 1234);
327  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create<Packet> (123), 0, realTo),
328  123, "100");
329 }
330 
331 void
333 {
334  m_receivedPacket = Create<Packet> ();
335  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (60),
337  Simulator::Stop (Seconds (66));
338  Simulator::Run ();
339 }
340 
341 // Test program for this 3-router scenario, using global routing
342 //
343 // (a.a.a.a/32)A<--x.x.x.0/30-->B<--y.y.y.0/30-->C(c.c.c.c/32)
344 //
345 void
347 {
348  Ptr<Node> nA = CreateObject<Node> ();
349  Ptr<Node> nB = CreateObject<Node> ();
350  Ptr<Node> nC = CreateObject<Node> ();
351 
352  NodeContainer c = NodeContainer (nA, nB, nC);
353 
354  InternetStackHelper internet;
355  internet.Install (c);
356 
357  // simple links
358  NodeContainer nAnB = NodeContainer (nA, nB);
359  NodeContainer nBnC = NodeContainer (nB, nC);
360 
361  SimpleNetDeviceHelper devHelper;
362 
363  Ptr<SimpleNetDevice> deviceA = CreateObject<SimpleNetDevice> ();
364  deviceA->SetAddress (Mac48Address::Allocate ());
365  nA->AddDevice (deviceA);
366 
367  NetDeviceContainer dAdB = devHelper.Install (nAnB);
368  NetDeviceContainer dBdC = devHelper.Install (nBnC);
369 
370  Ptr<SimpleNetDevice> deviceC = CreateObject<SimpleNetDevice> ();
371  deviceC->SetAddress (Mac48Address::Allocate ());
372  nC->AddDevice (deviceC);
373 
374  // Later, we add IP addresses.
375  Ipv4AddressHelper ipv4;
376  ipv4.SetBase ("10.1.1.0", "255.255.255.252");
377  Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
378 
379  ipv4.SetBase ("10.1.1.4", "255.255.255.252");
380  Ipv4InterfaceContainer iBiC = ipv4.Assign (dBdC);
381 
382  Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
383  Ptr<Ipv4> ipv4B = nB->GetObject<Ipv4> ();
384  Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
385 
386  int32_t ifIndexA = ipv4A->AddInterface (deviceA);
387  int32_t ifIndexC = ipv4C->AddInterface (deviceC);
388 
389  Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("/32"));
390  ipv4A->AddAddress (ifIndexA, ifInAddrA);
391  ipv4A->SetMetric (ifIndexA, 1);
392  ipv4A->SetUp (ifIndexA);
393 
394  Ipv4InterfaceAddress ifInAddrC = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.1"), Ipv4Mask ("/32"));
395  ipv4C->AddAddress (ifIndexC, ifInAddrC);
396  ipv4C->SetMetric (ifIndexC, 1);
397  ipv4C->SetUp (ifIndexC);
398 
399  // Create router nodes, initialize routing database and set up the routing
400  // tables in the nodes.
401  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
402 
403  // Create the UDP sockets
404  Ptr<SocketFactory> rxSocketFactory = nC->GetObject<UdpSocketFactory> ();
405  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
406  NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (InetSocketAddress (Ipv4Address ("192.168.1.1"), 1234)), 0, "trivial");
407  rxSocket->SetRecvCallback (MakeCallback (&Ipv4GlobalRoutingSlash32TestCase::ReceivePkt, this));
408 
409  Ptr<SocketFactory> txSocketFactory = nA->GetObject<UdpSocketFactory> ();
410  Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
411  txSocket->SetAllowBroadcast (true);
412 
413  // ------ Now the tests ------------
414 
415  // Unicast test
416  SendData (txSocket, "192.168.1.1");
417  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "Static routing with /32 did not deliver all packets.");
418 
419  Simulator::Destroy ();
420 }
421 
422 
424 {
425 public:
427 };
428 
430  : TestSuite ("ipv4-global-routing", UNIT)
431 {
432  AddTestCase (new Ipv4DynamicGlobalRoutingTestCase, TestCase::QUICK);
433  AddTestCase (new Ipv4GlobalRoutingSlash32TestCase, TestCase::QUICK);
434 }
435 
436 // Do not forget to allocate an instance of this TestSuite
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
an Inet address class
AttributeValue implementation for Boolean.
Definition: boolean.h:34
Definition: second.py:1
virtual void DoRun(void)
Implementation to actually run this TestCase.
NodeContainer n1n2
Definition: red-tests.cc:63
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
holds a vector of std::pair of Ptr and interface index.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:455
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:226
virtual int ShutdownSend(void)=0
A suite of tests to run.
Definition: test.h:1333
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
aggregate IP/TCP/UDP functionality to existing Nodes.
#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:278
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:786
virtual Ptr< Socket > CreateSocket(void)=0
encapsulates test code
Definition: test.h:1147
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
void SetUp(char *deviceName)
virtual int Listen(void)=0
Listen for incoming connections.
std::vector< std::pair< Ptr< Socket >, bool > > m_sendSocks
Class for representing data rates.
Definition: data-rate.h:88
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
Definition: socket.cc:358
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:844
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:297
virtual void SetUp(uint32_t interface)=0
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
#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:161
void DoSendData(Ptr< Socket > socket, std::string to)
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1480
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:249
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SendData(Ptr< Socket > socket, std::string to)
static Ipv4GlobalRoutingTestSuite globalRoutingTestSuite
NodeContainer n0n2
Definition: red-tests.cc:62
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:121
uint32_t GetId(void) const
Definition: node.cc:107
a class to store IPv4 address information on an interface
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
virtual void SetAddress(Address address)
Set the address of this interface.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:330
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
API to create UDP socket instances.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
build a set of SimpleNetDevice objects
a unique identifier for an interface.
Definition: type-id.h:58
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.