ns3.29
piaodejiang1994 / ns3.29 Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v2.0
License: GNU General Public License v2.0
ns3.29
Hi,
I implemented a 802.11af standard in NS 3.29 but when I simulated using the wifi-tcp.cc, I noticed that when I use the 100 mbps data rate on the application layer of the tcp file I got a missed ack and a 0 mbps throughput even if there was a re-transmission that happened. On the other hand, when I changed the data rate to 1 mbps on the application layer, I noticed that I got no 0 mbps throughput even if there was a missed ack. I would like to ask why I cannot receive some throughput even if there was a re-transmission that happened and what are the possible factors why I got a missed ack's. Please see below the modified wifi-tcp.cc code for reference.
Best Regards,
Adrian
`/* -- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -- /
/
#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/tcp-westwood.h"
#include "ns3/internet-stack-helper.h"
#include "ns3/ipv4-address-helper.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/animation-interface.h"
NS_LOG_COMPONENT_DEFINE ("wifi-tcp");
using namespace ns3;
Ptr sink; /* Pointer to the packet sink application /
uint64_t lastTotalRx = 0; / The value of the last total received bytes */
bool verbose = false;
void
CalculateThroughput ()
{
Time now = Simulator::Now (); /* Return the simulator's virtual time. /
double cur = (sink->GetTotalRx () - lastTotalRx) * (double) 8 / 1e5; / Convert Application RX Packets to MBits. */
std::cout << now.GetSeconds () << "s: \t" << cur << " Mbit/s" << std::endl;
lastTotalRx = sink->GetTotalRx ();
Simulator::Schedule (MilliSeconds (100), &CalculateThroughput);
}
int
main (int argc, char argv[])
{
uint32_t payloadSize = 1472; / Transport layer payload size in bytes. /
std::string dataRate = "100Mbps"; / Application layer datarate. /
std::string tcpVariant = "TcpNewReno"; / TCP variant type. /
std::string phyRate = "TVhtMcs0"; / Physical layer bitrate. /
double simulationTime = 10; / Simulation time in seconds. /
bool pcapTracing = false; / PCAP Tracing is enabled or not. */
/* Command line argument parser setup. */
CommandLine cmd;
cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize);
cmd.AddValue ("dataRate", "Application data ate", dataRate);
cmd.AddValue ("tcpVariant", "Transport protocol to use: TcpNewReno, "
"TcpHybla, TcpHighSpeed, TcpHtcp, TcpVegas, TcpScalable, TcpVeno, "
"TcpBic, TcpYeah, TcpIllinois, TcpWestwood, TcpWestwoodPlus, TcpLedbat ", tcpVariant);
cmd.AddValue ("phyRate", "Physical layer bitrate", phyRate);
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("pcap", "Enable/disable PCAP Tracing", pcapTracing);
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
cmd.Parse (argc, argv);
tcpVariant = std::string ("ns3::") + tcpVariant;
// Select TCP variant
if (tcpVariant.compare ("ns3::TcpWestwoodPlus") == 0)
{
// TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));
// the default protocol type in ns3::TcpWestwood is WESTWOOD
Config::SetDefault ("ns3::TcpWestwood::ProtocolType", EnumValue (TcpWestwood::WESTWOODPLUS));
}
else
{
TypeId tcpTid;
NS_ABORT_MSG_UNLESS (TypeId::LookupByNameFailSafe (tcpVariant, &tcpTid), "TypeId " << tcpVariant << " not found");
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TypeId::LookupByName (tcpVariant)));
}
/* Configure TCP Options */
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (payloadSize));
WifiMacHelper wifiMac;
WifiHelper wifiHelper;
if (verbose)
{
wifiHelper.EnableLogComponents (); // Turn on all Wifi logging
}
wifiHelper.SetStandard (WIFI_PHY_STANDARD_80211af);
/* Set up Legacy Channel /
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel", "Frequency", DoubleValue (470e6));
//wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel", "Rss", DoubleValue (0));
/ 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 (phyRate),
"ControlMode", StringValue ("TVhtMcs0"));
NodeContainer networkNodes;
networkNodes.Create (2);
Ptr apWifiNode = networkNodes.Get (0);
Ptr staWifiNode = networkNodes.Get (1);
/* Configure AP */
Ssid ssid = Ssid ("network");
wifiMac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevice;
apDevice = wifiHelper.Install (wifiPhy, wifiMac, apWifiNode);
/* Configure STA */
wifiMac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer staDevices;
staDevices = wifiHelper.Install (wifiPhy, wifiMac, staWifiNode);
/* Mobility model */
MobilityHelper mobility;
Ptr positionAlloc = CreateObject ();
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
positionAlloc->Add (Vector (1.0, 1.0, 0.0));
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (apWifiNode);
mobility.Install (staWifiNode);
/* Internet stack */
InternetStackHelper stack;
stack.Install (networkNodes);
Ipv4AddressHelper address;
address.SetBase ("10.0.0.0", "255.255.255.0");
Ipv4InterfaceContainer apInterface;
apInterface = address.Assign (apDevice);
Ipv4InterfaceContainer staInterface;
staInterface = address.Assign (staDevices);
/* Populate routing table */
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
/* Install TCP Receiver on the access point */
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), 9));
ApplicationContainer sinkApp = sinkHelper.Install (apWifiNode);
sink = StaticCast (sinkApp.Get (0));
/* Install TCP/UDP Transmitter on the station */
OnOffHelper server ("ns3::TcpSocketFactory", (InetSocketAddress (apInterface.GetAddress (0), 9)));
server.SetAttribute ("PacketSize", UintegerValue (payloadSize));
server.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
server.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
server.SetAttribute ("DataRate", DataRateValue (DataRate (dataRate)));
ApplicationContainer serverApp = server.Install (staWifiNode);
/* Start Applications */
sinkApp.Start (Seconds (0.0));
serverApp.Start (Seconds (1.0));
Simulator::Schedule (Seconds (1.1), &CalculateThroughput);
AnimationInterface anim ("wireless-animationotin.xml");
/* Enable Traces */
if (pcapTracing)
{
wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
wifiPhy.EnablePcap ("AccessPoint", apDevice);
wifiPhy.EnablePcap ("Station", staDevices);
}
/* Start Simulation */
Simulator::Stop (Seconds (simulationTime + 1));
Simulator::Run ();
double averageThroughput = ((sink->GetTotalRx () * 8) / (1e6 * simulationTime));
Simulator::Destroy ();
/if (averageThroughput < 50)
{
NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!");
exit (1);
}/
std::cout << "\nAverage throughput: " << averageThroughput << " Mbit/s" << std::endl;
return 0;
}
`
This photo shows the throughput when setting the application layer data rate to 1 mbps.
This photo shows the throughput when setting the application layer data rate to 100 mbps.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.