A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
udp-trace-client.h
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 
53 class UdpTraceClient : public Application
54 {
55 public:
56  static TypeId
57  GetTypeId (void);
61  UdpTraceClient ();
62 
75  UdpTraceClient (Ipv4Address ip, uint16_t port, char *traceFile);
76  ~UdpTraceClient ();
77 
83  void SetRemote (Address ip, uint16_t port);
84  void SetRemote (Ipv4Address ip, uint16_t port);
85  void SetRemote (Ipv6Address ip, uint16_t port);
86 
94  void SetTraceFile (std::string filename);
95 
99  uint16_t GetMaxPacketSize (void);
100 
104  void SetMaxPacketSize (uint16_t maxPacketSize);
105 
106 protected:
107  virtual void DoDispose (void);
108 
109 private:
110  void LoadTrace (std::string filename);
111  void LoadDefaultTrace (void);
112  virtual void StartApplication (void);
113  virtual void StopApplication (void);
114  void ScheduleTransmit (Time dt);
115  void Send (void);
116  void SendPacket (uint32_t size);
117 
118 
119  struct TraceEntry
120  {
121  uint32_t timeToSend;
122  uint16_t packetSize;
123  char frameType;
124  };
125  uint32_t m_sent;
126  Ptr<Socket> m_socket;
127  Address m_peerAddress;
128  uint16_t m_peerPort;
129  EventId m_sendEvent;
130  std::vector<struct TraceEntry> m_entries;
131  uint32_t m_currentEntry;
132  static struct TraceEntry g_defaultEntries[];
133  uint16_t m_maxPacketSize;
134 };
135 
136 } // namespace ns3
137 
138 #endif /* UDP_TRACE_CLIENT_H */
virtual void StartApplication(void)
Application specific startup code.
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
Definition: address.h:86
uint16_t GetMaxPacketSize(void)
void SetMaxPacketSize(uint16_t maxPacketSize)
an identifier for simulation events.
Definition: event-id.h:46
void SetRemote(Address ip, uint16_t port)
set the destination IP address and port
virtual void DoDispose(void)