A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
udp-echo-client.h
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:
42  static TypeId GetTypeId (void);
43 
44  UdpEchoClient ();
45 
46  virtual ~UdpEchoClient ();
47 
52  void SetRemote (Address ip, uint16_t port);
53  void SetRemote (Ipv4Address ip, uint16_t port);
54  void SetRemote (Ipv6Address ip, uint16_t port);
55 
66  void SetDataSize (uint32_t dataSize);
67 
79  uint32_t GetDataSize (void) const;
80 
91  void SetFill (std::string fill);
92 
105  void SetFill (uint8_t fill, uint32_t dataSize);
106 
123  void SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize);
124 
125 protected:
126  virtual void DoDispose (void);
127 
128 private:
129 
130  virtual void StartApplication (void);
131  virtual void StopApplication (void);
132 
133  void ScheduleTransmit (Time dt);
134  void Send (void);
135 
136  void HandleRead (Ptr<Socket> socket);
137 
138  uint32_t m_count;
139  Time m_interval;
140  uint32_t m_size;
141 
142  uint32_t m_dataSize;
143  uint8_t *m_data;
144 
145  uint32_t m_sent;
146  Ptr<Socket> m_socket;
147  Address m_peerAddress;
148  uint16_t m_peerPort;
149  EventId m_sendEvent;
152 };
153 
154 } // namespace ns3
155 
156 #endif /* UDP_ECHO_CLIENT_H */
keep track of time unit.
Definition: nstime.h:149
TracedCallback< Ptr< const Packet > > m_txTrace
Callbacks for tracing the packet Tx events.
virtual void DoDispose(void)
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
void SetRemote(Address ip, uint16_t port)
virtual void StopApplication(void)
Application specific shutdown code.
a polymophic address class
Definition: address.h:86
The base class for all ns3 applications.
Definition: application.h:61
A Udp Echo client.
virtual void StartApplication(void)
Application specific startup code.
void SetDataSize(uint32_t dataSize)
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
an identifier for simulation events.
Definition: event-id.h:46
uint32_t GetDataSize(void) const
a unique identifier for an interface.
Definition: type-id.h:44
void SetFill(std::string fill)