A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udp-client-server-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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  */
21 #include "ns3/udp-server.h"
22 #include "ns3/udp-client.h"
23 #include "ns3/udp-trace-client.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/string.h"
26 
27 namespace ns3 {
28 
30 {
31 }
32 
34 {
36  SetAttribute ("Port", UintegerValue (port));
37 }
38 
39 void
40 UdpServerHelper::SetAttribute (std::string name, const AttributeValue &value)
41 {
42  m_factory.Set (name, value);
43 }
44 
47 {
49  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
50  {
51  Ptr<Node> node = *i;
52 
54  node->AddApplication (m_server);
55  apps.Add (m_server);
56 
57  }
58  return apps;
59 }
60 
63 {
64  return m_server;
65 }
66 
68 {
69 }
70 
72 {
74  SetAttribute ("RemoteAddress", AddressValue (address));
75  SetAttribute ("RemotePort", UintegerValue (port));
76 }
77 
79 {
81  SetAttribute ("RemoteAddress", AddressValue (Address(address)));
82  SetAttribute ("RemotePort", UintegerValue (port));
83 }
84 
86 {
88  SetAttribute ("RemoteAddress", AddressValue (Address(address)));
89  SetAttribute ("RemotePort", UintegerValue (port));
90 }
91 
92 void
93 UdpClientHelper::SetAttribute (std::string name, const AttributeValue &value)
94 {
95  m_factory.Set (name, value);
96 }
97 
100 {
102  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
103  {
104  Ptr<Node> node = *i;
106  node->AddApplication (client);
107  apps.Add (client);
108  }
109  return apps;
110 }
111 
113 {
114 }
115 
117 {
119  SetAttribute ("RemoteAddress", AddressValue (address));
120  SetAttribute ("RemotePort", UintegerValue (port));
121  SetAttribute ("TraceFilename", StringValue (filename));
122 }
123 
125 {
127  SetAttribute ("RemoteAddress", AddressValue (Address (address)));
128  SetAttribute ("RemotePort", UintegerValue (port));
129  SetAttribute ("TraceFilename", StringValue (filename));
130 }
131 
133 {
135  SetAttribute ("RemoteAddress", AddressValue (Address (address)));
136  SetAttribute ("RemotePort", UintegerValue (port));
137  SetAttribute ("TraceFilename", StringValue (filename));
138 }
139 
140 void
141 UdpTraceClientHelper::SetAttribute (std::string name, const AttributeValue &value)
142 {
143  m_factory.Set (name, value);
144 }
145 
148 {
150  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
151  {
152  Ptr<Node> node = *i;
154  node->AddApplication (client);
155  apps.Add (client);
156  }
157  return apps;
158 }
159 
160 } // namespace ns3
holds a vector of ns3::Application pointers.
uint32_t AddApplication(Ptr< Application > application)
Definition: node.cc:146
std::vector< Ptr< Node > >::const_iterator Iterator
hold variables of type string
Definition: string.h:19
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
Hold a value for an Attribute.
Definition: attribute.h:56
void SetAttribute(std::string name, const AttributeValue &value)
void SetTypeId(TypeId tid)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
ApplicationContainer Install(NodeContainer c)
ApplicationContainer Install(NodeContainer c)
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:86
Ptr< Object > Create(void) const
Hold an unsigned integer type.
Definition: uinteger.h:46
Ptr< UdpServer > GetServer(void)
static TypeId GetTypeId(void)
Definition: udp-client.cc:42
static TypeId GetTypeId(void)
void SetAttribute(std::string name, const AttributeValue &value)
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
A Udp client. Sends UDP packet carrying sequence number and time stamp in their payloads.
Definition: udp-client.h:43
A trace based streamer.
static TypeId GetTypeId(void)
Definition: udp-server.cc:44
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
hold objects of type ns3::Address
ApplicationContainer Install(NodeContainer c)
void SetAttribute(std::string name, const AttributeValue &value)
tuple address
Definition: first.py:37
A Udp server. Receives UDP packets from a remote host. UDP packets carry a 32bits sequence number fol...
Definition: udp-server.h:45