A Discrete-Event Network Simulator
API
udp-trace-client.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18  * <amine.ismail@udcast.com>
19  */
20 
21 #ifndef UDP_TRACE_CLIENT_H
22 #define UDP_TRACE_CLIENT_H
23 
24 #include "ns3/application.h"
25 #include "ns3/event-id.h"
26 #include "ns3/ipv4-address.h"
27 #include "ns3/ptr.h"
28 
29 #include <vector>
30 
31 namespace ns3
32 {
33 
34 class Socket;
35 class Packet;
36 
60 class UdpTraceClient : public Application
61 {
62  public:
67  static TypeId GetTypeId();
68 
70 
82  UdpTraceClient(Ipv4Address ip, uint16_t port, char* traceFile);
83  ~UdpTraceClient() override;
84 
90  void SetRemote(Address ip, uint16_t port);
95  void SetRemote(Address addr);
96 
104  void SetTraceFile(std::string filename);
105 
110  uint16_t GetMaxPacketSize();
111 
116  void SetMaxPacketSize(uint16_t maxPacketSize);
117 
122  void SetTraceLoop(bool traceLoop);
123 
124  protected:
125  void DoDispose() override;
126 
127  private:
132  void LoadTrace(std::string filename);
136  void LoadDefaultTrace();
137  void StartApplication() override;
138  void StopApplication() override;
139 
143  void Send();
148  void SendPacket(uint32_t size);
149 
155  struct TraceEntry
156  {
157  uint32_t timeToSend;
158  uint32_t packetSize;
159  char frameType;
160  };
161 
162  uint32_t m_sent;
165  uint16_t m_peerPort;
167 
168  std::vector<TraceEntry> m_entries;
169  uint32_t m_currentEntry;
171  uint16_t m_maxPacketSize;
172  bool m_traceLoop;
173 };
174 
175 } // namespace ns3
176 
177 #endif /* UDP_TRACE_CLIENT_H */
a polymophic address class
Definition: address.h:100
An identifier for simulation events.
Definition: event-id.h:55
uint16_t port
Definition: dsdv-manet.cc:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Entry to send.
uint32_t timeToSend
Time to send the frame.
uint32_t packetSize
Size of the frame.
char frameType
Frame type (I, P or B)
EventId m_sendEvent
Event to send the next packet.
void StopApplication() override
Application specific shutdown code.
static TypeId GetTypeId()
Get the type ID.
void Send()
Send a packet.
uint16_t m_peerPort
Remote peer port.
void SetTraceLoop(bool traceLoop)
Set the trace loop flag.
uint32_t m_sent
Counter for sent packets.
void SetRemote(Address ip, uint16_t port)
set the remote address and port
Address m_peerAddress
Remote peer address.
std::vector< TraceEntry > m_entries
Entries in the trace to send.
uint32_t m_currentEntry
Current entry index.
void SetTraceFile(std::string filename)
Set the trace file to be used by the application.
void LoadTrace(std::string filename)
Load a trace file.
void SetMaxPacketSize(uint16_t maxPacketSize)
Set the maximum packet size.
void StartApplication() override
Application specific startup code.
void DoDispose() override
Destructor implementation.
void SendPacket(uint32_t size)
Send a packet of a given size.
bool m_traceLoop
Loop through the trace file.
uint16_t m_maxPacketSize
Maximum packet size to send (including the SeqTsHeader)
uint16_t GetMaxPacketSize()
Return the maximum packet size.
void LoadDefaultTrace()
Load the default trace.
Ptr< Socket > m_socket
Socket.