22 #include "ns3/ipv4-address.h"
23 #include "ns3/nstime.h"
24 #include "ns3/inet-socket-address.h"
25 #include "ns3/inet6-socket-address.h"
26 #include "ns3/socket.h"
27 #include "ns3/simulator.h"
28 #include "ns3/socket-factory.h"
29 #include "ns3/packet.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/string.h"
61 .AddConstructor<UdpTraceClient> ()
62 .AddAttribute (
"RemoteAddress",
63 "The destination Address of the outbound packets",
66 MakeAddressChecker ())
67 .AddAttribute (
"RemotePort",
68 "The destination port of the outbound packets",
71 MakeUintegerChecker<uint16_t> ())
72 .AddAttribute (
"MaxPacketSize",
73 "The maximum size of a packet.",
76 MakeUintegerChecker<uint32_t> ())
77 .AddAttribute (
"TraceFilename",
78 "Name of file to load a trace from. By default, uses a hardcoded trace.",
107 if (traceFile != NULL)
186 uint32_t time, index, prevTime = 0;
190 std::ifstream ifTraceFile;
191 ifTraceFile.open (filename.c_str (), std::ifstream::in);
193 if (!ifTraceFile.good ())
197 while (ifTraceFile.good ())
199 ifTraceFile >> index >> frameType >> time >> size;
200 if (frameType ==
'B')
213 ifTraceFile.close ();
221 uint32_t prevTime = 0;
279 packetSize = size - 12;
285 p = Create<Packet> (packetSize);
290 std::stringstream addressString;
308 << addressString.str ());
312 NS_LOG_INFO (
"Error while sending " << size <<
" bytes to "
313 << addressString.str ());
static bool IsMatchingType(const Address &address)
If the Address matches the type.
void LoadDefaultTrace(void)
#define NS_LOG_FUNCTION(parameters)
virtual int Bind6()=0
Allocate a local IPv6 endpoint for this socket.
hold variables of type string
#define NS_ASSERT(condition)
virtual void StartApplication(void)
Application specific startup code.
static void Cancel(const EventId &id)
Callback< R > MakeNullCallback(void)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
virtual void StopApplication(void)
Application specific shutdown code.
UdpTraceClient()
creates a traceBasedStreamer application
void SetTraceFile(std::string filename)
set the trace file to be used by the application
a polymophic address class
The base class for all ns3 applications.
Hold an unsigned integer type.
uint16_t GetMaxPacketSize(void)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
static struct TraceEntry g_defaultEntries[]
Ptr< Node > GetNode() const
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)
std::vector< struct TraceEntry > m_entries
static bool IsMatchingType(const Address &address)
static TypeId GetTypeId(void)
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void DoDispose(void)
void LoadTrace(std::string filename)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetMaxPacketSize(uint16_t maxPacketSize)
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
hold objects of type ns3::Address
NS_LOG_COMPONENT_DEFINE("PacketLossCounter")
an identifier for simulation events.
void SetRemote(Address ip, uint16_t port)
set the destination IP address and port
static Ipv4Address ConvertFrom(const Address &address)
virtual void DoDispose(void)
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
void SendPacket(uint32_t size)
bool IsExpired(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)
static TypeId LookupByName(std::string name)
static Ipv6Address ConvertFrom(const Address &address)
Convert the Address object into an Ipv6Address ones.