23#include "ns3/boolean.h"
24#include "ns3/double.h"
25#include "ns3/internet-stack-helper.h"
26#include "ns3/ipv4-address-helper.h"
27#include "ns3/ipv4-raw-socket-factory.h"
28#include "ns3/olsr-header.h"
29#include "ns3/olsr-helper.h"
30#include "ns3/random-variable-stream.h"
31#include "ns3/rng-seed-manager.h"
32#include "ns3/simple-net-device-helper.h"
33#include "ns3/simple-net-device.h"
34#include "ns3/simulator.h"
35#include "ns3/socket-factory.h"
36#include "ns3/string.h"
37#include "ns3/udp-header.h"
38#include "ns3/udp-l4-protocol.h"
39#include "ns3/uinteger.h"
47 :
TestCase(
"Test OLSR Topology Control message generation"),
85 internet.SetRoutingHelper(
olsr);
87 int64_t streamsUsed =
olsr.AssignStreams(c, 0);
100 ch->BlackList(nd0, nd2);
101 ch->BlackList(nd2, nd0);
105 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
110 m_rxSocketA = DynamicCast<Ipv4RawSocketImpl>(rxSocketFactoryA->CreateSocket());
115 m_rxSocketB = DynamicCast<Ipv4RawSocketImpl>(rxSocketFactoryB->CreateSocket());
120 m_rxSocketC = DynamicCast<Ipv4RawSocketImpl>(rxSocketFactoryC->CreateSocket());
130 availableData = socket->GetRxAvailable();
131 Ptr<Packet> receivedPacketProbe = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
132 NS_ASSERT(availableData == receivedPacketProbe->GetSize());
135 receivedPacketProbe->RemoveHeader(ipHdr);
137 receivedPacketProbe->RemoveHeader(udpHdr);
139 receivedPacketProbe->RemoveHeader(pktHdr);
144 receivedPacketProbe->RemoveHeader(msgHdr);
148 "Originator address.");
154 receivedPacketProbe->RemoveHeader(msgHdr);
157 "Originator address.");
180 receivedPacketProbe->RemoveHeader(msgHdr);
184 "Originator address.");
187 int(
m_countA) <<
" - TC, one message.");
198 receivedPacketProbe->RemoveHeader(msgHdr);
201 "Originator address.");
205 int(
m_countA) <<
" - Hello, one message.");
208 int(
m_countA) <<
" - Symmetric Link.");
217 int(
m_countA) <<
" - Symmetric Link.");
233 availableData = socket->GetRxAvailable();
234 Ptr<Packet> receivedPacketProbe = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
235 NS_ASSERT(availableData == receivedPacketProbe->GetSize());
238 receivedPacketProbe->RemoveHeader(ipHdr);
240 receivedPacketProbe->RemoveHeader(udpHdr);
242 receivedPacketProbe->RemoveHeader(pktHdr);
245 receivedPacketProbe->RemoveHeader(msgHdr);
253 "Originator address.");
259 "Originator address.");
266 int(
m_countC) <<
" - Hello, links announced.");
272 int(
m_countC) <<
" - Hello, links announced.");
277 int(
m_countC) <<
" - Asymmetric Link.");
283 int(
m_countC) <<
" - Symmetric Link.");
305 availableData = socket->GetRxAvailable();
306 Ptr<Packet> receivedPacketProbe = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
307 NS_ASSERT(availableData == receivedPacketProbe->GetSize());
310 receivedPacketProbe->RemoveHeader(ipHdr);
312 receivedPacketProbe->RemoveHeader(udpHdr);
314 receivedPacketProbe->RemoveHeader(pktHdr);
319 receivedPacketProbe->RemoveHeader(msgHdr);
323 "Originator address.");
329 receivedPacketProbe->RemoveHeader(msgHdr);
332 "Originator address.");
355 receivedPacketProbe->RemoveHeader(msgHdr);
359 "Originator address.");
362 int(
m_countC) <<
" - TC, one message.");
373 receivedPacketProbe->RemoveHeader(msgHdr);
376 "Originator address.");
380 int(
m_countC) <<
" - Hello, one message.");
383 int(
m_countC) <<
" - Symmetric Link.");
392 int(
m_countC) <<
" - Symmetric Link.");
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
API to create RAW socket instances.
void SetProtocol(uint16_t protocol)
Set protocol field.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Helper class that adds OLSR routing to nodes.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
build a set of SimpleNetDevice objects
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Hold variables of type string.
static const uint8_t PROT_NUMBER
protocol number (0x11)
void CreateNodes()
Create & configure test network.
void ReceivePktProbeB(Ptr< Socket > socket)
Receive raw data on node B.
~TcRegressionTest() override
uint8_t m_countB
Packet counter on node B.
Ptr< Ipv4RawSocketImpl > m_rxSocketB
Receiving socket on node B.
void ReceivePktProbeC(Ptr< Socket > socket)
Receive raw data on node C.
uint8_t m_countC
Packet counter on node C.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< Ipv4RawSocketImpl > m_rxSocketC
Receiving socket on node C.
void ReceivePktProbeA(Ptr< Socket > socket)
Receive raw data on node A.
const Time m_time
Total simulation time.
Ptr< Ipv4RawSocketImpl > m_rxSocketA
Receiving socket on node A.
uint8_t m_countA
Packet counter on node A.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
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...