A Discrete-Event Network Simulator
API
three-gpp-http-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  * Copyright (c) 2013 Magister Solutions
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Original work author (from packet-sink-helper.cc):
20  * - Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
21  *
22  * Converted to 3GPP HTTP web browsing traffic models by:
23  * - Budiarto Herman <budiarto.herman@magister.fi>
24  *
25  */
26 
27 #include <ns3/names.h>
28 #include "three-gpp-http-helper.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,
43  const AttributeValue &value)
44 {
45  m_factory.Set (name, value);
46 }
47 
50 {
51  return ApplicationContainer (InstallPriv (node));
52 }
53 
55 ThreeGppHttpClientHelper::Install (const std::string &nodeName) const
56 {
57  Ptr<Node> node = Names::Find<Node> (nodeName);
58  return ApplicationContainer (InstallPriv (node));
59 }
60 
63 {
65  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
66  {
67  apps.Add (InstallPriv (*i));
68  }
69 
70  return apps;
71 }
72 
75 {
77  node->AddApplication (app);
78 
79  return app;
80 }
81 
82 
83 // HTTP SERVER HELPER /////////////////////////////////////////////////////////
84 
86 {
87  m_factory.SetTypeId ("ns3::ThreeGppHttpServer");
88  m_factory.Set ("LocalAddress", AddressValue (address));
89 }
90 
91 void
92 ThreeGppHttpServerHelper::SetAttribute (const std::string &name,
93  const AttributeValue &value)
94 {
95  m_factory.Set (name, value);
96 }
97 
100 {
101  return ApplicationContainer (InstallPriv (node));
102 }
103 
105 ThreeGppHttpServerHelper::Install (const std::string &nodeName) const
106 {
107  Ptr<Node> node = Names::Find<Node> (nodeName);
108  return ApplicationContainer (InstallPriv (node));
109 }
110 
113 {
115  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
116  {
117  apps.Add (InstallPriv (*i));
118  }
119 
120  return apps;
121 }
122 
125 {
127  node->AddApplication (app);
128 
129  return app;
130 }
131 
132 
133 } // end of `namespace ns3`
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes, but not the socket attributes...
holds a vector of ns3::Application pointers.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:157
ApplicationContainer Install(NodeContainer c) const
Install an ThreeGppHttpServer on each node of the input container configured with all the attributes ...
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Ptr< Application > InstallPriv(Ptr< Node > node) const
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:68
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
ObjectFactory m_factory
Used to instantiate an ThreeGppHttpClient instance.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
a polymophic address class
Definition: address.h:90
Ptr< Application > InstallPriv(Ptr< Node > node) const
ObjectFactory m_factory
Used to instantiate a ThreeGppHttpServer instance.
ApplicationContainer Install(NodeContainer c) const
Install a ThreeGppHttpClient on each node of the input container configured with all the attributes s...
The base class for all ns3 applications.
Definition: application.h:60
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
ThreeGppHttpClientHelper(const Address &address)
Create a ThreeGppHttpClientHelper to make it easier to work with ThreeGppHttpClient applications...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
address
Definition: first.py:37
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes, but not the socket attributes...
AttributeValue implementation for Address.
Definition: address.h:278
ThreeGppHttpServerHelper(const Address &address)
Create a ThreeGppHttpServerHelper to make it easier to work with ThreeGppHttpServer applications...
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.