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:
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;
140  uint32_t m_size;
141 
142  uint32_t m_dataSize;
143  uint8_t *m_data;
144 
145  uint32_t m_sent;
148  uint16_t m_peerPort;
152 };
153 
154 } // namespace ns3
155 
156 #endif /* UDP_ECHO_CLIENT_H */