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/seq-ts-header.h"
27 #include "ns3/wave-net-device.h"
28 #include "ns3/wave-mac-helper.h"
29 #include "ns3/wave-helper.h"
46 void NotifyCchStartNow (
Time duration);
47 void NotifySchStartNow (
Time duration);
48 void NotifyGuardStartNow (
Time duration,
bool inCchInterval);
50 void TestIntervalAfter (
bool cchi,
bool schi,
bool guardi);
51 virtual void DoRun (
void);
61 : m_coordinatorTest (coordinatorTest)
69 m_coordinatorTest->NotifyCchStartNow (duration);
73 m_coordinatorTest->NotifySchStartNow (duration);
77 m_coordinatorTest->NotifyGuardStartNow (duration, cchi);
95 "check whether is CCH interval");
97 "check whether is SCH interval");
99 "check whether is Guard interval");
111 bool test = (((now - guardi) % synci) == 0);
131 bool test = ((now - guardi - cchi) % synci == 0);
149 test = ((now % sync) == 0);
155 test = (((now - cchi) % sync) == 0);
207 Simulator::Stop (
Seconds (1.0));
209 Simulator::Destroy ();
211 m_coordinator = CreateObject<ChannelCoordinator> ();
214 m_coordinator->RegisterListener (ptr);
215 Simulator::Stop (
Seconds (100.0));
217 Simulator::Destroy ();
226 #define PI 3.14159265
232 nodes.
Create (nodesNumber);
240 for (uint32_t n = 1; n != nodesNumber; ++n)
242 double angle = (
PI / 180) * (360 / (nodesNumber - 1) * n);
243 double x = cos (angle) * 10;
244 double y = sin (angle) * 10;
253 WaveHelper waveHelper = WaveHelper::Default ();
270 void SendIp (
bool shouldSucceed,
bool ipv6);
279 virtual void DoRun (
void);
299 const Address dest = Mac48Address::GetBroadcast ();
300 uint16_t protocol = 0x80dd;
301 bool result =
m_sender->
SendX (packet, dest, protocol, txInfo);
308 const Address dest = Mac48Address::GetBroadcast ();
309 const static uint16_t IPv4_PROT_NUMBER = 0x0800;
310 const static uint16_t IPv6_PROT_NUMBER = 0x86DD;
311 uint16_t protocol = ipv6 ? IPv6_PROT_NUMBER : IPv4_PROT_NUMBER;
329 m_sender = DynamicCast<WaveNetDevice> (devices.
Get (0));
336 Simulator::Schedule (
Seconds (0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
365 Simulator::Stop (
Seconds (1.0));
367 Simulator::Destroy ();
373 m_sender = DynamicCast<WaveNetDevice> (devices.
Get (0));
375 bool ipv6 =
true, ipv4 =
false;
380 Simulator::Schedule (
Seconds (0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
386 Simulator::Schedule (
Seconds (0.4), &WaveNetDevice::RegisterTxProfile,
m_sender, txProfile);
404 Simulator::Stop (
Seconds (1.0));
406 Simulator::Destroy ();
412 m_sender = DynamicCast<WaveNetDevice> (devices.
Get (0));
415 const Mac48Address dest = Mac48Address::GetBroadcast ();
427 Simulator::Schedule (
Seconds (0.4), &WaveNetDevice::StartSch,
m_sender, schInfo);
446 Simulator::Stop (
Seconds (1.0));
448 Simulator::Destroy ();
471 void SendX (uint32_t channel, uint32_t receiverId);
474 virtual void DoRun (
void);
530 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
531 const Mac48Address dest = Mac48Address::GetBroadcast ();
536 seqTs.
SetSeq (receiverId);
545 ConstCast<Packet> (pkt)->RemoveHeader (seqTs);
590 Simulator::Stop (
Seconds (7.0));
592 Simulator::Destroy ();
601 for (uint32_t i = 1; i != 8; ++i)
607 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
608 uint32_t channel = WaveChannels[i - 1];
610 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
625 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
635 Simulator::Stop (
Seconds (10.0));
637 Simulator::Destroy ();
687 Simulator::Stop (
Seconds (6.0));
689 Simulator::Destroy ();
698 for (uint32_t i = 1; i != 8; ++i)
704 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
705 uint32_t channel = WaveChannels[i - 1];
707 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
723 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
742 Simulator::Stop (
Seconds (10.0));
744 Simulator::Destroy ();
785 Simulator::Stop (
Seconds (6.0));
787 Simulator::Destroy ();
796 for (uint32_t i = 1; i != 8; ++i)
802 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels ();
803 uint32_t channel = WaveChannels[i - 1];
805 Simulator::Schedule (
Seconds (0), &WaveNetDevice::StartSch, device, info);
820 Simulator::Schedule (
Seconds (1), &WaveNetDevice::StartSch,
m_sender, info);
842 Simulator::Stop (
Seconds (10.0));
844 Simulator::Destroy ();
858 virtual void DoRun (
void);
880 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
885 Ptr<Packet> p = Create<Packet> (packetSize - (8 + 4));
889 p->AddHeader (seqTs);
897 ConstCast<Packet> (pkt)->RemoveHeader (seqTs);
898 uint32_t seq = seqTs.
GetSeq ();
901 Time duration = curTime - sendTime;
905 NS_TEST_EXPECT_MSG_GT (duration, ChannelCoordinator::GetDefaultSchInterval (),
"fail to test Annex C when packet sequence is " << seq);
909 NS_TEST_EXPECT_MSG_LT (duration, ChannelCoordinator::GetDefaultSchInterval (),
"fail to test Annex C when packet sequence is " << seq);
913 NS_TEST_EXPECT_MSG_GT (duration, ChannelCoordinator::GetDefaultCchInterval (),
"fail to test Annex C when packet sequence is " << seq);
917 NS_TEST_EXPECT_MSG_LT (duration, ChannelCoordinator::GetDefaultCchInterval (),
"fail to test Annex C when packet sequence is " << seq);
932 Simulator::Schedule (
MilliSeconds (0), &WaveNetDevice::StartSch, m_receiver, infoReceiver);
956 Simulator::Stop (
Seconds (1.0));
958 Simulator::Destroy ();
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< NetDevice > Get(uint32_t i) const
Get the Ptr 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.
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)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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
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.
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
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
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 AddHeader(const Header &header)
Add header to this packet.
void SetGuardInterval(Time guardi)
ChannelRoutingTestCase(void)