1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3
* Copyright 2007 University of Washington
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;
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.
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
19
#ifndef UDP_ECHO_CLIENT_H
20
#define UDP_ECHO_CLIENT_H
22
#include "ns3/application.h"
23
#include "ns3/event-id.h"
25
#include "ns3/ipv4-address.h"
26
#include "ns3/traced-callback.h"
35
* \brief A Udp Echo client
37
* Every packet sent should be returned by the server and received here.
39
class UdpEchoClient : public Application
42
static TypeId GetTypeId (void);
46
virtual ~UdpEchoClient ();
49
* \param ip destination ipv4 address
50
* \param port destination port
52
void SetRemote (Ipv4Address ip, uint16_t port);
55
* Set the data size of the packet (the number of bytes that are sent as data
56
* to the server). The contents of the data are set to unspecified (don't
59
* \warning If you have set the fill data for the echo client using one of the
60
* SetFill calls, this will undo those effects.
62
* \param dataSize The size of the echo data you want to sent.
64
void SetDataSize (uint32_t dataSize);
67
* Get the number of data bytes that will be sent to the server.
69
* \warning The number of bytes may be modified by calling any one of the
70
* SetFill methods. If you have called SetFill, then the number of
71
* data bytes will correspond to the size of an initialized data buffer.
72
* If you have not called a SetFill method, the number of data bytes will
73
* correspond to the number of don't care bytes that will be sent.
75
* \returns The number of data bytes.
77
uint32_t GetDataSize (void) const;
80
* Set the data fill of the packet (what is sent as data to the server) to
81
* the zero-terminated contents of the fill string string.
83
* \warning The size of resulting echo packets will be automatically adjusted
84
* to reflect the size of the fill string -- this means that the PacketSize
85
* attribute may be changed as a result of this call.
87
* \param fill The string to use as the actual echo data bytes.
89
void SetFill (std::string fill);
92
* Set the data fill of the packet (what is sent as data to the server) to
93
* the repeated contents of the fill byte. i.e., the fill byte will be
94
* used to initialize the contents of the data packet.
96
* \warning The size of resulting echo packets will be automatically adjusted
97
* to reflect the dataSize parameter -- this means that the PacketSize
98
* attribute may be changed as a result of this call.
100
* \param fill The byte to be repeated in constructing the packet data..
101
* \param dataSize The desired size of the resulting echo packet data.
103
void SetFill (uint8_t fill, uint32_t dataSize);
106
* Set the data fill of the packet (what is sent as data to the server) to
107
* the contents of the fill buffer, repeated as many times as is required.
109
* Initializing the packet to the contents of a provided single buffer is
110
* accomplished by setting the fillSize set to your desired dataSize
111
* (and providing an appropriate buffer).
113
* \warning The size of resulting echo packets will be automatically adjusted
114
* to reflect the dataSize parameter -- this means that the PacketSize
115
* attribute of the Application may be changed as a result of this call.
117
* \param fill The fill pattern to use when constructing packets.
118
* \param fillSize The number of bytes in the provided fill pattern.
119
* \param dataSize The desired size of the final echo data.
121
void SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize);
124
virtual void DoDispose (void);
128
virtual void StartApplication (void);
129
virtual void StopApplication (void);
131
void ScheduleTransmit (Time dt);
134
void HandleRead (Ptr<Socket> socket);
144
Ptr<Socket> m_socket;
145
Ipv4Address m_peerAddress;
148
/// Callbacks for tracing the packet Tx events
149
TracedCallback<Ptr<const Packet> > m_txTrace;
154
#endif /* UDP_ECHO_CLIENT_H */