A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
udp-client.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008,2009 INRIA, UDCAST
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 *
20 */
21
22#ifndef UDP_CLIENT_H
23#define UDP_CLIENT_H
24
25#include "ns3/application.h"
26#include "ns3/event-id.h"
27#include "ns3/ipv4-address.h"
28#include "ns3/ptr.h"
29#include <ns3/traced-callback.h>
30
31namespace ns3
32{
33
34class Socket;
35class Packet;
36
37/**
38 * \ingroup udpclientserver
39 *
40 * \brief A Udp client. Sends UDP packet carrying sequence number and time stamp
41 * in their payloads
42 *
43 */
44class UdpClient : public Application
45{
46 public:
47 /**
48 * \brief Get the type ID.
49 * \return the object TypeId
50 */
51 static TypeId GetTypeId();
52
53 UdpClient();
54
55 ~UdpClient() override;
56
57 /**
58 * \brief set the remote address and port
59 * \param ip remote IP address
60 * \param port remote port
61 */
62 void SetRemote(Address ip, uint16_t port);
63 /**
64 * \brief set the remote address
65 * \param addr remote address
66 */
67 void SetRemote(Address addr);
68
69 /**
70 * \return the total bytes sent by this app
71 */
72 uint64_t GetTotalTx() const;
73
74 private:
75 void StartApplication() override;
76 void StopApplication() override;
77
78 /**
79 * \brief Send a packet
80 */
81 void Send();
82
83 /// Traced Callback: transmitted packets.
85
86 /// Callbacks for tracing the packet Tx events, includes source and destination addresses
88
89 uint32_t m_count; //!< Maximum number of packets the application will send
90 Time m_interval; //!< Packet inter-send time
91 uint32_t m_size; //!< Size of the sent packet (including the SeqTsHeader)
92
93 uint32_t m_sent; //!< Counter for sent packets
94 uint64_t m_totalTx; //!< Total bytes sent
95 Ptr<Socket> m_socket; //!< Socket
96 Address m_peerAddress; //!< Remote peer address
97 uint16_t m_peerPort; //!< Remote peer port
98 uint8_t m_tos; //!< The packets Type of Service
99 EventId m_sendEvent; //!< Event to send the next packet
100
101#ifdef NS3_LOG_ENABLE
102 std::string m_peerAddressString; //!< Remote peer address string
103#endif // NS3_LOG_ENABLE
104};
105
106} // namespace ns3
107
108#endif /* UDP_CLIENT_H */
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
An identifier for simulation events.
Definition: event-id.h:55
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
A Udp client.
Definition: udp-client.h:45
Time m_interval
Packet inter-send time.
Definition: udp-client.h:90
uint64_t GetTotalTx() const
Definition: udp-client.cc:254
uint64_t m_totalTx
Total bytes sent.
Definition: udp-client.h:94
~UdpClient() override
Definition: udp-client.cc:106
uint32_t m_sent
Counter for sent packets.
Definition: udp-client.h:93
Ptr< Socket > m_socket
Socket.
Definition: udp-client.h:95
TracedCallback< Ptr< const Packet >, const Address &, const Address & > m_txTraceWithAddresses
Callbacks for tracing the packet Tx events, includes source and destination addresses.
Definition: udp-client.h:87
uint16_t m_peerPort
Remote peer port.
Definition: udp-client.h:97
void Send()
Send a packet.
Definition: udp-client.cc:211
static TypeId GetTypeId()
Get the type ID.
Definition: udp-client.cc:46
EventId m_sendEvent
Event to send the next packet.
Definition: udp-client.h:99
uint32_t m_size
Size of the sent packet (including the SeqTsHeader)
Definition: udp-client.h:91
uint32_t m_count
Maximum number of packets the application will send.
Definition: udp-client.h:89
void SetRemote(Address ip, uint16_t port)
set the remote address and port
Definition: udp-client.cc:112
Address m_peerAddress
Remote peer address.
Definition: udp-client.h:96
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets.
Definition: udp-client.h:84
uint8_t m_tos
The packets Type of Service.
Definition: udp-client.h:98
void StartApplication() override
Application specific startup code.
Definition: udp-client.cc:127
void StopApplication() override
Application specific shutdown code.
Definition: udp-client.cc:204
std::string m_peerAddressString
Remote peer address string.
Definition: udp-client.h:102
uint16_t port
Definition: dsdv-manet.cc:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.