|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/socket-factory.h"
23 #include "ns3/udp-socket-factory.h"
24 #include "ns3/simulator.h"
25 #include "ns3/socket.h"
27 #include "ns3/internet-stack-helper.h"
28 #include "ns3/ipv4-address-helper.h"
29 #include "ns3/ipv4-l3-protocol.h"
30 #include "ns3/icmpv4-l4-protocol.h"
31 #include "ns3/ipv6-address-helper.h"
32 #include "ns3/ipv6-l3-protocol.h"
33 #include "ns3/icmpv6-l4-protocol.h"
34 #include "ns3/udp-l4-protocol.h"
35 #include "ns3/simple-net-device-helper.h"
36 #include "ns3/nix-vector-helper.h"
101 virtual void DoRun (
void);
114 :
TestCase (
"three router, two path test")
120 uint32_t availableData;
124 "availableData should be equal to the size of packet received.");
133 socket->
SendTo (Create<Packet> (123), 0, realTo);
140 socket->
SendTo (Create<Packet> (123), 0, realTo);
147 Simulator::ScheduleWithContext (socket->
GetNode ()->
GetId (), delay,
155 Simulator::ScheduleWithContext (socket->
GetNode ()->
GetId (), delay,
171 nAnB.
Add (nSrcnA.
Get (1));
177 nCnDst.
Add (nBnC.
Get (1));
181 nAnC.
Add (nCnDst.
Get (0));
188 std::ostringstream stringStream1v4;
190 std::ostringstream stringStream1v6;
192 std::ostringstream stringStream2v4;
194 std::ostringstream stringStream2v6;
196 std::ostringstream stringStream3v4;
198 std::ostringstream stringStream3v6;
205 stack.SetRoutingHelper (ipv4NixRouting);
206 stack.SetRoutingHelper (ipv6NixRouting);
207 stack.Install (allNodes);
214 dSrcdA = devHelper.
Install (nSrcnA);
215 dAdB = devHelper.
Install (nAnB);
216 dBdC = devHelper.
Install (nBnC);
217 dCdDst = devHelper.
Install (nCnDst);
218 dAdC = devHelper.
Install (nAnC);
221 aSrcaAv4.
SetBase (
"10.1.0.0",
"255.255.255.0");
223 aAaBv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
225 aBaCv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
227 aCaDstv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
229 aAaCv4.
SetBase (
"10.1.4.0",
"255.255.255.0");
276 Simulator::Schedule (
Seconds (5), &Ipv4::SetDown, ipv4, ifIndex);
281 Simulator::Schedule (
Seconds (5), &Ipv6::SetDown, ipv6, ifIndex);
283 ipv4NixRouting.PrintRoutingTableAllAt (
Seconds (7), cacheStreamv4);
284 ipv6NixRouting.PrintRoutingTableAllAt (
Seconds (7), cacheStreamv6);
295 Simulator::Schedule (
Seconds (10), &Ipv4::SetDown, ipv4, ifIndex);
300 Simulator::Schedule (
Seconds (10), &Ipv6::SetDown, ipv6, ifIndex);
305 Simulator::Stop (
Seconds (66));
316 const std::string p_nSrcnAnCnDstv4 =
"Time: +3s, Nix Routing\n"
317 "Route Path: (Node 0 to Node 4, Nix Vector: 01001)\n"
318 "10.1.0.1 (Node 0) ----> 10.1.0.2 (Node 1)\n"
319 "10.1.4.1 (Node 1) ----> 10.1.4.2 (Node 3)\n"
320 "10.1.3.1 (Node 3) ----> 10.1.3.2 (Node 4)\n\n";
323 const std::string p_nSrcnAnCnDstv6 =
"Time: +3s, Nix Routing\n"
324 "Route Path: (Node 0 to Node 4, Nix Vector: 01001)\n"
325 "2001::200:ff:fe00:1 (Node 0) ----> fe80::200:ff:fe00:2 (Node 1)\n"
326 "fe80::200:ff:fe00:9 (Node 1) ----> fe80::200:ff:fe00:a (Node 3)\n"
327 "fe80::200:ff:fe00:7 (Node 3) ----> 2001:3::200:ff:fe00:8 (Node 4)\n\n";
330 const std::string p_nSrcnAnBnCnDstv4 =
"Time: +9s, Nix Routing\n"
331 "Route Path: (Node 0 to Node 4, Nix Vector: 0111)\n"
332 "10.1.0.1 (Node 0) ----> 10.1.0.2 (Node 1)\n"
333 "10.1.1.1 (Node 1) ----> 10.1.1.2 (Node 2)\n"
334 "10.1.2.1 (Node 2) ----> 10.1.2.2 (Node 3)\n"
335 "10.1.3.1 (Node 3) ----> 10.1.3.2 (Node 4)\n\n";
338 const std::string p_nSrcnAnBnCnDstv6 =
"Time: +9s, Nix Routing\n"
339 "Route Path: (Node 0 to Node 4, Nix Vector: 0111)\n"
340 "2001::200:ff:fe00:1 (Node 0) ----> fe80::200:ff:fe00:2 (Node 1)\n"
341 "fe80::200:ff:fe00:3 (Node 1) ----> fe80::200:ff:fe00:4 (Node 2)\n"
342 "fe80::200:ff:fe00:5 (Node 2) ----> fe80::200:ff:fe00:6 (Node 3)\n"
343 "fe80::200:ff:fe00:7 (Node 3) ----> 2001:3::200:ff:fe00:8 (Node 4)\n\n";
346 const std::string emptyCaches =
"Node: 0, Time: +7s, Local time: +7s, Nix Routing\n"
349 "Node: 1, Time: +7s, Local time: +7s, Nix Routing\n"
352 "Node: 2, Time: +7s, Local time: +7s, Nix Routing\n"
355 "Node: 3, Time: +7s, Local time: +7s, Nix Routing\n"
358 "Node: 4, Time: +7s, Local time: +7s, Nix Routing\n"
364 Simulator::Destroy ();
holds a vector of ns3::NetDevice pointers
The topology is of the form:
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
API to create UDP socket instances.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t GetId(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
Get the interface index of the specified NetDevice.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
void SendData(Time delay, Ptr< Socket > socket, Ipv4Address to)
Schedules the DoSendData () function to send the data.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Helper class to auto-assign global IPv6 unicast addresses.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Access to the IPv4 forwarding table, interfaces, and configuration.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Helper class that adds Nix-vector routing to nodes.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
a polymophic address class
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
#define NS_UNUSED(x)
Mark a local variable as unused.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Keep track of a set of IPv6 interfaces.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
build a set of SimpleNetDevice objects
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Simulation virtual time values and global simulation resolution.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual Ptr< Socket > CreateSocket(void)=0
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void DoSendDatav6(Ptr< Socket > socket, Ipv6Address to)
Send data immediately after being called.
void DoSendDatav4(Ptr< Socket > socket, Ipv4Address to)
Send data immediately after being called.
#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.
Ptr< Packet > m_receivedPacket
Received packet.
@ UNIT
This test suite implements a Unit Test.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
std::vector< uint32_t > m_receivedPacketSizes
Received packet sizes.
keep track of a set of node pointers.
Access to the IPv6 forwarding table, interfaces, and configuration.
static NixVectorRoutingTestSuite g_nixVectorRoutingTestSuite
Static variable for test initialization.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
NixVectorRoutingTestSuite()
IPv4 Nix-Vector Routing TestSuite.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
Describes an IPv6 prefix.
aggregate IP/TCP/UDP functionality to existing Nodes.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void PrintRoutingPathAt(Time printTime, Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing path for a source and destination at a particular time.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.