27 #include "ns3/core-module.h"
28 #include "ns3/csma-module.h"
29 #include "ns3/applications-module.h"
30 #include "ns3/internet-module.h"
31 #include "ns3/network-module.h"
54 uint32_t pktCount,
Time pktInterval )
58 socket->
Send (Create<Packet> (pktSize));
60 socket, pktSize,pktCount - 1, pktInterval);
69 main (
int argc,
char *argv[])
75 uint32_t packetSize = 1024;
76 uint32_t packetCount = 10;
77 double packetInterval = 1.0;
81 bool ipRecvTos =
true;
83 bool ipRecvTtl =
true;
86 cmd.
AddValue (
"PacketSize",
"Packet size in bytes", packetSize);
87 cmd.
AddValue (
"PacketCount",
"Number of packets to send", packetCount);
88 cmd.
AddValue (
"Interval",
"Interval between packets", packetInterval);
89 cmd.
AddValue (
"IP_TOS",
"IP_TOS", ipTos);
90 cmd.
AddValue (
"IP_RECVTOS",
"IP_RECVTOS", ipRecvTos);
91 cmd.
AddValue (
"IP_TTL",
"IP_TTL", ipTtl);
92 cmd.
AddValue (
"IP_RECVTTL",
"IP_RECVTTL", ipRecvTtl);
93 cmd.
Parse (argc, argv);
114 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
125 recvSink->
Bind (local);
149 Time interPacketInterval = Seconds (packetInterval);
152 source, packetSize, packetCount, interPacketInterval);
static void SendPacket(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval)
keep track of time values and allow control of global simulation resolution
Manage ASCII trace files for device models.
static Ipv4Address GetAny(void)
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
holds a vector of std::pair of Ptr and interface index.
uint8_t GetTos(void) const
Get the tag's TOS.
int main(int argc, char *argv[])
static void Run(void)
Run the simulation until one of:
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
aggregate IP/TCP/UDP functionality to existing Nodes.
void ReceivePacket(Ptr< Socket > socket)
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
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. ...
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
a polymophic address class
Class for representing data rates.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
hold objects of type ns3::Time
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
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...
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
Parse command-line arguments.
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
keep track of a set of node pointers.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
build a set of CsmaNetDevice objects
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
uint32_t GetId(void) const
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
hold objects of type ns3::DataRate
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
void SetIpRecvTtl(bool ipv4RecvTtl)
Tells a socket to pass information about IP_TTL up the stack.
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
uint8_t GetTtl(void) const
Get the tag's TTL.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Close(void)=0
Close a socket.
indicates whether the socket has IP_TOS set.
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
a unique identifier for an interface.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
static TypeId LookupByName(std::string name)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const