30 #include "ns3/core-module.h"
31 #include "ns3/network-module.h"
32 #include "ns3/internet-module.h"
34 #include "ns3/stats-module.h"
47 .AddConstructor<Sender> ()
48 .AddAttribute (
"PacketSize",
"The size of packets transmitted.",
51 MakeUintegerChecker<uint32_t>(1))
52 .AddAttribute (
"Destination",
"Target host address.",
55 MakeIpv4AddressChecker ())
56 .AddAttribute (
"Port",
"Destination app port.",
59 MakeUintegerChecker<uint32_t>())
60 .AddAttribute (
"NumPackets",
"Total number of packets to send.",
63 MakeUintegerChecker<uint32_t>(1))
64 .AddAttribute (
"Interval",
"Delay between transmissions.",
65 StringValue (
"ns3::ConstantRandomVariable[Constant=0.5]"),
67 MakePointerChecker <RandomVariableStream>())
68 .AddTraceSource (
"Tx",
"A new packet is created and is sent",
78 m_interval = CreateObject<ConstantRandomVariable> ();
142 if (++m_count < m_numPkts) {
161 .AddConstructor<Receiver> ()
162 .AddAttribute (
"Port",
"Listening port.",
165 MakeUintegerChecker<uint32_t>())
190 Application::DoDispose ();
200 (UdpSocketFactory::GetTypeId ());
204 m_socket->Bind (local);
244 while ((packet = socket->
RecvFrom (from))) {
245 if (InetSocketAddress::IsMatchingType (from)) {
247 InetSocketAddress::ConvertFrom (from).GetIpv4 ());
282 .AddConstructor<TimestampTag> ()
283 .AddAttribute (
"Timestamp",
284 "Some momentous point in time!",
306 i.
Write ((
const uint8_t *)&t, 8);
312 i.
Read ((uint8_t *)&t, 8);
static TypeId GetTypeId(void)
Get the type ID.
bool FindFirstMatchingByteTag(Tag &tag) const
void Write(const uint8_t *buffer, uint32_t size)
keep track of time values and allow control of global simulation resolution
smart pointer class similar to boost::intrusive_ptr
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
hold variables of type string
virtual void StopApplication(void)
Application specific shutdown code.
uint32_t GetSize(void) const
virtual Ptr< Socket > CreateSocket(void)=0
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Callback< R > MakeNullCallback(void)
static TypeId GetTypeId(void)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Object to create transport layer instances that provide a socket API to applications.
virtual uint32_t GetSerializedSize(void) const
a polymophic address class
static TypeId GetTypeId(void)
The base class for all ns3 applications.
A class for an empty attribute value.
Hold an unsigned integer type.
Ptr< ConstantRandomVariable > m_interval
Ptr< Node > GetNode() const
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.
virtual void Serialize(TagBuffer i) const
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
tag a set of bytes in a packet
virtual void StopApplication(void)
Application specific shutdown code.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual void StartApplication(void)
Application specific startup code.
static TypeId GetTypeId(void)
virtual void Deserialize(TagBuffer i)
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
Time GetTimestamp(void) const
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
hold objects of type ns3::Ipv4Address
static Time Now(void)
Return the "current simulation time".
int64_t GetNanoSeconds(void) const
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
void Receive(Ptr< Socket > socket)
virtual TypeId GetInstanceTypeId(void) const
void Update()
Increments count by 1.
void Read(uint8_t *buffer, uint32_t size)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
TracedCallback< Ptr< const Packet > > m_txTrace
void Print(std::ostream &os) const
void SetTimestamp(Time time)
void Update(const Time i)
Updates all variables of TimeMinMaxAvgTotalCalculator.
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
Ptr< T > GetObject(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual void StartApplication(void)
Application specific startup code.
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Ptr< CounterCalculator<> > m_calc
void SetCounter(Ptr< CounterCalculator<> > calc)