#include "ns3/core-module.h"
55
#include "ns3/network-module.h"
56
#include "ns3/mobility-module.h"
57
#include "ns3/config-store-module.h"
58
#include "ns3/wifi-module.h"
59
#include "ns3/internet-module.h"
76 uint32_t pktCount,
Time pktInterval )
80 socket->
Send (Create<Packet> (pktSize));
82 socket, pktSize,pktCount-1, pktInterval);
91
int
main (
int argc,
char *argv[])
93 std::string phyMode (
"DsssRate1Mbps");
95 uint32_t packetSize = 1000;
96 uint32_t numPackets = 1;
97
double interval = 1.0;
102 cmd.
AddValue (
"phyMode",
"Wifi Phy mode", phyMode);
103 cmd.
AddValue (
"rss",
"received signal strength", rss);
104 cmd.
AddValue (
"packetSize",
"size of application packet sent", packetSize);
105 cmd.
AddValue (
"numPackets",
"number of packets generated", numPackets);
106 cmd.
AddValue (
"interval",
"interval (seconds) between packets", interval);
107 cmd.
AddValue (
"verbose",
"turn on all WifiNetDevice log components", verbose);
109 cmd.
Parse (argc, argv);
111
Time interPacketInterval = Seconds (interval);
//配置wifiphy
// ConstantSpeedPropagationDelayModel默认的传播延迟模型
//配置wifichannel
152 wifiMac.
SetType (
"ns3::AdhocWifiMac");
// 移动模型配置
159 positionAlloc->
Add (
Vector (0.0, 0.0, 0.0));
160 positionAlloc->
Add (
Vector (5.0, 0.0, 0.0));
170 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
176 recvSink->
Bind (local);
185 wifiPhy.
EnablePcap (
"wifi-simple-adhoc", devices);
188
NS_LOG_UNCOND (
"Testing " << numPackets <<
" packets sent with receiver rss " << rss );
192 source, packetSize, numPackets, interPacketInterval);