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"
45 void NotifyCchStartNow (
Time duration);
46 void NotifySchStartNow (
Time duration);
47 void NotifyGuardStartNow (
Time duration,
bool inCchInterval);
49 void TestIntervalAfter (
bool cchi,
bool schi,
bool guardi);
50 virtual void DoRun (
void);
60 : m_coordinatorTest (coordinatorTest)
68 m_coordinatorTest->NotifyCchStartNow (duration);
72 m_coordinatorTest->NotifySchStartNow (duration);
76 m_coordinatorTest->NotifyGuardStartNow (duration, cchi);
94 "check whether is CCH interval");
96 "check whether is SCH interval");
98 "check whether is Guard interval");
110 bool test = (((now - guardi) % synci) == 0);
130 bool test = ((now - guardi - cchi) % synci == 0);
148 test = ((now % sync) == 0);
154 test = (((now - cchi) % sync) == 0);
206 Simulator::Stop (
Seconds (1.0));
208 Simulator::Destroy ();
210 m_coordinator = CreateObject<ChannelCoordinator> ();
213 m_coordinator->RegisterListener (ptr);
214 Simulator::Stop (
Seconds (100.0));
216 Simulator::Destroy ();
225 #define PI 3.14159265
231 nodes.
Create (nodesNumber);
239 for (uint32_t n = 1; n != nodesNumber; ++n)
241 double angle = (
PI / 180) * (360 / (nodesNumber - 1) * n);
242 double x = cos (angle) * 10;
243 double y = sin (angle) * 10;
252 WaveHelper waveHelper = WaveHelper::Default ();
269 void SendIp (
bool shouldSucceed,
bool ipv6);
278 virtual void DoRun (
void);
298 const Address dest = Mac48Address::GetBroadcast ();
299 uint16_t protocol = 0x80dd;
300 bool result =
m_sender->
SendX (packet, dest, protocol, txInfo);
307 const Address dest = Mac48Address::GetBroadcast ();
308 const static uint16_t IPv4_PROT_NUMBER = 0x0800;
309 const static uint16_t IPv6_PROT_NUMBER = 0x86DD;
310 uint16_t protocol = ipv6 ? IPv6_PROT_NUMBER : IPv4_PROT_NUMBER;
328 m_sender = DynamicCast<WaveNetDevice> (devices.
Get (0));
335 Simulator::Schedule (
Seconds (0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
364 Simulator::Stop (
Seconds (1.0));
366 Simulator::Destroy ();
372 m_sender = DynamicCast<WaveNetDevice> (devices.
Get (0));
374 bool ipv6 =
true, ipv4 =
false;
379 Simulator::Schedule (
Seconds (0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
385 Simulator::Schedule (
Seconds (0.4), &WaveNetDevice::RegisterTxProfile,
m_sender, txProfile);
403 Simulator::Stop (
Seconds (1.0));
405 Simulator::Destroy ();
411 m_sender = DynamicCast<WaveNetDevice> (devices.
Get (0));
414 const Mac48Address dest = Mac48Address::GetBroadcast ();
426 Simulator::Schedule (
Seconds (0.4), &WaveNetDevice::StartSch,
m_sender, schInfo);
445 Simulator::Stop (
Seconds (1.0));
447 Simulator::Destroy ();
473 virtual void DoRun (
void);
529 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
530 const Mac48Address dest = Mac48Address::GetBroadcast ();
533 uint8_t *
data =
new uint8_t [112];
534 data [0] = (receiverId >> 24) & 0xFF;
535 data [1] = (receiverId >> 16) & 0xFF;
536 data [2] = (receiverId >> 8) & 0xFF;
537 data [3] = (receiverId >> 0) & 0xFF;
540 data [4] = (ts >> 56) & 0xFF;
541 data [5] = (ts >> 48) & 0xFF;
542 data [6] = (ts >> 40) & 0xFF;
543 data [7] = (ts >> 32) & 0xFF;
544 data [8] = (ts >> 24) & 0xFF;
545 data [9] = (ts >> 16) & 0xFF;
546 data [10] = (ts >> 8) & 0xFF;
547 data [11] = (ts >> 0) & 0xFF;
562 uint32_t seq = data [0];
570 uint64_t ts = data [4];
635 Simulator::Stop (
Seconds (7.0));
637 Simulator::Destroy ();
646 for (uint32_t i = 1; i != 8; ++i)
652 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
653 uint32_t
channel = WaveChannels[i - 1];
655 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
670 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
680 Simulator::Stop (
Seconds (10.0));
682 Simulator::Destroy ();
732 Simulator::Stop (
Seconds (6.0));
734 Simulator::Destroy ();
743 for (uint32_t i = 1; i != 8; ++i)
749 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
750 uint32_t
channel = WaveChannels[i - 1];
752 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
768 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
787 Simulator::Stop (
Seconds (10.0));
789 Simulator::Destroy ();
830 Simulator::Stop (
Seconds (6.0));
832 Simulator::Destroy ();
841 for (uint32_t i = 1; i != 8; ++i)
847 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
848 uint32_t
channel = WaveChannels[i - 1];
850 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
865 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
887 Simulator::Stop (
Seconds (10.0));
889 Simulator::Destroy ();
903 virtual void DoRun (
void);
925 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
929 data [0] = (sequence >> 24) & 0xFF;
930 data [1] = (sequence >> 16) & 0xFF;
931 data [2] = (sequence >> 8) & 0xFF;
932 data [3] = (sequence >> 0) & 0xFF;
935 data [4] = (ts >> 56) & 0xFF;
936 data [5] = (ts >> 48) & 0xFF;
937 data [6] = (ts >> 40) & 0xFF;
938 data [7] = (ts >> 32) & 0xFF;
939 data [8] = (ts >> 24) & 0xFF;
940 data [9] = (ts >> 16) & 0xFF;
941 data [10] = (ts >> 8) & 0xFF;
942 data [11] = (ts >> 0) & 0xFF;
957 uint32_t seq = data [0];
965 uint64_t ts = data [4];
985 Time duration = curTime - sendTime;
989 NS_TEST_EXPECT_MSG_GT (duration, ChannelCoordinator::GetDefaultSchInterval (),
"fail to test Annex C when packet sequence is " << seq);
993 NS_TEST_EXPECT_MSG_LT (duration, ChannelCoordinator::GetDefaultSchInterval (),
"fail to test Annex C when packet sequence is " << seq);
997 NS_TEST_EXPECT_MSG_GT (duration, ChannelCoordinator::GetDefaultCchInterval (),
"fail to test Annex C when packet sequence is " << seq);
1001 NS_TEST_EXPECT_MSG_LT (duration, ChannelCoordinator::GetDefaultCchInterval (),
"fail to test Annex C when packet sequence is " << seq);
1016 Simulator::Schedule (
MilliSeconds (0), &WaveNetDevice::StartSch, m_receiver, infoReceiver);
1040 Simulator::Stop (
Seconds (1.0));
1042 Simulator::Destroy ();
1052 :
TestSuite (
"wave-mac-extension", UNIT)
virtual Address GetAddress(void) const
void SendX(uint32_t channel, uint32_t receiverId)
virtual ~ChannelRoutingTestCase(void)
bool IsGuardInterval(Time duration=Seconds(0.0)) const
Simulation virtual time values and global simulation resolution.
virtual void NotifyGuardSlotStart(Time duration, bool cchi)
bool StartSch(const SchInfo &schInfo)
void TestContinuousAfter(uint32_t channelNumber, bool isAccessAssigned)
Ptr< YansWifiChannel > Create(void) const
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void NotifySchStartNow(Time duration)
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
virtual Ptr< Node > GetNode(void) const =0
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
static NetDeviceContainer CreatWaveDevice(uint32_t nodesNumber=2)
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetCchInterval(Time cchi)
Ptr< ChannelCoordinator > m_coordinator
void SendWsmp(bool shouldSucceed, const TxInfo &txInfo)
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
virtual void DoRun(void)
Implementation to actually run this TestCase.
void TestContinuous(SchInfo &info, bool shouldSuccceed)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
bool IsSchInterval(Time duration=Seconds(0.0)) const
a polymophic address class
bool IsValidConfig(void) const
virtual ~ChannelCoordinationTestCase(void)
ChannelAccessTestCase(void)
Keep track of the current position and velocity of an object.
void SetChannel(Ptr< YansWifiChannel > channel)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Ptr< WaveNetDevice > m_sender
#define EXTENDED_ALTERNATING
the organization identifier is a public organizationally unique identifier assigned by the IEEE...
virtual ~CoordinationTestListener(void)
helps to create WaveNetDevice objects
Time GetGuardInterval(void) const
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
#define EXTENDED_CONTINUOUS
Ptr< WaveNetDevice > m_sender
void SendPacket(uint32_t packetSize, const TxInfo &txInfo, uint32_t sequence)
NetDeviceContainer m_devices
void SendIp(bool shouldSucceed, bool ipv6)
bool IsCchInterval(Time duration=Seconds(0.0)) const
CoordinationTestListener(ChannelCoordinationTestCase *coordinatorTest)
keep track of a set of node pointers.
void NotifyGuardStartNow(Time duration, bool inCchInterval)
Time GetCchInterval(void) const
void SendWsa(bool shouldSucceed, const VsaInfo &vsaInfo)
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
route packets or frames in different approaches see 1609.4-2010 chapter 5.3.4
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Time TimeStep(uint64_t ts)
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
void TestExtended(SchInfo &info, bool shouldSuccceed)
manage and create wifi channel objects for the yans model.
Time GetSchInterval(void) const
virtual ~ChannelAccessTestCase(void)
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
NetDeviceContainer m_devices
ChannelCoordinationTestCase * m_coordinatorTest
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
void SetPosition(const Vector &position)
virtual void NotifySchSlotStart(Time duration)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void TestAlternatingAfter(uint32_t channelNumber, bool isAccessAssigned)
void NotifyCchStartNow(Time duration)
Helper class used to assign positions and mobility models to nodes.
bool StartVsa(const VsaInfo &vsaInfo)
virtual ~AnnexC_TestCase()
Ptr< WaveNetDevice > m_sender
uint32_t GetId(void) const
void TestExtendedAfter(uint32_t channelNumber, bool isAccessAssigned)
receive notifications about channel coordination events.
bool ReceiveVsa(Ptr< const Packet >, const Address &, uint32_t, uint32_t)
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetSchInterval(Time schi)
void TestAlternating(SchInfo &info, bool shouldSuccceed)
Time GetSyncInterval(void) const
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
static const uint32_t packetSize
ChannelCoordinationTestCase(void)
static WaveMacTestSuite waveMacTestSuite
void TestIntervalAfter(bool cchi, bool schi, bool guardi)
Ptr< ChannelScheduler > GetChannelScheduler(void) const
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void test(void)
Example use of ns3::SystemThread.
virtual void NotifyCchSlotStart(Time duration)
Ptr< WaveNetDevice > m_receiver
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void SetGuardInterval(Time guardi)
ChannelRoutingTestCase(void)