A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udp-echo-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "udp-echo-helper.h"
21 #include "ns3/udp-echo-server.h"
22 #include "ns3/udp-echo-client.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/names.h"
25 
26 namespace ns3 {
27 
29 {
31  SetAttribute ("Port", UintegerValue (port));
32 }
33 
34 void
36  std::string name,
37  const AttributeValue &value)
38 {
39  m_factory.Set (name, value);
40 }
41 
44 {
45  return ApplicationContainer (InstallPriv (node));
46 }
47 
49 UdpEchoServerHelper::Install (std::string nodeName) const
50 {
51  Ptr<Node> node = Names::Find<Node> (nodeName);
52  return ApplicationContainer (InstallPriv (node));
53 }
54 
57 {
59  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
60  {
61  apps.Add (InstallPriv (*i));
62  }
63 
64  return apps;
65 }
66 
69 {
71  node->AddApplication (app);
72 
73  return app;
74 }
75 
77 {
79  SetAttribute ("RemoteAddress", AddressValue (address));
80  SetAttribute ("RemotePort", UintegerValue (port));
81 }
82 
84 {
86  SetAttribute ("RemoteAddress", AddressValue (Address(address)));
87  SetAttribute ("RemotePort", UintegerValue (port));
88 }
89 
91 {
93  SetAttribute ("RemoteAddress", AddressValue (Address(address)));
94  SetAttribute ("RemotePort", UintegerValue (port));
95 }
96 
97 void
99  std::string name,
100  const AttributeValue &value)
101 {
102  m_factory.Set (name, value);
103 }
104 
105 void
107 {
108  app->GetObject<UdpEchoClient>()->SetFill (fill);
109 }
110 
111 void
112 UdpEchoClientHelper::SetFill (Ptr<Application> app, uint8_t fill, uint32_t dataLength)
113 {
114  app->GetObject<UdpEchoClient>()->SetFill (fill, dataLength);
115 }
116 
117 void
118 UdpEchoClientHelper::SetFill (Ptr<Application> app, uint8_t *fill, uint32_t fillLength, uint32_t dataLength)
119 {
120  app->GetObject<UdpEchoClient>()->SetFill (fill, fillLength, dataLength);
121 }
122 
125 {
126  return ApplicationContainer (InstallPriv (node));
127 }
128 
130 UdpEchoClientHelper::Install (std::string nodeName) const
131 {
132  Ptr<Node> node = Names::Find<Node> (nodeName);
133  return ApplicationContainer (InstallPriv (node));
134 }
135 
138 {
140  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
141  {
142  apps.Add (InstallPriv (*i));
143  }
144 
145  return apps;
146 }
147 
150 {
152  node->AddApplication (app);
153 
154  return app;
155 }
156 
157 } // namespace ns3