~ubuntu-branches/ubuntu/quantal/ns3/quantal

« back to all changes in this revision

Viewing changes to ns-3.12.1/src/applications/model/udp-echo-client.h

  • Committer: Package Import Robot
  • Author(s): YunQiang Su, Aron Xu, YunQiang Su, Upstream
  • Date: 2012-01-06 00:35:42 UTC
  • mfrom: (10.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20120106003542-vcn5g03mhapm991h
Tags: 3.13+dfsg-1
[ Aron Xu ]:
        add tag binary and binary-indep, 
  for not build doc when --binary-arch (Closes: #654493).
[ YunQiang Su ]
        add waf 1.5/1.6 source to debian directory, 
  and build waf from there (Closes: #642217).
[ Upstream ]
  Successfully link with --as-needed option (Closes: #642225).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
33
 
/**
34
 
 * \ingroup udpecho
35
 
 * \brief A Udp Echo client
36
 
 *
37
 
 * Every packet sent should be returned by the server and received here.
38
 
 */
39
 
class UdpEchoClient : public Application 
40
 
{
41
 
public:
42
 
  static TypeId GetTypeId (void);
43
 
 
44
 
  UdpEchoClient ();
45
 
 
46
 
  virtual ~UdpEchoClient ();
47
 
 
48
 
  /**
49
 
   * \param ip destination ipv4 address
50
 
   * \param port destination port
51
 
   */
52
 
  void SetRemote (Ipv4Address ip, uint16_t port);
53
 
 
54
 
  /**
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
57
 
   * care) by this call.
58
 
   *
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.
61
 
   *
62
 
   * \param dataSize The size of the echo data you want to sent.
63
 
   */
64
 
  void SetDataSize (uint32_t dataSize);
65
 
 
66
 
  /**
67
 
   * Get the number of data bytes that will be sent to the server.
68
 
   *
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.
74
 
   *
75
 
   * \returns The number of data bytes.
76
 
   */
77
 
  uint32_t GetDataSize (void) const;
78
 
 
79
 
  /**
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.
82
 
   *
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.
86
 
   *
87
 
   * \param fill The string to use as the actual echo data bytes.
88
 
   */
89
 
  void SetFill (std::string fill);
90
 
 
91
 
  /**
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.
95
 
   * 
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.
99
 
   *
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.
102
 
   */
103
 
  void SetFill (uint8_t fill, uint32_t dataSize);
104
 
 
105
 
  /**
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.
108
 
   *
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).
112
 
   *
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.
116
 
   *
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.
120
 
   */
121
 
  void SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize);
122
 
 
123
 
protected:
124
 
  virtual void DoDispose (void);
125
 
 
126
 
private:
127
 
 
128
 
  virtual void StartApplication (void);
129
 
  virtual void StopApplication (void);
130
 
 
131
 
  void ScheduleTransmit (Time dt);
132
 
  void Send (void);
133
 
 
134
 
  void HandleRead (Ptr<Socket> socket);
135
 
 
136
 
  uint32_t m_count;
137
 
  Time m_interval;
138
 
  uint32_t m_size;
139
 
 
140
 
  uint32_t m_dataSize;
141
 
  uint8_t *m_data;
142
 
 
143
 
  uint32_t m_sent;
144
 
  Ptr<Socket> m_socket;
145
 
  Ipv4Address m_peerAddress;
146
 
  uint16_t m_peerPort;
147
 
  EventId m_sendEvent;
148
 
  /// Callbacks for tracing the packet Tx events
149
 
  TracedCallback<Ptr<const Packet> > m_txTrace;
150
 
};
151
 
 
152
 
} // namespace ns3
153
 
 
154
 
#endif /* UDP_ECHO_CLIENT_H */