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;
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)
#define EXTENDED_ALTERNATING
#define EXTENDED_CONTINUOUS
The Annex C of IEEE 1609.4 : "Avoiding transmission at scheduled guard intervals" This feature is imp...
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
Ptr< WaveNetDevice > m_sender
sender
Ptr< WaveNetDevice > m_receiver
receiver
void SendPacket(uint32_t packetSize, const TxInfo &txInfo, uint32_t sequence)
Send packet function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~AnnexC_TestCase()
NetDeviceContainer m_devices
devices
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.
void TestAlternatingAfter(uint32_t channelNumber, bool isAccessAssigned)
Test alternating after function.
NetDeviceContainer m_devices
the devices
void SendX(uint32_t channel, uint32_t receiverId)
Send X function.
virtual ~ChannelAccessTestCase(void)
uint32_t m_received
received
void TestExtendedAfter(uint32_t channelNumber, bool isAccessAssigned)
Test extended after function.
void TestContinuousAfter(uint32_t channelNumber, bool isAccessAssigned)
Test continuous after function.
ChannelAccessTestCase(void)
virtual void DoRun(void)
Implementation to actually run this TestCase.
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
void TestContinuous(SchInfo &info, bool shouldSucceed)
Test continuous function.
void TestExtended(SchInfo &info, bool shouldSucceed)
Test extended function.
Ptr< WaveNetDevice > m_sender
sender
This test case tests the channel coordination.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void NotifySchStartNow(Time duration)
Notify SCH start now function.
void TestIntervalAfter(bool cchi, bool schi, bool guardi)
Test interval after function.
virtual ~ChannelCoordinationTestCase(void)
ChannelCoordinationTestCase(void)
void NotifyGuardStartNow(Time duration, bool inCchInterval)
Notify guard start now function.
void NotifyCchStartNow(Time duration)
Notify CCS start now function.
Ptr< ChannelCoordinator > m_coordinator
coordinator
route packets or frames in different approaches see 1609.4-2010 chapter 5.3.4
Ptr< WaveNetDevice > m_sender
sender
void SendWsa(bool shouldSucceed, const VsaInfo &vsaInfo)
Send VSA management frames.
void SendWsmp(bool shouldSucceed, const TxInfo &txInfo)
Send WSMP or other packets.
void SendIp(bool shouldSucceed, bool ipv6)
Send IP-based packets.
virtual ~ChannelRoutingTestCase(void)
bool ReceiveVsa(Ptr< const Packet > pkt, const Address &address, uint32_t, uint32_t)
Receive VSA function.
ChannelRoutingTestCase(void)
virtual void DoRun(void)
Implementation to actually run this TestCase.
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
CoordinationTestListener is used to test channel coordination events.
virtual ~CoordinationTestListener(void)
ChannelCoordinationTestCase * m_coordinatorTest
coordinator test
virtual void NotifyGuardSlotStart(Time duration, bool cchi)
virtual void NotifySchSlotStart(Time duration)
virtual void NotifyCchSlotStart(Time duration)
CoordinationTestListener(ChannelCoordinationTestCase *coordinatorTest)
Constructor.
static NetDeviceContainer CreatWaveDevice(uint32_t nodesNumber=2)
Create WAVE device function.
a polymophic address class
receive notifications about channel coordination events.
Time GetCchInterval(void) const
Time GetSchInterval(void) const
void SetSchInterval(Time schi)
bool IsValidConfig(void) const
bool IsSchInterval(Time duration=Seconds(0.0)) const
bool IsGuardInterval(Time duration=Seconds(0.0)) const
void SetGuardInterval(Time guardi)
Time GetSyncInterval(void) const
Time GetGuardInterval(void) const
void SetCchInterval(Time cchi)
bool IsCchInterval(Time duration=Seconds(0.0)) const
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
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.
virtual Ptr< Node > GetNode(void) const =0
keep track of a set of node pointers.
uint32_t GetId(void) const
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
the organization identifier is a public organizationally unique identifier assigned by the IEEE.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Qos Wave Mac Helper class.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
helps to create WaveNetDevice objects
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
virtual Address GetAddress(void) const
bool StartSch(const SchInfo &schInfo)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
Ptr< ChannelScheduler > GetChannelScheduler(void) const
bool StartVsa(const VsaInfo &vsaInfo)
represent a single transmission mode
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
manage and create wifi channel objects for the YANS model.
Ptr< YansWifiChannel > Create(void) const
void SetChannel(Ptr< YansWifiChannel > channel)
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
#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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
static WaveMacTestSuite waveMacTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
list x
Random number samples.
uint32_t channelNumber
channel number
static const uint32_t packetSize