83 #include "ns3/core-module.h" 84 #include "ns3/network-module.h" 85 #include "ns3/internet-module.h" 86 #include "ns3/applications-module.h" 87 #include "ns3/config-store-module.h" 88 #include "ns3/fd-net-device-module.h" 95 main (
int argc,
char *argv[])
97 uint16_t sinkPort = 8000;
99 std::string dataRate(
"1000Mb/s");
100 bool serverMode =
false;
102 std::string deviceName (
"eth0");
103 std::string client (
"10.1.1.1");
104 std::string server (
"10.1.1.2");
105 std::string netmask (
"255.255.255.0");
106 std::string macClient (
"00:00:00:00:00:01");
107 std::string macServer (
"00:00:00:00:00:02");
110 cmd.AddValue (
"deviceName",
"Device name", deviceName);
111 cmd.AddValue (
"client",
"Local IP address (dotted decimal only please)", client);
112 cmd.AddValue (
"server",
"Remote IP address (dotted decimal only please)", server);
113 cmd.AddValue (
"localmask",
"Local mask address (dotted decimal only please)", netmask);
114 cmd.AddValue (
"serverMode",
"1:true, 0:false, default client", serverMode);
115 cmd.AddValue (
"mac-client",
"Mac Address for Server Client : 00:00:00:00:00:01", macClient);
116 cmd.AddValue (
"mac-server",
"Mac Address for Server Default : 00:00:00:00:00:02", macServer);
117 cmd.AddValue (
"data-rate",
"Data rate defaults to 1000Mb/s", dataRate);
118 cmd.Parse (argc, argv);
137 Ipv4Mask localMask (netmask.c_str ());
156 internetStackHelper.
Install (node);
160 uint32_t
interface = ipv4->AddInterface (device);
164 ipv4->
SetUp (interface);
180 onoff.SetAttribute (
"Remote", remoteAddress);
181 onoff.SetAttribute (
"OnTime",
StringValue (
"ns3::ConstantRandomVariable[Constant=1]"));
182 onoff.SetAttribute (
"OffTime",
StringValue (
"ns3::ConstantRandomVariable[Constant=0]"));
holds a vector of ns3::Application pointers.
AttributeValue implementation for Boolean.
Hold variables of type string.
a class to represent an Ipv4 address mask
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.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
a polymophic address class
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
virtual void SetUp(uint32_t interface)=0
Hold an unsigned integer type.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
holds a vector of ns3::NetDevice pointers
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...
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
AttributeValue implementation for Address.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
a class to store IPv4 address information on an interface
AttributeValue implementation for DataRate.
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.
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
static const uint32_t packetSize
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
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