25 #include "ns3/core-module.h"
26 #include "ns3/csma-module.h"
27 #include "ns3/internet-module.h"
28 #include "ns3/network-module.h"
68 main(
int argc,
char* argv[])
75 uint32_t packetCount = 10;
76 double packetInterval = 1.0;
80 bool ipRecvTos =
true;
82 bool ipRecvTtl =
true;
85 cmd.AddValue(
"PacketSize",
"Packet size in bytes",
packetSize);
86 cmd.AddValue(
"PacketCount",
"Number of packets to send", packetCount);
87 cmd.AddValue(
"Interval",
"Interval between packets", packetInterval);
88 cmd.AddValue(
"IP_TOS",
"IP_TOS", ipTos);
89 cmd.AddValue(
"IP_RECVTOS",
"IP_RECVTOS", ipRecvTos);
90 cmd.AddValue(
"IP_TTL",
"IP_TTL", ipTtl);
91 cmd.AddValue(
"IP_RECVTTL",
"IP_RECVTTL", ipRecvTtl);
92 cmd.Parse(argc, argv);
105 csma.SetChannelAttribute(
"DataRate", DataRateValue(
DataRate(5000000)));
112 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
123 recvSink->
Bind(local);
145 csma.EnablePcapAll(
"socket-options-ipv4",
false);
148 Time interPacketInterval =
Seconds(packetInterval);
155 interPacketInterval);
a polymophic address class
Manage ASCII trace files for device models.
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.
Parse command-line arguments.
build a set of CsmaNetDevice objects
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static Ipv4Address GetAny()
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void Run()
Run the simulation.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual int Close()=0
Close a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetIpRecvTtl(bool ipv4RecvTtl)
Tells a socket to pass information about IP_TTL up the stack.
indicates whether the socket has IP_TOS set.
uint8_t GetTos() const
Get the tag's TOS.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
uint8_t GetTtl() const
Get the tag's TTL.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Hold an unsigned integer type.
#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.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void ReceivePacket(Ptr< Socket > socket)
static void SendPacket(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval)
uint32_t pktSize
packet size used for the simulation (in bytes)
static const uint32_t packetSize
Packet size generated at the AP.