author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sat, 04 Jul 2009 08:15:48 +0200 | |
changeset 4654 | 2eaebe77d66b |
parent 4577 | 84c133267507 |
permissions | -rw-r--r-- |
2833
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
2 |
/* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
3 |
* Copyright (c) 2008 INRIA |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
4 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
7 |
* published by the Free Software Foundation; |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
8 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
12 |
* GNU General Public License for more details. |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
13 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
17 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2767
diff
changeset
|
19 |
*/ |
2767
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#ifndef UDP_ECHO_HELPER_H |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#define UDP_ECHO_HELPER_H |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include <stdint.h> |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "application-container.h" |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "node-container.h" |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "ns3/object-factory.h" |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "ns3/ipv4-address.h" |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
|
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
namespace ns3 { |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
class UdpEchoServerHelper |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
{ |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
public: |
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
34 |
UdpEchoServerHelper (uint16_t port); |
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
35 |
|
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
36 |
void SetAttribute (std::string name, const AttributeValue &value); |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
37 |
|
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
38 |
ApplicationContainer Install (Ptr<Node> node) const; |
4140
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
39 |
ApplicationContainer Install (std::string nodeName) const; |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
40 |
ApplicationContainer Install (NodeContainer c) const; |
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
41 |
|
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
42 |
private: |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
43 |
Ptr<Application> InstallPriv (Ptr<Node> node) const; |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
44 |
|
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
45 |
ObjectFactory m_factory; |
2767
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
}; |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
|
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
class UdpEchoClientHelper |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
{ |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
public: |
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
51 |
UdpEchoClientHelper (Ipv4Address ip, uint16_t port); |
2767
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
|
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
53 |
void SetAttribute (std::string name, const AttributeValue &value); |
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
2965
diff
changeset
|
54 |
|
4577
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
55 |
/** |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
56 |
* Given a pointer to a UdpEchoClient application, set the data fill of the |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
57 |
* packet (what is sent as data to the server) to the contents of the fill |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
58 |
* string (including the trailing zero terminator). |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
59 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
60 |
* \warn The size of resulting echo packets will be automatically adjusted |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
61 |
* to reflect the size of the fill string -- this means that the PacketSize |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
62 |
* attribute may be changed as a result of this call. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
63 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
64 |
* \param app Smart pointer to the application (real type must be UdpEchoClient). |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
65 |
* \param fill The string to use as the actual echo data bytes. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
66 |
*/ |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
67 |
void SetFill (Ptr<Application> app, std::string fill); |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
68 |
|
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
69 |
/** |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
70 |
* Given a pointer to a UdpEchoClient application, set the data fill of the |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
71 |
* packet (what is sent as data to the server) to the contents of the fill |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
72 |
* byte. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
73 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
74 |
* The fill byte will be used to initialize the contents of the data packet. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
75 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
76 |
* \warn The size of resulting echo packets will be automatically adjusted |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
77 |
* to reflect the dataLength parameter -- this means that the PacketSize |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
78 |
* attribute may be changed as a result of this call. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
79 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
80 |
* \param app Smart pointer to the application (real type must be UdpEchoClient). |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
81 |
* \param fill The byte to be repeated in constructing the packet data.. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
82 |
* \param dataLength The desired length of the resulting echo packet data. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
83 |
*/ |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
84 |
void SetFill (Ptr<Application> app, uint8_t fill, uint32_t dataLength); |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
85 |
|
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
86 |
/** |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
87 |
* Given a pointer to a UdpEchoClient application, set the data fill of the |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
88 |
* packet (what is sent as data to the server) to the contents of the fill |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
89 |
* buffer, repeated as many times as is required. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
90 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
91 |
* Initializing the fill to the contents of a single buffer is accomplished |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
92 |
* by providing a complete buffer with fillLength set to your desired |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
93 |
* dataLength |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
94 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
95 |
* \warn The size of resulting echo packets will be automatically adjusted |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
96 |
* to reflect the dataLength parameter -- this means that the PacketSize |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
97 |
* attribute of the Application may be changed as a result of this call. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
98 |
* |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
99 |
* \param app Smart pointer to the application (real type must be UdpEchoClient). |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
100 |
* \param fill The fill pattern to use when constructing packets. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
101 |
* \param fillLength The number of bytes in the provided fill pattern. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
102 |
* \param dataLength The desired length of the final echo data. |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
103 |
*/ |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
104 |
void SetFill (Ptr<Application> app, uint8_t *fill, uint32_t fillLength, uint32_t dataLength); |
84c133267507
Allow UDP echo client to specify packet contents
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
105 |
|
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
106 |
ApplicationContainer Install (Ptr<Node> node) const; |
4140
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
107 |
ApplicationContainer Install (std::string nodeName) const; |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
108 |
ApplicationContainer Install (NodeContainer c) const; |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
109 |
|
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
110 |
private: |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3382
diff
changeset
|
111 |
Ptr<Application> InstallPriv (Ptr<Node> node) const; |
2767
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
112 |
ObjectFactory m_factory; |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
113 |
}; |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
|
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
} // namespace ns3 |
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
|
c934b4adb8d5
helper for UdpEcho client and server
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
117 |
#endif /* UDP_ECHO_HELPER_H */ |