24 #include "ns3/callback.h"
25 #include "ns3/abort.h"
27 #include "ns3/pcap-file.h"
28 #include "ns3/config.h"
29 #include "ns3/string.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/double.h"
32 #include "ns3/data-rate.h"
33 #include "ns3/inet-socket-address.h"
34 #include "ns3/internet-stack-helper.h"
35 #include "ns3/ipv4-address-helper.h"
36 #include "ns3/tcp-socket-factory.h"
37 #include "ns3/yans-wifi-helper.h"
38 #include "ns3/propagation-loss-model.h"
39 #include "ns3/propagation-delay-model.h"
40 #include "ns3/yans-wifi-channel.h"
41 #include "ns3/yans-wifi-phy.h"
42 #include "ns3/wifi-net-device.h"
43 #include "ns3/mobility-helper.h"
44 #include "ns3/constant-position-mobility-model.h"
45 #include "ns3/nqos-wifi-mac-helper.h"
46 #include "ns3/simulator.h"
59 virtual void DoRun (
void);
62 void PrintEndSync (std::string context, uint32_t dataRate,
double snr,
double per);
63 double WifiSimpleInterference (std::string phyMode,
double Prss,
double Irss,
double delta, uint32_t PpacketSize,
72 :
TestCase (
"Test interference calculation when interfering frame exactly overlaps intended frame")
80 static inline std::string
87 std::ostringstream oss;
88 oss <<
"Received one packet! Socket: " << iaddr.
GetIpv4 () <<
" port: " << iaddr.
GetPort ();
104 socket->
Send (Create<Packet> (pktSize));
116 NS_LOG_UNCOND (
"EndSync: Received frame with dataRate=" << dataRate <<
", SNR=" << snr <<
", PER =" << per);
126 uint32_t numPackets = 1;
127 double interval = 1.0;
128 double startTime = 10.0;
129 double distanceToRx = 100.0;
176 wifiMac.
SetType (
"ns3::AdhocWifiMac");
190 positionAlloc->
Add (
Vector (0.0, 0.0, 0.0));
191 positionAlloc->
Add (
Vector (distanceToRx, 0.0, 0.0));
192 positionAlloc->
Add (
Vector (-1*distanceToRx, 0.0, 0.0));
202 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
205 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
208 recvSink->
Bind (local);
219 interferer->
Connect (interferingAddr);
225 Simulator::ScheduleWithContext (source->
GetNode ()->
GetId (),
227 source, PpacketSize, numPackets, interPacketInterval);
229 Simulator::ScheduleWithContext (interferer->
GetNode ()->
GetId (),
231 interferer, IpacketSize, numPackets, interPacketInterval);
234 Simulator::Destroy ();
243 std::string phyMode (
"DsssRate1Mbps");
247 uint32_t PpacketSize = 1000;
248 uint32_t IpacketSize = 1000;
250 double PER, PER1, PER2;
268 double PERDiff1 = PER - PER1;
270 double PERDiff2 = PER1 - PER2;
273 "The PER difference due to 1 microsecond difference in arrival shouldn't depend on absolute arrival");
283 :
TestSuite (
"ns3-wifi-interference", UNIT)