105 #include "ns3/applications-module.h"
106 #include "ns3/core-module.h"
107 #include "ns3/fd-net-device-module.h"
108 #include "ns3/internet-module.h"
109 #include "ns3/network-module.h"
121 main(
int argc,
char* argv[])
123 uint16_t sinkPort = 8000;
125 std::string dataRate(
"1000Mb/s");
126 bool serverMode =
false;
128 std::string deviceName(
"eth0");
129 std::string
client(
"10.1.1.1");
130 std::string
server(
"10.1.1.2");
131 std::string netmask(
"255.255.255.0");
132 std::string macClient(
"00:00:00:00:00:01");
133 std::string macServer(
"00:00:00:00:00:02");
134 std::string transportProt =
"Tcp";
135 std::string socketType;
137 std::string emuMode(
"raw");
138 #elif HAVE_NETMAP_USER_H
139 std::string emuMode(
"netmap");
141 std::string emuMode(
"dpdk");
145 cmd.AddValue(
"deviceName",
146 "Device name (in raw, netmap mode) or Device address (in dpdk mode, eg: "
147 "0000:00:1f.6). Use `lspci` to find device address.",
149 cmd.AddValue(
"client",
"Local IP address (dotted decimal only please)",
client);
150 cmd.AddValue(
"server",
"Remote IP address (dotted decimal only please)",
server);
151 cmd.AddValue(
"localmask",
"Local mask address (dotted decimal only please)", netmask);
152 cmd.AddValue(
"serverMode",
"1:true, 0:false, default client", serverMode);
153 cmd.AddValue(
"mac-client",
"Mac Address for Server Client : 00:00:00:00:00:01", macClient);
154 cmd.AddValue(
"mac-server",
"Mac Address for Server Default : 00:00:00:00:00:02", macServer);
155 cmd.AddValue(
"data-rate",
"Data rate defaults to 1000Mb/s", dataRate);
156 cmd.AddValue(
"transportProt",
"Transport protocol to use: Tcp, Udp", transportProt);
157 cmd.AddValue(
"emuMode",
"Emulation mode in {raw, netmap}", emuMode);
158 cmd.Parse(argc, argv);
160 if (transportProt ==
"Tcp")
162 socketType =
"ns3::TcpSocketFactory";
166 socketType =
"ns3::UdpSocketFactory";
171 Mac48AddressValue localMac;
179 localMac = Mac48AddressValue(macServer.c_str());
185 localMac = Mac48AddressValue(macClient.c_str());
188 Ipv4Mask localMask(netmask.c_str());
201 if (emuMode ==
"raw")
208 #ifdef HAVE_NETMAP_USER_H
209 if (emuMode ==
"netmap")
216 #ifdef HAVE_DPDK_USER_H
217 if (emuMode ==
"dpdk")
232 if (helper ==
nullptr)
239 device->SetAttribute(
"Address", localMac);
244 internetStackHelper.
Install(node);
248 uint32_t
interface =
ipv4->AddInterface(device);
251 ipv4->SetMetric(interface, 1);
252 ipv4->SetUp(interface);
269 onoff.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
270 onoff.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
271 onoff.SetAttribute(
"DataRate", DataRateValue(dataRate));
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Parse command-line arguments.
build a DpdkNetDevice object attached to a physical network interface
void SetPmdLibrary(std::string pmdLibrary)
Sets PMD Library to be used for the NIC.
void SetDpdkDriver(std::string dpdkDriver)
Sets DPDK Driver to bind NIC to.
build a set of FdNetDevice objects attached to a physical network interface
void SetDeviceName(std::string deviceName)
Set the device name of this device.
build a set of FdNetDevice objects Normally we eschew multiple inheritance, however,...
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
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...
aggregate IP/TCP/UDP functionality to existing Nodes.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
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.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
holds a vector of ns3::NetDevice pointers
build a set of FdNetDevice objects attached to a physical network interface
void SetDeviceName(std::string deviceName)
Set the device name of this device.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint32_t packetSize
Packet size generated at the AP.