29 #include "ns3/core-module.h"
30 #include "ns3/internet-module.h"
31 #include "ns3/network-module.h"
32 #include "ns3/stats-module.h"
49 .AddConstructor<Sender>()
50 .AddAttribute(
"PacketSize",
51 "The size of packets transmitted.",
54 MakeUintegerChecker<uint32_t>(1))
55 .AddAttribute(
"Destination",
56 "Target host address.",
57 Ipv4AddressValue(
"255.255.255.255"),
59 MakeIpv4AddressChecker())
61 "Destination app port.",
64 MakeUintegerChecker<uint32_t>())
65 .AddAttribute(
"NumPackets",
66 "Total number of packets to send.",
69 MakeUintegerChecker<uint32_t>(1))
70 .AddAttribute(
"Interval",
71 "Delay between transmissions.",
72 StringValue(
"ns3::ConstantRandomVariable[Constant=0.5]"),
74 MakePointerChecker<RandomVariableStream>())
76 "A new packet is created and is sent",
78 "ns3::Packet::TracedCallback");
85 m_interval = CreateObject<ConstantRandomVariable>();
112 m_socket = socketFactory->CreateSocket();
148 if (++m_count < m_nPackets)
164 .AddConstructor<Receiver>()
165 .AddAttribute(
"Port",
169 MakeUintegerChecker<uint32_t>());
202 m_socket = socketFactory->CreateSocket();
204 m_socket->Bind(local);
240 while ((packet = socket->
RecvFrom(from)))
void StopApplication() override
Application specific shutdown code.
uint32_t m_port
Listening port.
void DoDispose() override
Destructor implementation.
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
Set the delay tracker for received packets.
static TypeId GetTypeId()
Get the type ID.
void Receive(Ptr< Socket > socket)
Receive a packet.
void StartApplication() override
Application specific startup code.
void SetCounter(Ptr< CounterCalculator<>> calc)
Set the counter calculator for received packets.
void SendPacket()
Send a packet.
uint32_t m_destPort
Destination port.
Ptr< ConstantRandomVariable > m_interval
Rng for sending packets.
void StopApplication() override
Application specific shutdown code.
Ipv4Address m_destAddr
Destination address.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
uint32_t m_packetSize
The packet size.
TracedCallback< Ptr< const Packet > > m_txTrace
Tx TracedCallback.
uint32_t m_nPackets
Number of packets to send.
void StartApplication() override
Application specific startup code.
a polymophic address class
The base class for all ns3 applications.
void DoDispose() override
Destructor implementation.
Template class CounterCalculator.
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
static Ipv4Address GetAny()
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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...
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Object to create transport layer instances that provide a socket API to applications.
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.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
Timestamp tag for associating a timestamp with a packet.
void SetTimestamp(Time timestamp)
Set the Timestamp object.
Time GetTimestamp() const
Get the Timestamp object.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static TypeId GetTypeId()
Get the type ID.
Hold an unsigned integer type.
Callback< R, Args... > MakeNullCallback()
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)