A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udp-client.h
Go to the documentation of this file.
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: Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@udcast.com>
20  *
21  */
22 
23 #ifndef UDP_CLIENT_H
24 #define UDP_CLIENT_H
25 
26 #include "ns3/application.h"
27 #include "ns3/event-id.h"
28 #include "ns3/ptr.h"
29 #include "ns3/ipv4-address.h"
30 
31 namespace ns3 {
32 
33 class Socket;
34 class Packet;
35 
43 class UdpClient : public Application
44 {
45 public:
50  static TypeId GetTypeId (void);
51 
52  UdpClient ();
53 
54  virtual ~UdpClient ();
55 
61  void SetRemote (Ipv4Address ip, uint16_t port);
67  void SetRemote (Ipv6Address ip, uint16_t port);
73  void SetRemote (Address ip, uint16_t port);
74 
75 protected:
76  virtual void DoDispose (void);
77 
78 private:
79 
80  virtual void StartApplication (void);
81  virtual void StopApplication (void);
82 
86  void Send (void);
87 
88  uint32_t m_count;
90  uint32_t m_size;
91 
92  uint32_t m_sent;
95  uint16_t m_peerPort;
97 
98 };
99 
100 } // namespace ns3
101 
102 #endif /* UDP_CLIENT_H */
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
uint32_t m_count
Maximum number of packets the application will send.
Definition: udp-client.h:88
virtual void StartApplication(void)
Application specific startup code.
Definition: udp-client.cc:121
Ptr< Socket > m_socket
Socket.
Definition: udp-client.h:93
virtual void StopApplication(void)
Application specific shutdown code.
Definition: udp-client.cc:146
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:86
uint32_t m_sent
Counter for sent packets.
Definition: udp-client.h:92
uint32_t m_size
Size of the sent packet (including the SeqTsHeader)
Definition: udp-client.h:90
The base class for all ns3 applications.
Definition: application.h:61
Time m_interval
Packet inter-send time.
Definition: udp-client.h:89
uint16_t m_peerPort
Remote peer port.
Definition: udp-client.h:95
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-client.cc:44
void Send(void)
Send a packet.
Definition: udp-client.cc:153
virtual ~UdpClient()
Definition: udp-client.cc:84
Address m_peerAddress
Remote peer address.
Definition: udp-client.h:94
A Udp client.
Definition: udp-client.h:43
Describes an IPv6 address.
Definition: ipv6-address.h:46
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
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: udp-client.cc:114
void SetRemote(Ipv4Address ip, uint16_t port)
set the remote address and port
Definition: udp-client.cc:90
a unique identifier for an interface.
Definition: type-id.h:49
EventId m_sendEvent
Event to send the next packet.
Definition: udp-client.h:96