22 #include "ns3/simulator.h" 23 #include "ns3/random-variable-stream.h" 24 #include "ns3/rng-seed-manager.h" 25 #include "ns3/boolean.h" 26 #include "ns3/double.h" 27 #include "ns3/uinteger.h" 28 #include "ns3/string.h" 29 #include "ns3/olsr-helper.h" 30 #include "ns3/internet-stack-helper.h" 31 #include "ns3/ipv4-address-helper.h" 32 #include "ns3/abort.h" 33 #include "ns3/socket-factory.h" 34 #include "ns3/ipv4-raw-socket-factory.h" 35 #include "ns3/udp-l4-protocol.h" 36 #include "ns3/udp-header.h" 37 #include "ns3/olsr-header.h" 38 #include "ns3/simple-net-device-helper.h" 39 #include "ns3/simple-net-device.h" 45 TestCase (
"Test OLSR Topology Control message generation"),
47 m_countA (0), m_countB (0), m_countC (0)
83 int64_t streamsUsed =
olsr.AssignStreams (c, 0);
96 ch->BlackList (nd0, nd2);
97 ch->BlackList (nd2, nd0);
101 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
106 m_rxSocketA = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryA->CreateSocket ());
111 m_rxSocketB = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryB->CreateSocket ());
116 m_rxSocketC = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryC->CreateSocket ());
125 uint32_t availableData;
153 NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses.size (), 1,
"1 - Neighbor.");
156 NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses.size (), 1,
"1 - Neighbor.");
192 uint32_t availableData;
248 uint32_t availableData;
276 NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses.size (), 1,
"1 - Neighbor.");
279 NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses.size (), 1,
"1 - Neighbor.");
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void CreateNodes()
Create & configure test network.
Smart pointer class similar to boost::intrusive_ptr.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Hold variables of type string.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
static void Run(void)
Run the simulation.
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.
Helper class that adds OLSR routing to nodes.
API to create RAW socket instances.
void ReceivePktProbeC(Ptr< Socket > socket)
Receive raw data on node C.
Ptr< Ipv4RawSocketImpl > m_rxSocketB
Receiving socket on node B.
uint8_t m_countA
Packet counter on node A.
static void SetRun(uint64_t run)
Set the run number of simulation.
void ReceivePktProbeA(Ptr< Socket > socket)
Receive raw data on node A.
void DoRun()
Implementation to actually run this TestCase.
holds a vector of ns3::NetDevice pointers
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Ptr< Ipv4RawSocketImpl > m_rxSocketC
Receiving socket on node C.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
void ReceivePktProbeB(Ptr< Socket > socket)
Receive raw data on node B.
uint8_t m_countC
Packet counter on node C.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
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.
Ptr< Ipv4RawSocketImpl > m_rxSocketA
Receiving socket on node A.
static void SetSeed(uint32_t seed)
Set the seed.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4 addresses are stored in host order in this class.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
const Time m_time
Total simulation time.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
build a set of SimpleNetDevice objects
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static const uint8_t PROT_NUMBER
protocol number (0x11)
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
void SetProtocol(uint16_t protocol)
Set protocol field.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
uint8_t m_countB
Packet counter on node B.