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.",
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",
70 "ns3::Packet::TracedCallback")
79 m_interval = CreateObject<ConstantRandomVariable> ();
105 m_socket = socketFactory->CreateSocket ();
143 if (++m_count < m_numPkts) {
162 .AddConstructor<Receiver> ()
163 .AddAttribute (
"Port",
"Listening port.",
166 MakeUintegerChecker<uint32_t>())
191 Application::DoDispose ();
201 (UdpSocketFactory::GetTypeId ());
202 m_socket = socketFactory->CreateSocket ();
245 while ((packet = socket->
RecvFrom (from))) {
246 if (InetSocketAddress::IsMatchingType (from)) {
248 InetSocketAddress::ConvertFrom (from).GetIpv4 ());
283 .AddConstructor<TimestampTag> ()
284 .AddAttribute (
"Timestamp",
285 "Some momentous point in time!",
307 i.
Write ((
const uint8_t *)&t, 8);
313 i.
Read ((uint8_t *)&t, 8);
virtual void StopApplication(void)
Application specific shutdown code.
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
void Receive(Ptr< Socket > socket)
virtual void StartApplication(void)
Application specific startup code.
static TypeId GetTypeId(void)
Ptr< CounterCalculator<> > m_calc
void SetCounter(Ptr< CounterCalculator<> > calc)
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
virtual void DoDispose(void)
Destructor implementation.
Ptr< ConstantRandomVariable > m_interval
static TypeId GetTypeId(void)
virtual void StartApplication(void)
Application specific startup code.
virtual void DoDispose(void)
Destructor implementation.
TracedCallback< Ptr< const Packet > > m_txTrace
virtual void StopApplication(void)
Application specific shutdown code.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void Print(std::ostream &os) const
static TypeId GetTypeId(void)
void SetTimestamp(Time time)
virtual void Serialize(TagBuffer i) const
virtual uint32_t GetSerializedSize(void) const
virtual void Deserialize(TagBuffer i)
Time GetTimestamp(void) const
a polymophic address class
The base class for all ns3 applications.
virtual void DoDispose(void)
Destructor implementation.
Ptr< Node > GetNode() const
Template class CounterCalculator.
A class for an empty attribute value.
AttributeValue implementation for Ipv4Address.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
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.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Smart pointer class similar to boost::intrusive_ptr.
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 EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static Time Now(void)
Return the current simulation virtual time.
Object to create transport layer instances that provide a socket API to applications.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
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.
void Read(uint8_t *buffer, uint32_t size)
void Write(const uint8_t *buffer, uint32_t size)
tag a set of bytes in a packet
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void Update(const Time i)
Updates all variables of TimeMinMaxAvgTotalCalculator.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static TypeId GetTypeId(void)
Get the type ID.
Hold an unsigned integer type.
Ptr< const AttributeChecker > MakeIpv4AddressChecker(void)
Ptr< const AttributeAccessor > MakeIpv4AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Ts... > MakeNullCallback(void)
#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 Now(void)
create an ns3::Time instance which contains the current simulation time.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...