add missing log call
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WiFiDistanceApps");
|
||||
NS_LOG_COMPONENT_DEFINE ("WiFiThroughputApps");
|
||||
|
||||
TypeId
|
||||
Sender::GetTypeId(void)
|
||||
@@ -47,26 +47,26 @@ Sender::GetTypeId(void)
|
||||
static TypeId tid = TypeId ("Sender")
|
||||
.SetParent<Application> ()
|
||||
.AddConstructor<Sender> ()
|
||||
.AddAttribute ("PacketSize", "The size of packets transmitted.",
|
||||
.AddAttribute ("PacketSize", "The size of packets transmitted [Bytes].",
|
||||
UintegerValue(64),
|
||||
MakeUintegerAccessor(&Sender::m_pktSize),
|
||||
MakeUintegerChecker<uint32_t>(1))
|
||||
.AddAttribute("Destination", "Target host address.",
|
||||
Ipv4AddressValue("255.255.255.255"),
|
||||
MakeIpv4AddressAccessor(&Sender::m_destAddr),
|
||||
MakeIpv4AddressChecker())
|
||||
.AddAttribute("Port", "Destination app port.",
|
||||
UintegerValue(1603),
|
||||
MakeUintegerAccessor(&Sender::m_destPort),
|
||||
MakeUintegerChecker<uint32_t>())
|
||||
.AddAttribute("NumPackets", "Total number of packets to send.",
|
||||
UintegerValue(30),
|
||||
MakeUintegerAccessor(&Sender::m_numPkts),
|
||||
MakeUintegerChecker<uint32_t>(1))
|
||||
.AddAttribute ("Interval", "Delay between transmissions.",
|
||||
RandomVariableValue(ConstantVariable(0.5)),
|
||||
MakeRandomVariableAccessor(&Sender::m_interval),
|
||||
MakeRandomVariableChecker())
|
||||
.AddAttribute ("DataRate", "The data rate in on state.",
|
||||
DataRateValue (DataRate ("500kb/s")),
|
||||
MakeDataRateAccessor (&Sender::m_cbrRate),
|
||||
MakeDataRateChecker ())
|
||||
.AddAttribute ("Destination", "Target host address.",
|
||||
Ipv4AddressValue("255.255.255.255"),
|
||||
MakeIpv4AddressAccessor(&Sender::m_destAddr),
|
||||
MakeIpv4AddressChecker())
|
||||
.AddAttribute ("Port", "Destination app port.",
|
||||
UintegerValue(1603),
|
||||
MakeUintegerAccessor(&Sender::m_destPort),
|
||||
MakeUintegerChecker<uint32_t>())
|
||||
.AddAttribute ("NumPackets", "Total number of packets to send.",
|
||||
UintegerValue(30),
|
||||
MakeUintegerAccessor(&Sender::m_numPkts),
|
||||
MakeUintegerChecker<uint32_t>(1))
|
||||
.AddTraceSource ("Tx", "A new packet is created and is sent",
|
||||
MakeTraceSourceAccessor (&Sender::m_txTrace))
|
||||
;
|
||||
@@ -105,7 +105,7 @@ void Sender::StartApplication()
|
||||
m_socket = socketFactory->CreateSocket ();
|
||||
m_socket->Bind ();
|
||||
}
|
||||
|
||||
|
||||
m_count = 0;
|
||||
|
||||
Simulator::Cancel(m_sendEvent);
|
||||
@@ -124,8 +124,13 @@ void Sender::StopApplication()
|
||||
void Sender::SendPacket()
|
||||
{
|
||||
// NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_INFO("Sending packet at " << Simulator::Now() << " to " <<
|
||||
m_destAddr);
|
||||
uint32_t bits = m_pktSize * 8;
|
||||
|
||||
NS_LOG_LOGIC ("bits = " << bits);
|
||||
nextTime = Time(Seconds (bits / static_cast<double>(m_cbrRate.GetBitRate()))); // Time till next packet
|
||||
|
||||
NS_LOG_UNCOND("Sending packet at " << Simulator::Now() << " to " <<
|
||||
m_destAddr << " -- Time Interval is: " << nextTime);
|
||||
|
||||
Ptr<Packet> packet = Create<Packet>(m_pktSize);
|
||||
|
||||
@@ -140,11 +145,11 @@ void Sender::SendPacket()
|
||||
// Report the event to the trace.
|
||||
m_txTrace(packet);
|
||||
|
||||
if (++m_count < m_numPkts) {
|
||||
m_sendEvent = Simulator::Schedule(Seconds(m_interval.GetValue()),
|
||||
if (++m_count < m_numPkts) {
|
||||
m_sendEvent = Simulator::Schedule(nextTime,
|
||||
&Sender::SendPacket, this);
|
||||
}
|
||||
|
||||
|
||||
// end Sender::SendPacket
|
||||
}
|
||||
|
||||
@@ -250,13 +255,17 @@ Receiver::Receive(Ptr<Socket> socket)
|
||||
}
|
||||
|
||||
TimestampTag timestamp;
|
||||
packet->FindFirstMatchingTag(timestamp);
|
||||
Time tx = timestamp.GetTimestamp();
|
||||
|
||||
if (m_delay != 0) {
|
||||
m_delay->Update(Simulator::Now() - tx);
|
||||
if( packet->FindFirstMatchingTag(timestamp) ) {
|
||||
Time tx = timestamp.GetTimestamp();
|
||||
|
||||
if (m_delay != 0) {
|
||||
m_delay->Update(Simulator::Now() - tx);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
NS_LOG_UNCOND ("** missing time tag **");
|
||||
}
|
||||
|
||||
if (m_calc != 0) {
|
||||
m_calc->Update();
|
||||
}
|
||||
|
||||
@@ -55,9 +55,10 @@ private:
|
||||
uint32_t m_pktSize;
|
||||
Ipv4Address m_destAddr;
|
||||
uint32_t m_destPort;
|
||||
RandomVariable m_interval;
|
||||
uint32_t m_numPkts;
|
||||
|
||||
DataRate m_cbrRate; // Rate that data is generated
|
||||
Time nextTime; // Time till next packet
|
||||
|
||||
Ptr<Socket> m_socket;
|
||||
EventId m_sendEvent;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
using namespace ns3;
|
||||
using namespace std;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WiFiDistanceExperiment");
|
||||
NS_LOG_COMPONENT_DEFINE ("WiFiThroughputExperiment");
|
||||
|
||||
|
||||
|
||||
@@ -73,11 +73,14 @@ int main(int argc, char *argv[]) {
|
||||
double distance = 50.0;
|
||||
string format("omnet");
|
||||
|
||||
string experiment("wifi-distance-test");
|
||||
string experiment("wifi-throughput-test");
|
||||
string strategy("wifi-default");
|
||||
string input;
|
||||
string runID;
|
||||
|
||||
int nStas = 2;
|
||||
|
||||
//LogComponentEnableAll(LOG_LEVEL_ALL);
|
||||
|
||||
{
|
||||
stringstream sstr;
|
||||
sstr << "run-" << time(NULL);
|
||||
@@ -123,25 +126,49 @@ int main(int argc, char *argv[]) {
|
||||
//-- Create nodes and network stacks
|
||||
//--------------------------------------------
|
||||
NS_LOG_INFO("Creating nodes.");
|
||||
NodeContainer nodes;
|
||||
nodes.Create(2);
|
||||
NodeContainer stas;
|
||||
NodeContainer ap;
|
||||
NetDeviceContainer apDev;
|
||||
NetDeviceContainer stasDev;
|
||||
Ipv4InterfaceContainer staInterface;
|
||||
Ipv4InterfaceContainer apInterface;
|
||||
|
||||
NS_LOG_INFO("Installing WiFi and Internet stack.");
|
||||
WifiHelper wifi = WifiHelper::Default ();
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
Ssid ssid = Ssid ( "wifi-default" );
|
||||
|
||||
ap.Create(1);
|
||||
stas.Create(nStas);
|
||||
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
NetDeviceContainer nodeDevices = wifi.Install(wifiPhy, wifiMac, nodes);
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
WifiHelper wifi = WifiHelper::Default ();
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install(nodes);
|
||||
internet.Install(NodeContainer(stas,ap));
|
||||
Ipv4AddressHelper ipAddrs;
|
||||
ipAddrs.SetBase("192.168.0.0", "255.255.255.0");
|
||||
ipAddrs.Assign(nodeDevices);
|
||||
|
||||
|
||||
|
||||
NS_LOG_INFO("Installing WiFi and Internet stack on AP.");
|
||||
// wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
wifiMac.SetType ("ns3::NqapWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true),
|
||||
"BeaconInterval", TimeValue (Seconds (2.5)));
|
||||
apDev = wifi.Install(wifiPhy, wifiMac, ap);
|
||||
apInterface = ipAddrs.Assign(apDev);
|
||||
|
||||
|
||||
NS_LOG_INFO("Installing WiFi and Internet stack on nodes.");
|
||||
WifiHelper wifiNodes = WifiHelper::Default ();
|
||||
NqosWifiMacHelper wifiMacNodes = NqosWifiMacHelper::Default ();
|
||||
//wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
wifiMac.SetType ("ns3::NqstaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
stasDev = wifi.Install(wifiPhy, wifiMac, stas);
|
||||
staInterface = ipAddrs.Assign(stasDev);
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
@@ -154,7 +181,7 @@ int main(int argc, char *argv[]) {
|
||||
positionAlloc->Add(Vector(0.0, 0.0, 0.0));
|
||||
positionAlloc->Add(Vector(0.0, distance, 0.0));
|
||||
mobility.SetPositionAllocator(positionAlloc);
|
||||
mobility.Install(nodes);
|
||||
mobility.Install(NodeContainer(stas,ap));
|
||||
|
||||
|
||||
|
||||
@@ -163,16 +190,22 @@ int main(int argc, char *argv[]) {
|
||||
//-- Create a custom traffic source and sink
|
||||
//--------------------------------------------
|
||||
NS_LOG_INFO ("Create traffic source & sink.");
|
||||
Ptr<Node> appSource = NodeList::GetNode(0);
|
||||
Ptr<Sender> sender = CreateObject<Sender>();
|
||||
appSource->AddApplication(sender);
|
||||
sender->Start(Seconds(1));
|
||||
|
||||
Ptr<Node> appSink = NodeList::GetNode(1);
|
||||
Ptr<Node> appSink = NodeList::GetNode(0);
|
||||
Ptr<Receiver> receiver = CreateObject<Receiver>();
|
||||
appSink->AddApplication(receiver);
|
||||
receiver->Start(Seconds(0));
|
||||
|
||||
|
||||
for( int i=0; i<nStas; i++ ) {
|
||||
Ptr<Node> appSource = NodeList::GetNode(i+1);
|
||||
Ptr<Sender> sender = CreateObject<Sender>();
|
||||
sender->SetAttribute ("Destination", Ipv4AddressValue(apInterface.GetAddress(0)));
|
||||
sender->SetAttribute ("DataRate", DataRateValue (DataRate ("1kbps")) );
|
||||
sender->SetAttribute ("PacketSize", UintegerValue(1000));
|
||||
sender->SetAttribute ("NumPackets", UintegerValue(1000));
|
||||
|
||||
appSource->AddApplication(sender);
|
||||
sender->Start(Seconds(1));
|
||||
}
|
||||
// Config::Set("/NodeList/*/ApplicationList/*/$Sender/Destination",
|
||||
// Ipv4AddressValue("192.168.0.2"));
|
||||
|
||||
@@ -198,26 +231,36 @@ int main(int argc, char *argv[]) {
|
||||
// are triggered by the trace signal generated by the WiFi MAC model
|
||||
// object. Here we connect the counter to the signal via the simple
|
||||
// TxCallback() glue function defined above.
|
||||
Ptr<CounterCalculator<uint32_t> > totalTx =
|
||||
CreateObject<CounterCalculator<uint32_t> >();
|
||||
totalTx->SetKey("wifi-tx-frames");
|
||||
Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Tx",
|
||||
MakeBoundCallback(&TxCallback, totalTx));
|
||||
Ptr<PacketCounterCalculator> totalTx = CreateObject<PacketCounterCalculator>();
|
||||
totalTx->SetKey("wifiMac-tx-packets");
|
||||
Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
|
||||
MakeCallback(&PacketCounterCalculator::PacketUpdate, totalTx));
|
||||
data.AddDataCalculator(totalTx);
|
||||
|
||||
Ptr<PacketCounterCalculator> totalTxDrop = CreateObject<PacketCounterCalculator>();
|
||||
totalTxDrop->SetKey("wifiMac-txDrop-packets");
|
||||
Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTxDrop",
|
||||
MakeCallback(&PacketCounterCalculator::PacketUpdate, totalTxDrop));
|
||||
data.AddDataCalculator(totalTxDrop);
|
||||
|
||||
|
||||
// This is similar, but creates a counter to track how many frames
|
||||
// are received. Instead of our own glue function, this uses a
|
||||
// method of an adapter class to connect a counter directly to the
|
||||
// trace signal generated by the WiFi MAC.
|
||||
Ptr<PacketCounterCalculator> totalRx =
|
||||
CreateObject<PacketCounterCalculator>();
|
||||
totalRx->SetKey("wifi-rx-frames");
|
||||
Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Rx",
|
||||
MakeCallback(&PacketCounterCalculator::FrameUpdate,
|
||||
totalRx));
|
||||
Ptr<PacketCounterCalculator> totalRx = CreateObject<PacketCounterCalculator>();
|
||||
totalRx->SetKey("wifiMac-rx-packets");
|
||||
Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
|
||||
MakeCallback(&PacketCounterCalculator::PacketUpdate, totalRx));
|
||||
data.AddDataCalculator(totalRx);
|
||||
|
||||
|
||||
|
||||
Ptr<PacketCounterCalculator> totalRxDrop = CreateObject<PacketCounterCalculator>();
|
||||
totalRxDrop->SetKey("wifiMac-rxDrop-packets");
|
||||
Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRxDrop",
|
||||
MakeCallback(&PacketCounterCalculator::PacketUpdate, totalRxDrop));
|
||||
data.AddDataCalculator(totalRxDrop);
|
||||
|
||||
|
||||
|
||||
|
||||
// This counter tracks how many packets---as opposed to frames---are
|
||||
@@ -226,7 +269,7 @@ int main(int argc, char *argv[]) {
|
||||
Ptr<PacketCounterCalculator> appTx =
|
||||
CreateObject<PacketCounterCalculator>();
|
||||
appTx->SetKey("sender-tx-packets");
|
||||
Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
|
||||
Config::Connect("/NodeList/*/ApplicationList/*/$Sender/Tx",
|
||||
MakeCallback(&PacketCounterCalculator::PacketUpdate,
|
||||
appTx));
|
||||
data.AddDataCalculator(appTx);
|
||||
@@ -264,7 +307,7 @@ int main(int argc, char *argv[]) {
|
||||
Ptr<PacketSizeMinMaxAvgTotalCalculator> appTxPkts =
|
||||
CreateObject<PacketSizeMinMaxAvgTotalCalculator>();
|
||||
appTxPkts->SetKey("tx-pkt-size");
|
||||
Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
|
||||
Config::Connect("/NodeList/*/ApplicationList/*/$Sender/Tx",
|
||||
MakeCallback
|
||||
(&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate,
|
||||
appTxPkts));
|
||||
@@ -283,11 +326,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
|
||||
YansWifiPhyHelper::EnablePcap ("wifi-throughput-experiment", stasDev);
|
||||
YansWifiPhyHelper::EnablePcap ("wifi-throughput-experiment", apDev);
|
||||
|
||||
//------------------------------------------------------------
|
||||
//-- Run the simulation
|
||||
//--------------------------------------------
|
||||
NS_LOG_INFO("Run Simulation.");
|
||||
Simulator::Stop (Seconds (50));
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
|
||||
|
||||
@@ -293,6 +293,7 @@ Packet::RemoveAllTags (void)
|
||||
uint8_t const *
|
||||
Packet::PeekData (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_buffer.PeekData ();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user