43 #include "ns3/abort.h" 44 #include "ns3/core-module.h" 45 #include "ns3/internet-module.h" 46 #include "ns3/network-module.h" 47 #include "ns3/fd-net-device-module.h" 48 #include "ns3/internet-apps-module.h" 49 #include "ns3/ipv4-list-routing-helper.h" 50 #include "ns3/traffic-control-module.h" 64 #ifdef HAVE_NETMAP_USER_H 74 main (
int argc,
char *argv[])
78 std::string deviceName0 (
"enx503f56005a2a");
79 std::string deviceName1 (
"eno1");
80 std::string ip0 (
"10.0.1.2");
81 std::string ip1 (
"10.0.2.1");
82 std::string mask0 (
"255.255.255.0");
83 std::string mask1 (
"255.255.255.0");
84 std::string m0 (
"00:00:00:aa:00:01");
85 std::string
m1 (
"00:00:00:aa:00:02");
86 std::string queueDiscType =
"PfifoFast";
92 std::string emuMode (
"raw");
93 #else // HAVE_NETMAP_USER_H is true (otherwise this example is not compiled) 94 std::string emuMode (
"netmap");
98 cmd.AddValue (
"deviceName0",
"Device name", deviceName0);
99 cmd.AddValue (
"deviceName1",
"Device name", deviceName1);
100 cmd.AddValue (
"ip0",
"Local IP address", ip0);
101 cmd.AddValue (
"ip1",
"Local IP address", ip1);
102 cmd.AddValue (
"mask0",
"Local mask", mask0);
103 cmd.AddValue (
"mask1",
"Local mask", mask1);
104 cmd.AddValue (
"m0",
"Mac address", m0);
105 cmd.AddValue (
"m1",
"Mac address",
m1);
106 cmd.AddValue (
"writer",
"Enable write stats", writer);
107 cmd.AddValue (
"queueDiscType",
"Bottleneck queue disc type in {PfifoFast, ARED, CoDel, FqCoDel, PIE}", queueDiscType);
108 cmd.AddValue (
"bql",
"Enable byte queue limits on bottleneck netdevice", bql);
109 cmd.AddValue (
"index",
"Experiment index", index);
110 cmd.AddValue (
"emuMode",
"Emulation mode in {raw, netmap}", emuMode);
111 cmd.Parse (argc, argv);
166 if (emuMode ==
"raw")
177 #ifdef HAVE_NETMAP_USER_H 178 if (emuMode ==
"netmap")
190 if ((helper0 ==
nullptr) || (helper1 ==
nullptr))
210 internetStackHelper.
Install (node);
220 ipv4->
SetUp (interface0);
228 ipv4->
SetUp (interface1);
241 if (queueDiscType.compare (
"PfifoFast") == 0)
245 else if (queueDiscType.compare (
"ARED") == 0)
256 else if (queueDiscType.compare (
"CoDel") == 0)
260 else if (queueDiscType.compare (
"FqCoDel") == 0)
264 else if (queueDiscType.compare (
"PIE") == 0)
293 #ifdef HAVE_NETMAP_USER_H 294 if (emuMode.compare (
"netmap") == 0)
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Manage ASCII trace files for device models.
AttributeValue implementation for Boolean.
QueueDiscContainer Install(NetDeviceContainer c)
Class for representing queue sizes.
uint32_t nTotalDroppedPackets
Total dropped packets.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
Hold variables of type string.
a class to represent an Ipv4 address mask
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices...
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
build a set of FdNetDevice objects Normally we eschew multiple inheritance, however, the classes PcapUserHelperForDevice and AsciiTraceUserHelperForDevice are treated as "mixins".
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
const double m1
First component modulus, 232 - 209.
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. ...
uint32_t GetBytesInNetmapTxRing()
Get the number of bytes currently in the netmap transmission ring.
virtual void SetForwarding(uint32_t interface, bool val)=0
Holds a vector of ns3::QueueDisc pointers.
void TcPacketsInQueue(Ptr< QueueDisc > q, Ptr< OutputStreamWrapper > stream)
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
AttributeValue implementation for Time.
virtual void SetUp(uint32_t interface)=0
Hold an unsigned integer type.
Use number of packets for queue size.
holds a vector of ns3::NetDevice pointers
Build a set of QueueDisc objects.
const Stats & GetStats(void)
Retrieve all the collected statistics.
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...
Parse command-line arguments.
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...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Access to the IPv4 forwarding table, interfaces, and configuration.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetDeviceName(std::string deviceName)
Set the device name of this device.
build a set of FdNetDevice objects attached to a physical network interface
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
static Time Now(void)
Return the current simulation virtual time.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4 addresses are stored in host order in this class.
void SetDeviceName(std::string deviceName)
Set the device name of this device.
a class to store IPv4 address information on an interface
AttributeValue implementation for Mac48Address.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
Helper class that adds ns3::Ipv4GlobalRouting objects.
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
uint64_t nTotalDroppedBytes
Total dropped bytes.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
build a set of FdNetDevice objects attached to a physical network interface
Use number of bytes for queue size.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.