A Discrete-Event Network Simulator
API
three-gpp-http-helper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 INRIA
3  * Copyright (c) 2013 Magister Solutions
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  * Original work author (from packet-sink-helper.cc):
19  * - Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  *
21  * Converted to 3GPP HTTP web browsing traffic models by:
22  * - Budiarto Herman <budiarto.herman@magister.fi>
23  *
24  */
25 
26 #include "three-gpp-http-helper.h"
27 
28 #include <ns3/names.h>
29 
30 namespace ns3
31 {
32 
33 // 3GPP HTTP CLIENT HELPER /////////////////////////////////////////////////////////
34 
36 {
37  m_factory.SetTypeId("ns3::ThreeGppHttpClient");
38  m_factory.Set("RemoteServerAddress", AddressValue(address));
39 }
40 
41 void
42 ThreeGppHttpClientHelper::SetAttribute(const std::string& name, const AttributeValue& value)
43 {
44  m_factory.Set(name, value);
45 }
46 
49 {
50  return ApplicationContainer(InstallPriv(node));
51 }
52 
54 ThreeGppHttpClientHelper::Install(const std::string& nodeName) const
55 {
56  Ptr<Node> node = Names::Find<Node>(nodeName);
57  return ApplicationContainer(InstallPriv(node));
58 }
59 
62 {
64  for (auto i = c.Begin(); i != c.End(); ++i)
65  {
66  apps.Add(InstallPriv(*i));
67  }
68 
69  return apps;
70 }
71 
74 {
76  node->AddApplication(app);
77 
78  return app;
79 }
80 
81 // HTTP SERVER HELPER /////////////////////////////////////////////////////////
82 
84 {
85  m_factory.SetTypeId("ns3::ThreeGppHttpServer");
86  m_factory.Set("LocalAddress", AddressValue(address));
87 }
88 
89 void
90 ThreeGppHttpServerHelper::SetAttribute(const std::string& name, const AttributeValue& value)
91 {
92  m_factory.Set(name, value);
93 }
94 
97 {
98  return ApplicationContainer(InstallPriv(node));
99 }
100 
102 ThreeGppHttpServerHelper::Install(const std::string& nodeName) const
103 {
104  Ptr<Node> node = Names::Find<Node>(nodeName);
105  return ApplicationContainer(InstallPriv(node));
106 }
107 
110 {
112  for (auto i = c.Begin(); i != c.End(); ++i)
113  {
114  apps.Add(InstallPriv(*i));
115  }
116 
117  return apps;
118 }
119 
122 {
124  node->AddApplication(app);
125 
126  return app;
127 }
128 
129 } // namespace ns3
a polymophic address class
Definition: address.h:101
holds a vector of ns3::Application pointers.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
The base class for all ns3 applications.
Definition: application.h:62
Hold a value for an Attribute.
Definition: attribute.h:70
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:169
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
ThreeGppHttpClientHelper(const Address &address)
Create a ThreeGppHttpClientHelper to make it easier to work with ThreeGppHttpClient applications.
ApplicationContainer Install(NodeContainer c) const
Install a ThreeGppHttpClient on each node of the input container configured with all the attributes s...
ObjectFactory m_factory
Used to instantiate an ThreeGppHttpClient instance.
Ptr< Application > InstallPriv(Ptr< Node > node) const
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes, but not the socket attributes.
ThreeGppHttpServerHelper(const Address &address)
Create a ThreeGppHttpServerHelper to make it easier to work with ThreeGppHttpServer applications.
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes, but not the socket attributes.
ObjectFactory m_factory
Used to instantiate a ThreeGppHttpServer instance.
ApplicationContainer Install(NodeContainer c) const
Install an ThreeGppHttpServer on each node of the input container configured with all the attributes ...
Ptr< Application > InstallPriv(Ptr< Node > node) const
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.