A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udp-trace-client.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008, 2009 INRIA, UDcast
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@udcast.com>
20  */
21 
22 #ifndef UDP_TRACE_CLIENT_H
23 #define UDP_TRACE_CLIENT_H
24 
25 #include "ns3/application.h"
26 #include "ns3/event-id.h"
27 #include "ns3/ptr.h"
28 #include "ns3/ipv4-address.h"
29 #include <vector>
30 
31 namespace ns3 {
32 
33 class Socket;
34 class Packet;
35 
54 class UdpTraceClient : public Application
55 {
56 public:
61  static TypeId GetTypeId (void);
62 
63  UdpTraceClient ();
64 
76  UdpTraceClient (Ipv4Address ip, uint16_t port, char *traceFile);
77  ~UdpTraceClient ();
78 
84  void SetRemote (Ipv4Address ip, uint16_t port);
90  void SetRemote (Ipv6Address ip, uint16_t port);
96  void SetRemote (Address ip, uint16_t port);
97 
105  void SetTraceFile (std::string filename);
106 
111  uint16_t GetMaxPacketSize (void);
112 
117  void SetMaxPacketSize (uint16_t maxPacketSize);
118 
119 protected:
120  virtual void DoDispose (void);
121 
122 private:
127  void LoadTrace (std::string filename);
131  void LoadDefaultTrace (void);
132  virtual void StartApplication (void);
133  virtual void StopApplication (void);
134 
138  void Send (void);
143  void SendPacket (uint32_t size);
144 
150  struct TraceEntry
151  {
152  uint32_t timeToSend;
153  uint16_t packetSize;
154  char frameType;
155  };
156 
157  uint32_t m_sent;
160  uint16_t m_peerPort;
162 
163  std::vector<struct TraceEntry> m_entries;
164  uint32_t m_currentEntry;
165  static struct TraceEntry g_defaultEntries[];
166  uint16_t m_maxPacketSize;
167 };
168 
169 } // namespace ns3
170 
171 #endif /* UDP_TRACE_CLIENT_H */
void LoadDefaultTrace(void)
Load the default trace.
virtual void StartApplication(void)
Application specific startup code.
Address m_peerAddress
Remote peer address.
virtual void StopApplication(void)
Application specific shutdown code.
void SetTraceFile(std::string filename)
Set the trace file to be used by the application.
EventId m_sendEvent
Event to send the next packet.
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:86
uint32_t timeToSend
Time to send the frame.
uint16_t packetSize
Size of the frame.
uint16_t GetMaxPacketSize(void)
Return the maximum packet size.
static struct TraceEntry g_defaultEntries[]
Default trace to send.
char frameType
Frame type (I, P or B)
std::vector< struct TraceEntry > m_entries
Entries in the trace to send.
static TypeId GetTypeId(void)
Get the type ID.
void LoadTrace(std::string filename)
Load a trace file.
uint32_t m_sent
Counter for sent packets.
Ptr< Socket > m_socket
Socket.
void SetMaxPacketSize(uint16_t maxPacketSize)
Set the maximum packet size.
void Send(void)
Send a packet.
Entry to send.
uint16_t m_maxPacketSize
Maximum packet size to send (including the SeqTsHeader)
an identifier for simulation events.
Definition: event-id.h:46
uint16_t m_peerPort
Remote peer port.
uint32_t m_currentEntry
Current entry index.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void SendPacket(uint32_t size)
Send a packet of a given size.
void SetRemote(Ipv4Address ip, uint16_t port)
set the remote address and port