|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
44 #include <sys/socket.h>
47 #include "ns3/core-module.h"
48 #include "ns3/network-module.h"
49 #include "ns3/internet-module.h"
50 #include "ns3/fd-net-device-module.h"
51 #include "ns3/applications-module.h"
58 main (
int argc,
char *argv[])
65 cmd.AddValue (
"tcpMode",
"1:true, 0:false, default mode UDP",tcpMode);
66 cmd.Parse (argc, argv);
71 factory =
"ns3::TcpSocketFactory";
75 factory =
"ns3::UdpSocketFactory";
80 uint16_t sinkPort = 8000;
82 std::string dataRate(
"10Mb/s");
93 if (socketpair (AF_UNIX, SOCK_DGRAM, 0, sv) < 0)
113 addresses.
SetBase (
"10.0.0.0",
"255.255.255.0");
127 fd.
EnablePcap (
"fd2fd-onoff-server", serverDevice);
132 onoff.SetAttribute (
"Remote", serverAddress);
133 onoff.SetAttribute (
"OnTime",
StringValue (
"ns3::ConstantRandomVariable[Constant=1]"));
134 onoff.SetAttribute (
"OffTime",
StringValue (
"ns3::ConstantRandomVariable[Constant=0]"));
140 fd.
EnablePcap (
"fd2fd-onoff-client", clientDevice);
holds a vector of ns3::NetDevice pointers
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
AttributeValue implementation for DataRate.
Parse command-line arguments.
AttributeValue implementation for Boolean.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
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.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetFileDescriptor(int fd)
Set the associated file descriptor.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
AttributeValue implementation for Address.
Ipv4 addresses are stored in host order in this class.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
a polymophic address class
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
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.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
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.
a NetDevice to read/write network traffic from/into a file descriptor.
static const uint32_t packetSize
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
build a set of FdNetDevice objects Normally we eschew multiple inheritance, however,...
Time Seconds(double value)
Construct a Time in the indicated unit.
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.
keep track of a set of node pointers.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
Hold an unsigned integer type.
aggregate IP/TCP/UDP functionality to existing Nodes.