29 #include "ns3/simple-net-device.h"
30 #include "ns3/simple-channel.h"
31 #include "ns3/address.h"
32 #include "ns3/mac48-address.h"
33 #include "ns3/packet.h"
34 #include "ns3/callback.h"
36 #include "ns3/simulator.h"
37 #include "ns3/error-model.h"
38 #include "ns3/pointer.h"
39 #include "ns3/double.h"
40 #include "ns3/string.h"
41 #include "ns3/rng-seed-manager.h"
47 for (
int i = 0; i < num; i++)
50 device->
Send (pkt, addr, 0);
60 input->SetChannel (channel);
62 output->SetChannel (channel);
74 virtual void DoRun (
void);
82 ErrorModelSimple::ErrorModelSimple ()
83 :
TestCase (
"ErrorModel and PhyRxDrop trace for SimpleNetDevice"), m_count (0), m_drops (0)
87 ErrorModelSimple::~ErrorModelSimple ()
108 RngSeedManager::SetSeed (7);
109 RngSeedManager::SetRun (2);
117 BuildSimpleTopology (a, b, input, output, channel);
119 output->SetReceiveCallback (
MakeCallback (&ErrorModelSimple::Receive,
this));
130 output->SetAttribute (
"ReceiveErrorModel",
PointerValue (em));
131 output->TraceConnectWithoutContext (
"PhyRxDrop",
MakeCallback (&ErrorModelSimple::DropEvent,
this));
134 Simulator::Schedule (
Seconds (0), &SendPacket, 10000, input, output->GetAddress ());
137 Simulator::Destroy ();
141 NS_TEST_ASSERT_MSG_EQ (m_count, 9991,
"Wrong number of receptions.");
142 NS_TEST_ASSERT_MSG_EQ (m_drops, 9,
"Wrong number of drops.");
152 virtual void DoRun (
void);
160 BurstErrorModelSimple::BurstErrorModelSimple ()
161 :
TestCase (
"ErrorModel and PhyRxDrop trace for SimpleNetDevice"), m_count (0), m_drops (0)
165 BurstErrorModelSimple::~BurstErrorModelSimple ()
186 RngSeedManager::SetSeed (5);
187 RngSeedManager::SetRun (8);
195 BuildSimpleTopology (a, b, input, output, channel);
197 output->SetReceiveCallback (
MakeCallback (&BurstErrorModelSimple::Receive,
this));
210 output->SetAttribute (
"ReceiveErrorModel",
PointerValue (em));
211 output->TraceConnectWithoutContext (
"PhyRxDrop",
MakeCallback (&BurstErrorModelSimple::DropEvent,
this));
214 Simulator::Schedule (
Seconds (0), &SendPacket, 10000, input, output->GetAddress ());
217 Simulator::Destroy ();
223 NS_TEST_ASSERT_MSG_EQ (m_count, 9740,
"Wrong number of receptions.");
224 NS_TEST_ASSERT_MSG_EQ (m_drops, 260 ,
"Wrong number of drops.");
236 ErrorModelTestSuite::ErrorModelTestSuite ()
smart pointer class similar to boost::intrusive_ptr
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
hold variables of type string
virtual void DoRun(void)
Implementation to actually run this test case.
void SetRandomVariable(Ptr< RandomVariableStream >)
a polymophic address class
virtual void SetNode(Ptr< Node > node)
static Mac48Address Allocate(void)
int64_t AssignStreams(int64_t stream)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
hold objects of type Ptr<T>
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
uint32_t AddDevice(Ptr< NetDevice > device)
virtual void SetAddress(Address address)
void SetRandomVariable(Ptr< RandomVariableStream >)
Hold an floating point type.
void SetAttribute(std::string name, const AttributeValue &value)
virtual void DoRun(void)
Implementation to actually run this test case.