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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 *
9 */
10
11#ifndef UDP_CLIENT_H
12#define UDP_CLIENT_H
13
14#include "ns3/application.h"
15#include "ns3/event-id.h"
16#include "ns3/ipv4-address.h"
17#include "ns3/ptr.h"
18#include <ns3/traced-callback.h>
19
20namespace ns3
21{
22
23class Socket;
24class Packet;
25
26/**
27 * \ingroup udpclientserver
28 *
29 * \brief A Udp client. Sends UDP packet carrying sequence number and time stamp
30 * in their payloads
31 *
32 */
33class UdpClient : public Application
34{
35 public:
36 /**
37 * \brief Get the type ID.
38 * \return the object TypeId
39 */
40 static TypeId GetTypeId();
41
42 UdpClient();
43
44 ~UdpClient() override;
45
46 /**
47 * \brief set the remote address and port
48 * \param ip remote IP address
49 * \param port remote port
50 */
51 void SetRemote(Address ip, uint16_t port);
52 /**
53 * \brief set the remote address
54 * \param addr remote address
55 */
56 void SetRemote(Address addr);
57
58 /**
59 * \return the total bytes sent by this app
60 */
61 uint64_t GetTotalTx() const;
62
63 private:
64 void StartApplication() override;
65 void StopApplication() override;
66
67 /**
68 * \brief Send a packet
69 */
70 void Send();
71
72 /// Traced Callback: transmitted packets.
74
75 /// Callbacks for tracing the packet Tx events, includes source and destination addresses
77
78 uint32_t m_count; //!< Maximum number of packets the application will send
79 Time m_interval; //!< Packet inter-send time
80 uint32_t m_size; //!< Size of the sent packet (including the SeqTsHeader)
81
82 uint32_t m_sent; //!< Counter for sent packets
83 uint64_t m_totalTx; //!< Total bytes sent
84 Ptr<Socket> m_socket; //!< Socket
85 Address m_peerAddress; //!< Remote peer address
86 uint16_t m_peerPort; //!< Remote peer port
87 uint8_t m_tos; //!< The packets Type of Service
88 EventId m_sendEvent; //!< Event to send the next packet
89
90#ifdef NS3_LOG_ENABLE
91 std::string m_peerAddressString; //!< Remote peer address string
92#endif // NS3_LOG_ENABLE
93};
94
95} // namespace ns3
96
97#endif /* UDP_CLIENT_H */
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
A Udp client.
Definition udp-client.h:34
Time m_interval
Packet inter-send time.
Definition udp-client.h:79
uint64_t GetTotalTx() const
uint64_t m_totalTx
Total bytes sent.
Definition udp-client.h:83
~UdpClient() override
Definition udp-client.cc:95
uint32_t m_sent
Counter for sent packets.
Definition udp-client.h:82
Ptr< Socket > m_socket
Socket.
Definition udp-client.h:84
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:76
uint16_t m_peerPort
Remote peer port.
Definition udp-client.h:86
void Send()
Send a packet.
static TypeId GetTypeId()
Get the type ID.
Definition udp-client.cc:35
EventId m_sendEvent
Event to send the next packet.
Definition udp-client.h:88
uint32_t m_size
Size of the sent packet (including the SeqTsHeader)
Definition udp-client.h:80
uint32_t m_count
Maximum number of packets the application will send.
Definition udp-client.h:78
void SetRemote(Address ip, uint16_t port)
set the remote address and port
Address m_peerAddress
Remote peer address.
Definition udp-client.h:85
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets.
Definition udp-client.h:73
uint8_t m_tos
The packets Type of Service.
Definition udp-client.h:87
void StartApplication() override
Application specific startup code.
void StopApplication() override
Application specific shutdown code.
std::string m_peerAddressString
Remote peer address string.
Definition udp-client.h:91
uint16_t port
Definition dsdv-manet.cc:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.