summaryrefslogtreecommitdiff
path: root/ns-3_wifi_tests
diff options
context:
space:
mode:
authorLoic Guegan <manzerberdes@gmx.com>2019-05-22 10:15:45 +0200
committerLoic Guegan <manzerberdes@gmx.com>2019-05-22 10:15:45 +0200
commit5a77b67d6baae0414310d29cab6f240963866062 (patch)
tree4121e3e4065872ee697fdf79033e11e9236d2cb6 /ns-3_wifi_tests
parent4045a41e029ed11dde5763455095bd33c7746a72 (diff)
Clean repo, update paper
Diffstat (limited to 'ns-3_wifi_tests')
-rw-r--r--ns-3_wifi_tests/Makefile17
-rw-r--r--ns-3_wifi_tests/wifi-nodes-energy-consumption.cc334
-rw-r--r--ns-3_wifi_tests/wifi-nodes-energy-consumption2.cc377
-rwxr-xr-xns-3_wifi_tests/wifi-testbin264072 -> 0 bytes
-rw-r--r--ns-3_wifi_tests/wifi-test.cc262
5 files changed, 0 insertions, 990 deletions
diff --git a/ns-3_wifi_tests/Makefile b/ns-3_wifi_tests/Makefile
deleted file mode 100644
index 03f9ab6..0000000
--- a/ns-3_wifi_tests/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-
-NS3_ARGS= -D NS3_LOG_ENABLE -L ${NS3_PATH}/build/lib -I ${NS3_PATH}/build/
-NS3_ARGS+=$(addprefix -l, $(subst lib,,$(subst .so,,$(notdir $(wildcard ${NS3_PATH}/build/lib/*.so)))))
-
-all: wifi-test
-
-wifi-test: wifi-test.cc
- g++ $(NS3_ARGS) $^ -o $@
-
-run:
- @LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${NS3_PATH}/build/lib ./wifi-test
-
-export:
- @echo export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
-
-clean:
- - rm wifi-test
diff --git a/ns-3_wifi_tests/wifi-nodes-energy-consumption.cc b/ns-3_wifi_tests/wifi-nodes-energy-consumption.cc
deleted file mode 100644
index fe89256..0000000
--- a/ns-3_wifi_tests/wifi-nodes-energy-consumption.cc
+++ /dev/null
@@ -1,334 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <fstream>
-#include <iostream>
-#include <string>
-#include "ns3/core-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/network-module.h"
-#include "ns3/config-store-module.h"
-#include "ns3/energy-module.h"
-#include "ns3/applications-module.h"
-#include "ns3/wifi-module.h"
-#include "ns3/mobility-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/ipv4-global-routing-helper.h"
-#include "ns3/flow-monitor-module.h"
-
-// Default Network Topology
-//
-// Number of wifi Sta or Edge nodes can be increased up to 250
-// |
-// Rank 0 | Rank 1
-// -------------------------|----------------------------
-// Wifi Sta 10.1.3.0
-// AP
-// * * * *
-// | | | | 10.1.1.0
-// n3 n4 n5 n0 -------------- n1 n2
-// point-to-point | |
-// * *
-// Ap
-// WiFi Edge 10.1.2.0
-
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("WifiEnergyExample");
-
-uint32_t PhyTxDropCount =0;
-uint32_t PhyRxDropCount =0;
-double offeredLoad = 0.0;
-double throughput = 0.0;
-double lastPacketTime = 0.0;
-
-//FlowMonitorHelper flowmon;
-
-/// Trace function for remaining energy at node.
-void
-RemainingEnergy (double oldValue, double remainingEnergy)
-{
- NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
- << "s Current remaining energy = " << remainingEnergy << "J");
-}
-
-/// Trace function for total energy consumption at node.
-void
-TotalEnergy (double oldValue, double newValue)
-{
- NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
- << "AIE\t"<< newValue-oldValue<<"\t"<<newValue);
-}
-
-void
-PhyTxDrop(Ptr<const Packet> p)
-{
- NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Tx Packet Drop "<<++PhyTxDropCount);
-}
-
-void
-PhyRxDrop(Ptr<const Packet> p)
-{
- NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Rx Packet Drop "<<++PhyRxDropCount);
-}
-void ThroughputMonitor (FlowMonitorHelper *fmhelper, Ptr<FlowMonitor> flowMon)
- {
- std::map<FlowId, FlowMonitor::FlowStats> flowStats = flowMon->GetFlowStats();
- Ptr<Ipv4FlowClassifier> classing = DynamicCast<Ipv4FlowClassifier> (fmhelper->GetClassifier());
- for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator stats = flowStats.begin (); stats != flowStats.end (); ++stats)
- {
- Ipv4FlowClassifier::FiveTuple fiveTuple = classing->FindFlow (stats->first);
- std::cout<<"---------------------------------------------------------------------------"<<std::endl;
- std::cout<<"Flow ID : " << stats->first <<" ; "<< fiveTuple.sourceAddress <<" -----> "<<fiveTuple.destinationAddress<<std::endl;
- std::cout<<"Tx Packets = " << stats->second.txPackets<<std::endl;
- std::cout<<"Rx Packets = " << stats->second.rxPackets<<std::endl;
- std::cout<<"Duration : "<<stats->second.timeLastRxPacket.GetSeconds()-stats->second.timeFirstTxPacket.GetSeconds()<<std::endl;
- std::cout<<"Last Received Packet : "<< stats->second.timeLastRxPacket.GetSeconds()<<" Seconds"<<std::endl;
- std::cout<<"Throughput: " << stats->second.rxBytes * 8.0 / (stats->second.timeLastRxPacket.GetSeconds()-stats->second.timeFirstTxPacket.GetSeconds())/1024/1024 << " Mbps"<<std::endl;
- std::cout<<"---------------------------------------------------------------------------"<<std::endl;
- }
- Simulator::Schedule(Seconds(0.1),&ThroughputMonitor, fmhelper, flowMon);
-
- }
-
-int
-main (int argc, char *argv[])
-{
- bool verbose = true;
- uint32_t nWifiEdge = 1;
- bool tracing = false;
- double interval = 0.01; // ms
- uint32_t maxPackets = 100000;
- double simulationTime = 2.1;
-
- CommandLine cmd;
- cmd.AddValue ("nWifiEdge", "Number of wifi edge nodes/devices", nWifiEdge);
- cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
- cmd.AddValue ("tracing", "Enable pcap tracing", tracing);
- cmd.AddValue ("interval", "Interval between packets", interval);
- cmd.AddValue ("maxPackets", "Maximum number of packets", maxPackets);
-
-
- cmd.Parse (argc,argv);
-
- // turn off RTS/CTS for frames below 2200 bytes
- //Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
-
- NodeContainer edgeApNode;
- edgeApNode.Create (1);
- NodeContainer wifiEdgeNodes;
- wifiEdgeNodes.Create (nWifiEdge);
-
- YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
- YansWifiPhyHelper phyEdge = YansWifiPhyHelper::Default ();
- phyEdge.SetChannel (channel.Create ());
- phyEdge.Set ("TxAntennas", UintegerValue (4));
- phyEdge.Set ("RxAntennas", UintegerValue (4));
-
-
- WifiHelper wifi;
- wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
- wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue("HtMcs31"),"ControlMode",StringValue("HtMcs31"));
-
-
-
- WifiMacHelper macEdge;
- Ssid ssid = Ssid ("ns-3-ssid-edge");
- macEdge.SetType ("ns3::StaWifiMac",
- "Ssid", SsidValue (ssid),
- "ActiveProbing", BooleanValue (false));
-
- NetDeviceContainer edgeDevices;
- edgeDevices = wifi.Install (phyEdge, macEdge, wifiEdgeNodes);
-
- macEdge.SetType ("ns3::ApWifiMac",
- "Ssid", SsidValue (ssid));
-
- NetDeviceContainer edgeApDevices;
- edgeApDevices = wifi.Install (phyEdge, macEdge, edgeApNode);
-
- MobilityHelper mobility;
-
- mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
- "MinX", DoubleValue (0.0),
- "MinY", DoubleValue (0.0),
- "DeltaX", DoubleValue (0.5),
- "DeltaY", DoubleValue (0.5),
- "GridWidth", UintegerValue (3),
- "LayoutType", StringValue ("RowFirst"));
-
- mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
- "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
-
- mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
- mobility.Install (edgeApNode);
- mobility.Install (wifiEdgeNodes);
-
- InternetStackHelper stack;
- stack.Install (edgeApNode);
- stack.Install (wifiEdgeNodes);
-
- Ipv4AddressHelper address;
-
- address.SetBase ("10.1.2.0", "255.255.255.0");
- Ipv4InterfaceContainer edgeInterfaces;
- Ipv4InterfaceContainer edgeApInterfaces;
- edgeInterfaces = address.Assign (edgeDevices);
- edgeApInterfaces = address.Assign(edgeApDevices);
-
-
- /** Energy Model **/
- /***************************************************************************/
- /* energy source */
- BasicEnergySourceHelper edgeBasicSourceHelper;
- // configure energy source
-
- edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (2.9009));
- edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (3.3));
- // install source
- EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (wifiEdgeNodes);
- EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (edgeApNode);
-
- /* device energy model */
- WifiRadioEnergyModelHelper radioEnergyHelper;
- // configure radio energy model
- radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.38));
- radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.313));
- radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.273));
- // install device model
- DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (edgeDevices, wifiEdgeNodesSources);
- DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (edgeApDevices, apEdgeNodesSources);
-
- /***************************************************************************/
- //Setting applications
- UdpServerHelper myServer (9);
-
- ApplicationContainer serverApps = myServer.Install (edgeApNode.Get (0));
- serverApps.Start (Seconds (0));
- serverApps.Stop (Seconds (simulationTime));
-
- //UdpEchoClientHelper client (serverAddress, port);
- UdpClientHelper myClient (edgeApInterfaces.GetAddress (0), 9);
- myClient.SetAttribute ("MaxPackets", UintegerValue (maxPackets));
- myClient.SetAttribute ("Interval", TimeValue (Seconds ((interval/1000.0))));
- myClient.SetAttribute ("PacketSize", UintegerValue (1472)); // in Bytes
-
- ApplicationContainer clientApps = myClient.Install (wifiEdgeNodes.Get (0));
- clientApps.Start (Seconds (1.0));
- clientApps.Stop (Seconds (simulationTime));
-
- Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
-
- /** connect trace sources **/
- /***************************************************************************/
- // all sources are connected to node 1
- // energy source
-
- Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
-
- basicSourcePtr0->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
- //device energy model
-
- Ptr<DeviceEnergyModel> basicRadioModelPtr0 =
- basicSourcePtr0->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
-
- NS_ASSERT (basicRadioModelPtr0 != NULL);
- basicRadioModelPtr0->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
-
-
- if (tracing == true)
- {
- //AsciiTraceHelper ascii;
- //pointToPoint.EnableAsciiAll(ascii.CreateFileStream ("energy-wifi.tr"));
- //pointToPoint.EnablePcapAll ("wifiEnergy");
- // phySta.EnablePcapAll ("wifiEnergy");
- phyEdge.EnablePcapAll ("wifiEnergy");
-
- }
-
- //Set simulation time and launch simulation
- Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback(&PhyRxDrop));
- Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback(&PhyTxDrop));
-
-
-// edgeDevices.Get(0)->TraceConnectWithoutContext("PhyTxDrop",MakeCallback(&PhyTxDrop));
-
-
-///
-// FlowMonitor
-///
- FlowMonitorHelper fmHelper;
- Ptr<FlowMonitor> allMon = fmHelper.InstallAll();
- Simulator::Schedule(Seconds(1),&ThroughputMonitor,&fmHelper, allMon);
-
-
- FlowMonitorHelper flowmon;
- Ptr<FlowMonitor> monitor = flowmon.InstallAll();
- Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
-
- Simulator::Stop (Seconds (simulationTime));
- Simulator::Run ();
-
- std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();
-
- double totalThroughput = 0.0;
- double totalLostPackets = 0.0;
- for (std::map< FlowId, FlowMonitor::FlowStats>::iterator flow=stats.begin(); flow!=stats.end(); flow++)
- {
- Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(flow->first);
- NS_LOG_UNCOND( "\nFlowID: " << flow->first << " ("
- << t.sourceAddress << " / " << t.sourcePort << " --> "
- << t.destinationAddress << " / " << t.destinationPort << ")" );
- NS_LOG_UNCOND( " Tx Packets: " << flow->second.txPackets );
- NS_LOG_UNCOND( " Tx Bytes: " << flow->second.txBytes );
-
- offeredLoad = flow->second.txBytes * 8.0 / (flow->second.timeLastTxPacket.GetSeconds () - flow->second.timeFirstTxPacket.GetSeconds ()) / 1000000 ;
- NS_LOG_UNCOND( " Offered Load: " << offeredLoad << " Mbps");
-
- NS_LOG_UNCOND( " Rx Packets: " << flow->second.rxPackets );
- NS_LOG_UNCOND( " Rx Bytes: " << flow->second.rxBytes );
-
- throughput = flow->second.rxBytes * 8.0 / (flow->second.timeLastRxPacket.GetSeconds () - flow->second.timeFirstRxPacket.GetSeconds ()) / 1000000;
- NS_LOG_UNCOND( " Throughput: " << throughput << " Mbps");
-
- NS_LOG_UNCOND( " Lost Packets: " << flow->second.lostPackets );
- NS_LOG_UNCOND( " Time last packet Transmited: " << flow->second.timeLastTxPacket.GetSeconds() );
- NS_LOG_UNCOND( " Time last packet Received: " << flow->second.timeLastRxPacket.GetSeconds() );
-
- if(t.destinationPort == 9){
-
- totalThroughput = totalThroughput + throughput;
- totalLostPackets = totalLostPackets + flow->second.lostPackets;
-
- }
- if(t.destinationPort == 9 && (lastPacketTime < flow->second.timeLastRxPacket.GetSeconds ())){
-
- lastPacketTime = flow->second.timeLastRxPacket.GetSeconds ();
- }
-
-}
- double averageThroughput = totalThroughput/nWifiEdge;
- double averageLostPackets = totalLostPackets/nWifiEdge;
-
- NS_LOG_UNCOND( "\nLast Packet Time: " << lastPacketTime);
- NS_LOG_UNCOND( "Average Throughput: " << averageThroughput << " Mbps");
- NS_LOG_UNCOND( "Average Lost Packet : " << averageLostPackets);
-
-
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/ns-3_wifi_tests/wifi-nodes-energy-consumption2.cc b/ns-3_wifi_tests/wifi-nodes-energy-consumption2.cc
deleted file mode 100644
index e778e11..0000000
--- a/ns-3_wifi_tests/wifi-nodes-energy-consumption2.cc
+++ /dev/null
@@ -1,377 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <fstream>
-#include <iostream>
-#include <string>
-#include "ns3/core-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/network-module.h"
-#include "ns3/config-store-module.h"
-#include "ns3/energy-module.h"
-#include "ns3/applications-module.h"
-#include "ns3/wifi-module.h"
-#include "ns3/mobility-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/ipv4-global-routing-helper.h"
-#include "ns3/flow-monitor-module.h"
-
-// Default Network Topology
-//
-// Number of wifi Sta or Edge nodes can be increased up to 250
-// |
-// Rank 0 | Rank 1
-// -------------------------|----------------------------
-// Wifi Sta 10.1.3.0
-// AP
-// * * * *
-// | | | | 10.1.1.0
-// n3 n4 n5 n0 -------------- n1 n2
-// point-to-point | |
-// * *
-// Ap
-// WiFi Edge 10.1.2.0
-
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("WifiEnergyExample");
-
-uint32_t PhyTxDropCount =0;
-uint32_t PhyRxDropCount =0;
-double offeredLoad = 0.0;
-double throughput = 0.0;
-double lastPacketTime = 0.0;
-
-//FlowMonitorHelper flowmon;
-
-/// Trace function for remaining energy at node.
-void
-RemainingEnergy (double oldValue, double remainingEnergy)
-{
- NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
- << "s Current remaining energy = " << remainingEnergy << "J");
-}
-
-/// Trace function for total energy consumption at node.
-void
-TotalEnergy (double oldValue, double newValue)
-{
- NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
- << "\t"<< newValue-oldValue<<"\t"<<newValue);
-}
-
-void
-PhyTxDrop(Ptr<const Packet> p)
-{
- NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Tx Packet Drop "<<++PhyTxDropCount);
-}
-
-void
-PhyRxDrop(Ptr<const Packet> p)
-{
- NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Rx Packet Drop "<<++PhyRxDropCount);
-}
-int
-main (int argc, char *argv[])
-{
- bool verbose = false;
- uint32_t nWifiSta = 1;
- uint32_t nWifiEdge = 1;
- bool tracing = false;
- double interval = 1.0;
- uint32_t maxPackets = 10;
- double simulationTime = 20.0;
-
- CommandLine cmd;
- cmd.AddValue ("nWifiEdge", "Number of wifi edge nodes/devices", nWifiEdge);
- cmd.AddValue ("nWifiSta", "Number of wifi STA devices", nWifiSta);
- cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
- cmd.AddValue ("tracing", "Enable pcap tracing", tracing);
- cmd.AddValue ("interval", "Interval between packets", interval);
- cmd.AddValue ("maxPackets", "Maximum number of packets", maxPackets);
-
-
- cmd.Parse (argc,argv);
-
- // Check for valid number of csma or wifi nodes
- // 250 should be enough, otherwise IP addresses
- // soon become an issue
- if (nWifiEdge > 250 || nWifiSta > 250)
- {
- std::cout << "Too many wifi station/edge nodes, no more than 250 each." << std::endl;
- return 1;
- }
-
- if (verbose)
- {
- LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
- LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
- //LogComponentEnable("YansWifiPhy",LOG_LEVEL_INFO);
- }
-
- NodeContainer p2pNodes;
- p2pNodes.Create (2);
-
- PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("250Mbps"));
- pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ns"));
-
- NetDeviceContainer p2pDevices;
- p2pDevices = pointToPoint.Install (p2pNodes);
-
- NodeContainer wifiStaNodes;
- wifiStaNodes.Create (nWifiSta);
- NodeContainer staApNode = p2pNodes.Get (0);
-
- NodeContainer wifiEdgeNodes;
- wifiEdgeNodes.Create (nWifiEdge);
- NodeContainer edgeApNode = p2pNodes.Get (1);
-
- YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
- YansWifiPhyHelper phySta = YansWifiPhyHelper::Default ();
- phySta.SetChannel (channel.Create ());
- phySta.Set ("TxAntennas", UintegerValue (4));
- phySta.Set ("RxAntennas", UintegerValue (4));
-
- YansWifiPhyHelper phyEdge = YansWifiPhyHelper::Default ();
- phyEdge.SetChannel (channel.Create ());
- phyEdge.Set ("TxAntennas", UintegerValue (4));
- phyEdge.Set ("RxAntennas", UintegerValue (4));
-
-
- WifiHelper wifi;
- wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
- wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue("HtMcs31"),"ControlMode",StringValue("HtMcs31"));
-
- WifiMacHelper macSta;
- Ssid ssid = Ssid ("ns-3-ssid-sta");
- macSta.SetType ("ns3::StaWifiMac",
- "Ssid", SsidValue (ssid),
- "ActiveProbing", BooleanValue (false));
-
- NetDeviceContainer staDevices;
- staDevices = wifi.Install (phySta, macSta, wifiStaNodes);
-
- macSta.SetType ("ns3::ApWifiMac",
- "Ssid", SsidValue (ssid));
-
- NetDeviceContainer staApDevices;
- staApDevices = wifi.Install (phySta, macSta, staApNode);
-
- WifiMacHelper macEdge;
- ssid = Ssid ("ns-3-ssid-edge");
- macEdge.SetType ("ns3::StaWifiMac",
- "Ssid", SsidValue (ssid),
- "ActiveProbing", BooleanValue (false));
-
- NetDeviceContainer edgeDevices;
- edgeDevices = wifi.Install (phyEdge, macEdge, wifiEdgeNodes);
-
- macEdge.SetType ("ns3::ApWifiMac",
- "Ssid", SsidValue (ssid));
-
- NetDeviceContainer edgeApDevices;
- edgeApDevices = wifi.Install (phyEdge, macEdge, edgeApNode);
-
- MobilityHelper mobility;
-
- mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
- "MinX", DoubleValue (0.0),
- "MinY", DoubleValue (0.0),
- "DeltaX", DoubleValue (0.5),
- "DeltaY", DoubleValue (0.5),
- "GridWidth", UintegerValue (3),
- "LayoutType", StringValue ("RowFirst"));
-
- mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
- "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
- mobility.Install (wifiStaNodes);
-
- mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
- mobility.Install (staApNode);
- mobility.Install (edgeApNode);
- mobility.Install (wifiEdgeNodes);
-
- InternetStackHelper stack;
- stack.Install (staApNode);
- stack.Install (edgeApNode);
- stack.Install (wifiStaNodes);
- stack.Install (wifiEdgeNodes);
-
- Ipv4AddressHelper address;
-
- address.SetBase ("10.1.1.0", "255.255.255.0");
- Ipv4InterfaceContainer p2pInterfaces;
- p2pInterfaces = address.Assign (p2pDevices);
-
- address.SetBase ("10.1.2.0", "255.255.255.0");
- Ipv4InterfaceContainer edgeInterfaces;
- edgeInterfaces = address.Assign (edgeDevices);
- address.Assign(edgeApDevices);
-
- address.SetBase ("10.1.3.0", "255.255.255.0");
- address.Assign (staDevices);
- address.Assign (staApDevices);
-
- /** Energy Model **/
- /***************************************************************************/
- /* energy source */
- BasicEnergySourceHelper staBasicSourceHelper;
- BasicEnergySourceHelper edgeBasicSourceHelper;
- // configure energy source
-
- staBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (100));
- edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (100));
-// edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (220));
- // install source
- EnergySourceContainer wifiStaNodesSources = staBasicSourceHelper.Install (wifiStaNodes);
- EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (wifiEdgeNodes);
-
- /* device energy model */
- WifiRadioEnergyModelHelper radioEnergyHelper;
- // configure radio energy model
-/*
- radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.0857));
- radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.0528));
- radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.0188));
-*/
- // install device model
- DeviceEnergyModelContainer staDeviceModels = radioEnergyHelper.Install (staDevices, wifiStaNodesSources);
- DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (edgeDevices, wifiEdgeNodesSources);
-
- /***************************************************************************/
- UdpEchoServerHelper echoServer (9);
-
- ApplicationContainer serverApps = echoServer.Install (wifiEdgeNodes.Get (0));
- serverApps.Start (Seconds (0));
- serverApps.Stop (Seconds (simulationTime));
-
- UdpEchoClientHelper echoClient (edgeInterfaces.GetAddress (0), 9);
- echoClient.SetAttribute ("MaxPackets", UintegerValue (maxPackets));
- echoClient.SetAttribute ("Interval", TimeValue (Seconds ((interval/1000.0))));
- echoClient.SetAttribute ("PacketSize", UintegerValue (1472));
-
- ApplicationContainer clientApps =
- echoClient.Install (wifiStaNodes);
- clientApps.Start (Seconds (0.5));
- clientApps.Stop (Seconds (simulationTime));
-
- Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
-
- /** connect trace sources **/
- /***************************************************************************/
- // all sources are connected to node 1
- // energy source
-
- Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
-
- //basicSourcePtr0->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
- //device energy model
-
- Ptr<DeviceEnergyModel> basicRadioModelPtr0 =
- basicSourcePtr0->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
-
- NS_ASSERT (basicRadioModelPtr0 != NULL);
- basicRadioModelPtr0->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
-
-/*
-
- Ptr<BasicEnergySource> basicSourcePtr1 = DynamicCast<BasicEnergySource> (wifiStaNodesSources.Get (0));
-
- Ptr<DeviceEnergyModel> basicRadioModelPtr1 =
- basicSourcePtr1->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
-
- NS_ASSERT (basicRadioModelPtr1 != NULL);
- basicRadioModelPtr1->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
-*/
-
-
-
- if (tracing == true)
- {
- //AsciiTraceHelper ascii;
- //pointToPoint.EnableAsciiAll(ascii.CreateFileStream ("energy-wifi.tr"));
- pointToPoint.EnablePcapAll ("wifiEnergy");
- // phySta.EnablePcapAll ("wifiEnergy");
- // phyEdge.EnablePcapAll ("wifiEnergy");
-
- }
-
- //Set simulation time and launch simulation
- Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback(&PhyRxDrop));
- Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback(&PhyTxDrop));
-
-
-// edgeDevices.Get(0)->TraceConnectWithoutContext("PhyTxDrop",MakeCallback(&PhyTxDrop));
-
-
-
- FlowMonitorHelper flowmon;
- Ptr<FlowMonitor> monitor = flowmon.InstallAll();
- Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
-
- Simulator::Stop (Seconds (simulationTime));
- Simulator::Run ();
-
- std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();
-
- double totalThroughput = 0.0;
- double totalLostPackets = 0.0;
- for (std::map< FlowId, FlowMonitor::FlowStats>::iterator flow=stats.begin(); flow!=stats.end(); flow++)
- {
- Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(flow->first);
- NS_LOG_UNCOND( "\nFlowID: " << flow->first << " ("
- << t.sourceAddress << " / " << t.sourcePort << " --> "
- << t.destinationAddress << " / " << t.destinationPort << ")" );
- NS_LOG_UNCOND( " Tx Packets: " << flow->second.txPackets );
- NS_LOG_UNCOND( " Tx Bytes: " << flow->second.txBytes );
-
- offeredLoad = flow->second.txBytes * 8.0 / (flow->second.timeLastTxPacket.GetSeconds () - flow->second.timeFirstTxPacket.GetSeconds ()) / 1000000 ;
- NS_LOG_UNCOND( " Offered Load: " << offeredLoad << " Mbps");
-
- NS_LOG_UNCOND( " Rx Packets: " << flow->second.rxPackets );
- NS_LOG_UNCOND( " Rx Bytes: " << flow->second.rxBytes );
-
- throughput = flow->second.rxBytes * 8.0 / (flow->second.timeLastRxPacket.GetSeconds () - flow->second.timeFirstRxPacket.GetSeconds ()) / 1000000;
- NS_LOG_UNCOND( " Throughput: " << throughput << " Mbps");
-
- NS_LOG_UNCOND( " Lost Packets: " << flow->second.lostPackets );
- NS_LOG_UNCOND( " Time last packet Transmited: " << flow->second.timeLastTxPacket.GetSeconds() );
- NS_LOG_UNCOND( " Time last packet Received: " << flow->second.timeLastRxPacket.GetSeconds() );
-
- if(t.destinationPort == 9){
-
- totalThroughput = totalThroughput + throughput;
- totalLostPackets = totalLostPackets + flow->second.lostPackets;
-
- }
- if(t.destinationPort == 9 && (lastPacketTime < flow->second.timeLastRxPacket.GetSeconds ())){
-
- lastPacketTime = flow->second.timeLastRxPacket.GetSeconds ();
- }
-
-}
- double averageThroughput = totalThroughput/nWifiSta;
- double averageLostPackets = totalLostPackets/nWifiSta;
-
- NS_LOG_UNCOND( "\nLast Packet Time: " << lastPacketTime);
- NS_LOG_UNCOND( "Average Throughput: " << averageThroughput << " Mbps");
- NS_LOG_UNCOND( "Average Lost Packet : " << averageLostPackets);
-
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/ns-3_wifi_tests/wifi-test b/ns-3_wifi_tests/wifi-test
deleted file mode 100755
index 95ffcdf..0000000
--- a/ns-3_wifi_tests/wifi-test
+++ /dev/null
Binary files differ
diff --git a/ns-3_wifi_tests/wifi-test.cc b/ns-3_wifi_tests/wifi-test.cc
deleted file mode 100644
index 1ba2db8..0000000
--- a/ns-3_wifi_tests/wifi-test.cc
+++ /dev/null
@@ -1,262 +0,0 @@
-// ns-3
-
-#include "ns3/command-line.h"
-#include "ns3/config.h"
-#include "ns3/string.h"
-#include "ns3/log.h"
-#include "ns3/yans-wifi-helper.h"
-#include "ns3/ssid.h"
-#include "ns3/mobility-helper.h"
-#include "ns3/on-off-helper.h"
-#include "ns3/yans-wifi-channel.h"
-#include "ns3/mobility-model.h"
-#include "ns3/packet-sink.h"
-#include "ns3/packet-sink-helper.h"
-#include "ns3/udp-echo-helper.h"
-#include "ns3/tcp-westwood.h"
-#include "ns3/internet-stack-helper.h"
-#include "ns3/ipv4-address-helper.h"
-#include "ns3/ipv4-global-routing-helper.h"
-#include "ns3/constant-position-mobility-model.h"
-#include "ns3/energy-module.h"
-#include "ns3/wifi-radio-energy-model-helper.h"
-#include "ns3/point-to-point-helper.h"
-
-// C++ library
-#include <iostream>
-#include <utility> // To use std::pair
-#include <iomanip>
-
-using namespace ns3;
-NS_LOG_COMPONENT_DEFINE ("wifi-tcp");
-
-Ipv4Address cloudIP;
-int cloudPort=50;
-
-
-// ---------- Code ----------
-// Cell tuple like ((APNode,SensorNodes),(APNetDev,SensorsNetDev))
-typedef std::pair<NodeContainer,NodeContainer> CellNodes;
-typedef std::pair<NetDeviceContainer,NetDeviceContainer> CellNetDevices;
-typedef std::pair<CellNodes,CellNetDevices> Cell;
-
-
-
-void CloudSwitchRx(Ptr< const Packet > packet, const Address &address){
- NS_LOG_UNCOND(std::setw(7)<<Simulator::Now ().GetSeconds ()<< " Cloud switch receive a packet!");
-}
-
-void
-TotalEnergy (std::string context,double oldValue, double newValue)
-{
- NS_LOG_UNCOND ("Energy Value of node " << context << " at time " <<Simulator::Now ().GetSeconds ()
- << "\t"<< newValue);
-}
-
-
-
-/**
- * Create a sensors cell base on
- * nbSensors Number of temperature sensors in the cell
- * ap the Access Point (usually linked to the cloud)
- */
-Cell createCell(uint32_t nbSensors, Ptr<ns3::Node> ap){
- // Create sensors
- NodeContainer sensors;
- sensors.Create(nbSensors);
-
- // Place nodes somehow, this is required by every wireless simulation
- for (uint8_t i = 0; i < nbSensors; ++i)
- {
- sensors.Get (i)->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
- }
- ap->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
-
- // To apply XXWifiPhy and WifiMac on sensors
- WifiHelper wifiHelper;
- wifiHelper.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
-
- /* Set up Legacy Channel */
- YansWifiChannelHelper wifiChannel;
- wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
- wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel", "Frequency", DoubleValue (5e9));
-
- /* Setup Physical Layer */
- YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
- wifiPhy.SetChannel (wifiChannel.Create ());
- wifiPhy.Set ("TxPowerStart", DoubleValue (10.0));
- wifiPhy.Set ("TxPowerEnd", DoubleValue (10.0));
- wifiPhy.Set ("TxPowerLevels", UintegerValue (1));
- wifiPhy.Set ("TxGain", DoubleValue (0));
- wifiPhy.Set ("RxGain", DoubleValue (0));
- wifiPhy.Set ("RxNoiseFigure", DoubleValue (10));
- wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-79));
- wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-79 + 3));
- // wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel");
- wifiHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
- "DataMode", StringValue ("HtMcs7"),
- "ControlMode", StringValue ("HtMcs0"));
- /* Configure AP */
- Ssid ssid = Ssid ("network");
- WifiMacHelper wifiMac;
- wifiMac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid));
- NetDeviceContainer apNetDevice;
- apNetDevice = wifiHelper.Install (wifiPhy, wifiMac, ap);
- /* Configure STA */
- wifiMac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid));
- NetDeviceContainer sensorsNetDevices;
- sensorsNetDevices = wifiHelper.Install (wifiPhy, wifiMac, sensors);
-
- return(std::make_pair(std::make_pair(ap,sensors),std::make_pair(apNetDevice,sensorsNetDevices)));
-}
-
-
-/**
- * Install network stack and applications
- */
-void applyScenarios(Cell cell,int sensorsPktSize, int sensorsSendInterval){
- NodeContainer ap=cell.first.first;
- NodeContainer sensors=cell.first.second;
- NetDeviceContainer apNetDev= cell.second.first;
- NetDeviceContainer sensorsNetDev= cell.second.second;
-
- // 6. Install TCP/IP stack & assign IP addresses
- InternetStackHelper internet;
- // internet.Install (ap);
- internet.Install (sensors);
- Ipv4AddressHelper ipv4;
- ipv4.SetBase ("10.0.0.0", "255.255.255.0");
- Ipv4InterfaceContainer apInt,sensorsInt;
- apInt=ipv4.Assign(apNetDev);
- sensorsInt=ipv4.Assign(sensorsNetDev);
-
- UdpEchoClientHelper echoClientHelper (InetSocketAddress (cloudIP, cloudPort));
- // echoClientHelper.SetAttribute ("MaxPackets", UintegerValue (10));
- echoClientHelper.SetAttribute ("Interval", TimeValue (Seconds (sensorsSendInterval)));
- echoClientHelper.SetAttribute ("PacketSize", UintegerValue (sensorsPktSize));
- ApplicationContainer pingApps;
-
- // again using different start times to workaround Bug 388 and Bug 912
- echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (1))); // Start at 1 (WIFI seems to not work when t<1)
- echoClientHelper.Install (sensors);
-}
-
-Ptr<ns3::Node> buildEdgeAndCloud(int nbOp){
-
- NodeContainer OpNodes;
- OpNodes.Create(nbOp+1);
-
- InternetStackHelper stack;
- stack.Install(OpNodes);
-
- for(int i=0;i<nbOp;i++){ // Not nbOp-1 (We add a AP)
- NodeContainer curNodes(OpNodes.Get(i),OpNodes.Get(i+1));
-
- PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
-
- NetDeviceContainer p2pDevices;
- p2pDevices = pointToPoint.Install (curNodes);
-
- Ipv4AddressHelper address;
- address.SetBase (("10.1."+std::to_string(i)+".0").c_str(), "255.255.255.0");
- Ipv4InterfaceContainer p2pInterfaces;
- p2pInterfaces = address.Assign (p2pDevices);
-
- // NS_LOG_UNCOND(i);
- if(i==nbOp-1){ // If we are on the last Op
- cloudIP=p2pInterfaces.GetAddress (1);
-
- PacketSinkHelper apSink("ns3::UdpSocketFactory",InetSocketAddress (Ipv4Address::GetAny (), cloudPort));
- ApplicationContainer sinkApp=apSink.Install(curNodes.Get(1));
- sinkApp.Get(0)->TraceConnectWithoutContext("Rx",MakeCallback(&CloudSwitchRx));
- sinkApp.Start (Seconds (0));
- }
- }
- return(OpNodes.Get(0));
-
-}
-
-
-void setupEnergy(Cell cell){
- NodeContainer nodes(cell.first.first,cell.first.second);
- NetDeviceContainer nodesNetDev(cell.second.first,cell.second.second);
-
- // Install energy source
- BasicEnergySourceHelper edgeBasicSourceHelper;
- edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (2.9009));
- edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (3.3));
- EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.first);
- EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.second);
-
- // Install device energy model
- WifiRadioEnergyModelHelper radioEnergyHelper;
- radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.38));
- radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.313));
- radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.273));
- DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (cell.second.first, apEdgeNodesSources);
- DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (cell.second.second, wifiEdgeNodesSources);
-
-
- // Trace
- DeviceEnergyModelContainer energyModels(edgeApDeviceModels, edgeDeviceModels);
- DeviceEnergyModelContainer::Iterator it=energyModels.Begin();
-
- int i=0;
- while(it!=energyModels.End()){
- (*it)->TraceConnect ("TotalEnergyConsumption", std::to_string(i),MakeCallback (&TotalEnergy));
- it++;
- i++;
- }
-
-
-
-
- // Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
-
- // //basicSourcePtr0->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
- // //device energy model
-
- // Ptr<DeviceEnergyModel> basicRadioModelPtr0 =
- // basicSourcePtr0->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
-
- // NS_ASSERT (basicRadioModelPtr0 != NULL);
- // basicRadioModelPtr0->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
-
-
-}
-
-
-int main(int argc, char* argv[]){
-
- //LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
- // LogComponentEnable("PacketSink", LOG_LEVEL_INFO);
-
- uint32_t sensorsFrequency=1;
- uint32_t sensorsPktSize=150;
- uint32_t sensorsNumber=2;
- uint32_t nbHop=5;
-
- CommandLine cmd;
- cmd.AddValue ("sensorsSendInterval", "Number of temperature measurement per second", sensorsFrequency);
- cmd.AddValue ("sensorsPktSize", "Sensor measurements packet size (bytes)", sensorsPktSize);
- cmd.AddValue ("sensorsNumber", "Number of sensors", sensorsNumber);
- cmd.AddValue ("nbHop", "Number of hop between AP and Cloud sensors", sensorsNumber);
- cmd.Parse (argc, argv);
-
-
- Cell c=createCell(sensorsNumber,buildEdgeAndCloud(nbHop));
-
- applyScenarios(c,sensorsPktSize,sensorsFrequency);
- // setupEnergy(c);
- Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
- // Run simulators
- Simulator::Stop (Seconds (20));
- Simulator::Run ();
-
- // Destroy
- Simulator::Destroy ();
-
- return(0);
-}