A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udp-echo-client.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2007 University of Washington
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 
19 #ifndef UDP_ECHO_CLIENT_H
20 #define UDP_ECHO_CLIENT_H
21 
22 #include "ns3/application.h"
23 #include "ns3/event-id.h"
24 #include "ns3/ptr.h"
25 #include "ns3/ipv4-address.h"
26 #include "ns3/traced-callback.h"
27 
28 namespace ns3 {
29 
30 class Socket;
31 class Packet;
32 
39 class UdpEchoClient : public Application
40 {
41 public:
46  static TypeId GetTypeId (void);
47 
48  UdpEchoClient ();
49 
50  virtual ~UdpEchoClient ();
51 
57  void SetRemote (Ipv4Address ip, uint16_t port);
63  void SetRemote (Ipv6Address ip, uint16_t port);
69  void SetRemote (Address ip, uint16_t port);
70 
81  void SetDataSize (uint32_t dataSize);
82 
94  uint32_t GetDataSize (void) const;
95 
106  void SetFill (std::string fill);
107 
120  void SetFill (uint8_t fill, uint32_t dataSize);
121 
138  void SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize);
139 
140 protected:
141  virtual void DoDispose (void);
142 
143 private:
144 
145  virtual void StartApplication (void);
146  virtual void StopApplication (void);
147 
152  void ScheduleTransmit (Time dt);
156  void Send (void);
157 
165  void HandleRead (Ptr<Socket> socket);
166 
167  uint32_t m_count;
169  uint32_t m_size;
170 
171  uint32_t m_dataSize;
172  uint8_t *m_data;
173 
174  uint32_t m_sent;
177  uint16_t m_peerPort;
179 
182 };
183 
184 } // namespace ns3
185 
186 #endif /* UDP_ECHO_CLIENT_H */
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
TracedCallback< Ptr< const Packet > > m_txTrace
Callbacks for tracing the packet Tx events.
uint32_t m_dataSize
packet payload size (must be equal to m_size)
Ptr< Socket > m_socket
Socket.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
virtual void StopApplication(void)
Application specific shutdown code.
void SetRemote(Ipv4Address ip, uint16_t port)
set the remote address and port
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:86
void ScheduleTransmit(Time dt)
Schedule the next packet transmission.
The base class for all ns3 applications.
Definition: application.h:61
uint8_t * m_data
packet payload data
A Udp Echo client.
virtual void StartApplication(void)
Application specific startup code.
uint32_t m_count
Maximum number of packets the application will send.
static TypeId GetTypeId(void)
Get the type ID.
Time m_interval
Packet inter-send time.
void SetDataSize(uint32_t dataSize)
Set the data size of the packet (the number of bytes that are sent as data to the server)...
void Send(void)
Send a packet.
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
EventId m_sendEvent
Event to send the next packet.
an identifier for simulation events.
Definition: event-id.h:46
uint32_t GetDataSize(void) const
Get the number of data bytes that will be sent to the server.
Address m_peerAddress
Remote peer address.
uint32_t m_sent
Counter for sent packets.
uint32_t m_size
Size of the sent packet.
a unique identifier for an interface.
Definition: type-id.h:49
uint16_t m_peerPort
Remote peer port.
void SetFill(std::string fill)
Set the data fill of the packet (what is sent as data to the server) to the zero-terminated contents ...