|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
54 #include "ns3/core-module.h"
55 #include "ns3/network-module.h"
56 #include "ns3/internet-module.h"
57 #include "ns3/point-to-point-module.h"
58 #include "ns3/applications-module.h"
59 #include "ns3/config-store-module.h"
60 #include "ns3/error-model.h"
61 #include "ns3/tcp-header.h"
62 #include "ns3/udp-header.h"
64 #include "ns3/event-id.h"
65 #include "ns3/ipv4-global-routing-helper.h"
66 #include "ns3/traffic-control-module.h"
75 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
82 if (cwndTrFileName.compare (
"") == 0)
97 *stream->
GetStream () << newval << std::endl;
104 if (sojournTrFileName.compare (
"") == 0)
119 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
126 if (queueLengthTrFileName.compare (
"") == 0)
128 NS_LOG_DEBUG (
"No trace file for queue length provided");
148 if (everyDropTrFileName.compare (
"") == 0)
150 NS_LOG_DEBUG (
"No trace file for every drop event provided");
163 if (oldVal ==
false && newVal ==
true)
168 else if (oldVal ==
true && newVal ==
false)
179 if (dropStateTrFileName.compare (
"") == 0)
181 NS_LOG_DEBUG (
"No trace file for dropping state provided");
214 int main (
int argc,
char *argv[])
216 std::string serverCmtsDelay =
"15ms";
217 std::string cmtsRouterDelay =
"6ms";
218 std::string routerHostDelay =
"0.1ms";
219 std::string serverLanDataRate =
"10Gbps";
220 std::string cmtsLanDataRate =
"10Gbps";
221 std::string cmtsWanDataRate =
"22Mbps";
222 std::string routerWanDataRate =
"5Mbps";
223 std::string routerLanDataRate =
"10Gbps";
224 std::string hostLanDataRate =
"10Gbps";
226 std::string routerWanQueueDiscType =
"CoDel";
228 uint32_t queueSize = 1000;
229 uint32_t numOfUpLoadBulkFlows = 1;
230 uint32_t numOfDownLoadBulkFlows = 1;
231 uint32_t numOfUpLoadOnOffFlows = 1;
232 uint32_t numOfDownLoadOnOffFlows = 1;
233 bool isPcapEnabled =
true;
236 float simDuration = 60;
238 std::string fileNamePrefix =
"codel-vs-pfifo-fast-asymmetric";
242 cmd.AddValue (
"serverCmtsDelay",
"Link delay between server and CMTS", serverCmtsDelay);
243 cmd.AddValue (
"cmtsRouterDelay",
"Link delay between CMTS and rounter", cmtsRouterDelay);
244 cmd.AddValue (
"routerHostDelay",
"Link delay between router and host", routerHostDelay);
245 cmd.AddValue (
"serverLanDataRate",
"Server LAN net device data rate", serverLanDataRate);
246 cmd.AddValue (
"cmtsLanDataRate",
"CMTS LAN net device data rate", cmtsLanDataRate);
247 cmd.AddValue (
"cmtsWanDataRate",
"CMTS WAN net device data rate", cmtsWanDataRate);
248 cmd.AddValue (
"routerWanDataRate",
"Router WAN net device data rate", routerWanDataRate);
249 cmd.AddValue (
"routerLanDataRate",
"Router LAN net device data rate", routerLanDataRate);
250 cmd.AddValue (
"hostLanDataRate",
"Host LAN net device data rate", hostLanDataRate);
251 cmd.AddValue (
"routerWanQueueDiscType",
"Router WAN queue disc type: "
252 "PfifoFast, CoDel", routerWanQueueDiscType);
253 cmd.AddValue (
"queueSize",
"Queue size in packets", queueSize);
254 cmd.AddValue (
"pktSize",
"Packet size in bytes",
pktSize);
255 cmd.AddValue (
"numOfUpLoadBulkFlows",
"Number of upload bulk transfer flows", numOfUpLoadBulkFlows);
256 cmd.AddValue (
"numOfDownLoadBulkFlows",
"Number of download bulk transfer flows", numOfDownLoadBulkFlows);
257 cmd.AddValue (
"numOfUpLoadOnOffFlows",
"Number of upload OnOff flows", numOfUpLoadOnOffFlows);
258 cmd.AddValue (
"numOfDownLoadOnOffFlows",
"Number of download OnOff flows", numOfDownLoadOnOffFlows);
259 cmd.AddValue (
"startTime",
"Simulation start time",
startTime);
260 cmd.AddValue (
"simDuration",
"Simulation duration in seconds", simDuration);
261 cmd.AddValue (
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
262 cmd.AddValue (
"logging",
"Flag to enable/disable logging", logging);
263 cmd.Parse (argc, argv);
267 std::string pcapFileName = fileNamePrefix +
"-" + routerWanQueueDiscType;
268 std::string cwndTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-cwnd" +
".tr";
269 std::string attributeFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
".attr";
270 std::string sojournTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-sojourn" +
".tr";
271 std::string queueLengthTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-length" +
".tr";
272 std::string everyDropTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop" +
".tr";
273 std::string dropStateTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop-state" +
".tr";
312 NS_LOG_INFO (
"Create channels and install net devices on nodes");
342 NS_LOG_INFO (
"Install Internet stack on all nodes");
352 tchPfifo.
Install (serverCmtsDev);
354 if (routerWanQueueDiscType.compare (
"PfifoFast") == 0)
356 tchPfifo.
Install (routerWanDev);
358 else if (routerWanQueueDiscType.compare (
"CoDel") == 0)
360 tchCoDel.
Install (routerWanDev);
367 tchPfifo.
Install (routerHostDev);
371 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
373 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
375 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
382 uint16_t port1 = 50000;
389 while (numOfDownLoadBulkFlows)
392 numOfDownLoadBulkFlows--;
395 while (numOfDownLoadOnOffFlows)
398 numOfDownLoadOnOffFlows--;
402 uint16_t port2 = 50001;
409 while (numOfUpLoadBulkFlows)
412 numOfUpLoadBulkFlows--;
415 while (numOfUpLoadOnOffFlows)
418 numOfUpLoadOnOffFlows--;
423 if (routerWanQueueDiscType.compare (
"CoDel") == 0)
holds a vector of ns3::NetDevice pointers
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Parse command-line arguments.
AttributeValue implementation for Boolean.
uint16_t SetRootQueueDisc(const std::string &type, Args &&... args)
Helper function used to set a root queue disc of the given type and with the given attributes.
@ LOG_LEVEL_FUNCTION
LOG_FUNCTION and above.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
static void CwndTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
AttributeValue implementation for Address.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
NetDeviceContainer Install(NodeContainer c)
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
@ PACKETS
Use number of packets for queue size.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void TraceDroppingState(std::string dropStateTrFileName)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
static void EveryDropTracer(Ptr< OutputStreamWrapper >stream, Ptr< const QueueDiscItem > item)
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
QueueDiscContainer Install(NetDeviceContainer c)
a polymophic address class
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
static void DroppingStateTracer(Ptr< OutputStreamWrapper >stream, bool oldVal, bool newVal)
Introspection did not find any typical Config paths.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void CreateOnOffFlow(AddressValue remoteAddress, Ptr< Node > sender, float stopTime)
Simulation virtual time values and global simulation resolution.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
static void TraceEveryDrop(std::string everyDropTrFileName)
void ConfigureDefaults(void)
Configure the default values.
static void Run(void)
Run the simulation.
Hold variables of type string.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Manage ASCII trace files for device models.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void CreateBulkFlow(AddressValue remoteAddress, Ptr< Node > sender, uint32_t pktSize, float stopTime)
static Ipv4Address GetAny(void)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Time Seconds(double value)
Construct a Time in the indicated unit.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Build a set of QueueDisc objects.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
holds a vector of ns3::Application pointers.
uint32_t pktSize
packet size used for the simulation (in bytes)
Build a set of PointToPointNetDevice objects.
keep track of a set of node pointers.
static void TraceCwnd(std::string cwndTrFileName)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
static void TraceSojourn(std::string sojournTrFileName)
void ConfigureAttributes(void)
Configure the attribute values.
void SetDefault(std::string name, const AttributeValue &value)
static void SojournTracer(Ptr< OutputStreamWrapper >stream, Time newval)
Class for representing queue sizes.
aggregate IP/TCP/UDP functionality to existing Nodes.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
static void TraceQueueLength(std::string queueLengthTrFileName)
static void QueueLengthTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.