|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
20 #include "ns3/config.h"
21 #include "ns3/string.h"
22 #include "ns3/node-list.h"
23 #include "ns3/mobility-model.h"
24 #include "ns3/yans-wifi-helper.h"
25 #include "ns3/mobility-helper.h"
26 #include "ns3/wave-net-device.h"
27 #include "ns3/wave-mac-helper.h"
28 #include "ns3/wave-helper.h"
60 void NotifyCchStartNow (
Time duration);
65 void NotifySchStartNow (
Time duration);
71 void NotifyGuardStartNow (
Time duration,
bool inCchInterval);
79 void TestIntervalAfter (
bool cchi,
bool schi,
bool guardi);
80 virtual void DoRun (
void);
100 : m_coordinatorTest (coordinatorTest)
108 m_coordinatorTest->NotifyCchStartNow (duration);
112 m_coordinatorTest->NotifySchStartNow (duration);
116 m_coordinatorTest->NotifyGuardStartNow (duration, cchi);
134 "check whether is CCH interval");
136 "check whether is SCH interval");
138 "check whether is Guard interval");
150 bool test = (((now - guardi) % synci) == 0);
170 bool test = ((now - guardi - cchi) % synci == 0);
188 test = ((now % sync) == 0);
194 test = (((now - cchi) % sync) == 0);
246 Simulator::Stop (
Seconds (1.0));
248 Simulator::Destroy ();
254 Simulator::Stop (
Seconds (100.0));
256 Simulator::Destroy ();
276 #define PI 3.14159265
282 nodes.Create (nodesNumber);
285 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
290 for (uint32_t
n = 1;
n != nodesNumber; ++
n)
292 double angle = (
PI / 180) * (360 / (nodesNumber - 1) *
n);
293 double x = cos (angle) * 10;
294 double y = sin (angle) * 10;
303 WaveHelper waveHelper = WaveHelper::Default ();
324 void SendIp (
bool shouldSucceed,
bool ipv6);
339 virtual void DoRun (
void);
373 const Address dest = Mac48Address::GetBroadcast ();
374 uint16_t protocol = 0x80dd;
375 bool result =
m_sender->
SendX (packet, dest, protocol, txInfo);
382 const Address dest = Mac48Address::GetBroadcast ();
383 const static uint16_t IPv4_PROT_NUMBER = 0x0800;
384 const static uint16_t IPv6_PROT_NUMBER = 0x86DD;
385 uint16_t protocol = ipv6 ? IPv6_PROT_NUMBER : IPv4_PROT_NUMBER;
410 Simulator::Schedule (
Seconds (0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
439 Simulator::Stop (
Seconds (1.0));
441 Simulator::Destroy ();
449 bool ipv6 =
true, ipv4 =
false;
454 Simulator::Schedule (
Seconds (0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
460 Simulator::Schedule (
Seconds (0.4), &WaveNetDevice::RegisterTxProfile,
m_sender, txProfile);
478 Simulator::Stop (
Seconds (1.0));
480 Simulator::Destroy ();
489 const Mac48Address dest = Mac48Address::GetBroadcast ();
501 Simulator::Schedule (
Seconds (0.4), &WaveNetDevice::StartSch,
m_sender, schInfo);
520 Simulator::Stop (
Seconds (1.0));
522 Simulator::Destroy ();
593 virtual void DoRun (
void);
649 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
650 const Mac48Address dest = Mac48Address::GetBroadcast ();
653 uint8_t *
data =
new uint8_t [112];
654 data [0] = (receiverId >> 24) & 0xFF;
655 data [1] = (receiverId >> 16) & 0xFF;
656 data [2] = (receiverId >> 8) & 0xFF;
657 data [3] = (receiverId >> 0) & 0xFF;
660 data [4] = (ts >> 56) & 0xFF;
661 data [5] = (ts >> 48) & 0xFF;
662 data [6] = (ts >> 40) & 0xFF;
663 data [7] = (ts >> 32) & 0xFF;
664 data [8] = (ts >> 24) & 0xFF;
665 data [9] = (ts >> 16) & 0xFF;
666 data [10] = (ts >> 8) & 0xFF;
667 data [11] = (ts >> 0) & 0xFF;
682 uint32_t seq =
data [0];
690 uint64_t ts =
data [4];
705 Time sendTime = TimeStep (ts);
755 Simulator::Stop (
Seconds (7.0));
757 Simulator::Destroy ();
766 for (uint32_t i = 1; i != 8; ++i)
772 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
773 uint32_t
channel = WaveChannels[i - 1];
775 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
790 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
800 Simulator::Stop (
Seconds (10.0));
802 Simulator::Destroy ();
852 Simulator::Stop (
Seconds (6.0));
854 Simulator::Destroy ();
863 for (uint32_t i = 1; i != 8; ++i)
869 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
870 uint32_t
channel = WaveChannels[i - 1];
872 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
888 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
907 Simulator::Stop (
Seconds (10.0));
909 Simulator::Destroy ();
950 Simulator::Stop (
Seconds (6.0));
952 Simulator::Destroy ();
961 for (uint32_t i = 1; i != 8; ++i)
967 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
968 uint32_t
channel = WaveChannels[i - 1];
970 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
985 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
1007 Simulator::Stop (
Seconds (10.0));
1009 Simulator::Destroy ();
1028 virtual void DoRun (
void);
1064 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
1068 data [0] = (sequence >> 24) & 0xFF;
1069 data [1] = (sequence >> 16) & 0xFF;
1070 data [2] = (sequence >> 8) & 0xFF;
1071 data [3] = (sequence >> 0) & 0xFF;
1074 data [4] = (ts >> 56) & 0xFF;
1075 data [5] = (ts >> 48) & 0xFF;
1076 data [6] = (ts >> 40) & 0xFF;
1077 data [7] = (ts >> 32) & 0xFF;
1078 data [8] = (ts >> 24) & 0xFF;
1079 data [9] = (ts >> 16) & 0xFF;
1080 data [10] = (ts >> 8) & 0xFF;
1081 data [11] = (ts >> 0) & 0xFF;
1096 uint32_t seq =
data [0];
1104 uint64_t ts =
data [4];
1119 Time sendTime = TimeStep (ts);
1124 Time duration = curTime - sendTime;
1128 NS_TEST_EXPECT_MSG_GT (duration, ChannelCoordinator::GetDefaultSchInterval (),
"fail to test Annex C when packet sequence is " << seq);
1132 NS_TEST_EXPECT_MSG_LT (duration, ChannelCoordinator::GetDefaultSchInterval (),
"fail to test Annex C when packet sequence is " << seq);
1136 NS_TEST_EXPECT_MSG_GT (duration, ChannelCoordinator::GetDefaultCchInterval (),
"fail to test Annex C when packet sequence is " << seq);
1140 NS_TEST_EXPECT_MSG_LT (duration, ChannelCoordinator::GetDefaultCchInterval (),
"fail to test Annex C when packet sequence is " << seq);
1179 Simulator::Stop (
Seconds (1.0));
1181 Simulator::Destroy ();
1197 :
TestSuite (
"wave-mac-extension", UNIT)
holds a vector of ns3::NetDevice pointers
ChannelAccessTestCase(void)
void TestContinuous(SchInfo &info, bool shouldSucceed)
Test continuous function.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void TestExtendedAfter(uint32_t channelNumber, bool isAccessAssigned)
Test extended after function.
route packets or frames in different approaches see 1609.4-2010 chapter 5.3.4
NetDeviceContainer m_devices
devices
Ptr< WaveNetDevice > m_sender
sender
#define EXTENDED_ALTERNATING
Time GetCchInterval(void) const
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
This test case tests channel access assignments which is done by StartSch and StopSch method of WaveN...
void TestAlternating(SchInfo &info, bool shouldSucceed)
Test aternating function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void NotifyGuardSlotStart(Time duration, bool cchi)
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
virtual ~AnnexC_TestCase()
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
bool IsSchInterval(Time duration=Seconds(0.0)) const
void SetPosition(const Vector &position)
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void SendIp(bool shouldSucceed, bool ipv6)
Send IP-based packets.
static NetDeviceContainer CreatWaveDevice(uint32_t nodesNumber=2)
Create WAVE device function.
virtual void NotifyCchSlotStart(Time duration)
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t m_received
received
ChannelCoordinationTestCase(void)
void SetCchInterval(Time cchi)
helps to create WaveNetDevice objects
void SetChannel(Ptr< YansWifiChannel > channel)
Time GetSchInterval(void) const
Ptr< WaveNetDevice > m_sender
sender
NetDeviceContainer m_devices
the devices
#define EXTENDED_CONTINUOUS
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
ChannelCoordinationTestCase * m_coordinatorTest
coordinator test
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void TestExtended(SchInfo &info, bool shouldSucceed)
Test extended function.
Ptr< YansWifiChannel > Create(void) const
Qos Wave Mac Helper class.
represent a single transmission mode
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
void NotifySchStartNow(Time duration)
Notify SCH start now function.
CoordinationTestListener is used to test channel coordination events.
Ptr< ChannelCoordinator > m_coordinator
coordinator
a polymophic address class
receive notifications about channel coordination events.
void NotifyCchStartNow(Time duration)
Notify CCS start now function.
CoordinationTestListener(ChannelCoordinationTestCase *coordinatorTest)
Constructor.
Ptr< ChannelScheduler > GetChannelScheduler(void) const
virtual Ptr< Node > GetNode(void) const =0
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
Simulation virtual time values and global simulation resolution.
bool StartVsa(const VsaInfo &vsaInfo)
void SendPacket(uint32_t packetSize, const TxInfo &txInfo, uint32_t sequence)
Send packet function.
bool IsGuardInterval(Time duration=Seconds(0.0)) const
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
uint32_t channelNumber
channel number
virtual ~ChannelCoordinationTestCase(void)
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...
This test case tests the channel coordination.
bool IsValidConfig(void) const
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static const uint32_t packetSize
virtual ~CoordinationTestListener(void)
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
Time Seconds(double value)
Construct a Time in the indicated unit.
bool StartSch(const SchInfo &schInfo)
void SetSchInterval(Time schi)
The Annex C of IEEE 1609.4 : "Avoiding transmission at scheduled guard intervals" This feature is imp...
void TestIntervalAfter(bool cchi, bool schi, bool guardi)
Test interval after function.
void TestContinuousAfter(uint32_t channelNumber, bool isAccessAssigned)
Test continuous after function.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
Ptr< WaveNetDevice > m_receiver
receiver
Ptr< WaveNetDevice > m_sender
sender
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void SetGuardInterval(Time guardi)
void TestAlternatingAfter(uint32_t channelNumber, bool isAccessAssigned)
Test alternating after function.
void NotifyGuardStartNow(Time duration, bool inCchInterval)
Notify guard start now function.
void SendWsa(bool shouldSucceed, const VsaInfo &vsaInfo)
Send VSA management frames.
static WaveMacTestSuite waveMacTestSuite
the test suite
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
manage and create wifi channel objects for the YANS model.
bool ReceiveVsa(Ptr< const Packet > pkt, const Address &address, uint32_t, uint32_t)
Receive VSA function.
Time GetGuardInterval(void) const
virtual Address GetAddress(void) const
void SendWsmp(bool shouldSucceed, const TxInfo &txInfo)
Send WSMP or other packets.
void SendX(uint32_t channel, uint32_t receiverId)
Send X function.
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
ChannelRoutingTestCase(void)
Time GetSyncInterval(void) const
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void NotifySchSlotStart(Time duration)
virtual ~ChannelAccessTestCase(void)
virtual ~ChannelRoutingTestCase(void)
Helper class used to assign positions and mobility models to nodes.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
bool IsCchInterval(Time duration=Seconds(0.0)) const
the organization identifier is a public organizationally unique identifier assigned by the IEEE.