satellite-on-off-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions Ltd
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: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
22 
23 #include "ns3/string.h"
24 #include "ns3/uinteger.h"
25 
26 #include <string>
27 
28 namespace ns3
29 {
30 
31 SatOnOffHelper::SatOnOffHelper(std::string protocol, Address address)
32 {
33  m_factory.SetTypeId("ns3::SatOnOffApplication");
34  m_factory.Set("Protocol", StringValue(protocol));
35  m_factory.Set("Remote", AddressValue(address));
36 }
37 
38 void
39 SatOnOffHelper::SetAttribute(std::string name, const AttributeValue& value)
40 {
41  m_factory.Set(name, value);
42 }
43 
44 ApplicationContainer
45 SatOnOffHelper::Install(Ptr<Node> node) const
46 {
47  return ApplicationContainer(InstallPriv(node));
48 }
49 
50 ApplicationContainer
51 SatOnOffHelper::Install(NodeContainer c) const
52 {
53  ApplicationContainer apps;
54  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
55  {
56  apps.Add(InstallPriv(*i));
57  }
58 
59  return apps;
60 }
61 
62 Ptr<Application>
63 SatOnOffHelper::InstallPriv(Ptr<Node> node) const
64 {
65  Ptr<Application> app = m_factory.Create<Application>();
66  node->AddApplication(app);
67 
68  return app;
69 }
70 
71 void
72 SatOnOffHelper::SetConstantRate(DataRate dataRate, uint32_t packetSize)
73 {
74  m_factory.Set("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1000]"));
75  m_factory.Set("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
76  m_factory.Set("DataRate", DataRateValue(dataRate));
77  m_factory.Set("PacketSize", UintegerValue(packetSize));
78 }
79 
80 } // namespace ns3
ApplicationContainer Install(NodeContainer c) const
Install an ns3::SatOnOffApplication on each node of the input container configured with all the attri...
SatOnOffHelper(std::string protocol, Address address)
Create an SatOnOffHelper to make it easier to work with SatOnOffApplications.
ObjectFactory m_factory
Object factory.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
Ptr< Application > InstallPriv(Ptr< Node > node) const
Install an ns3::SatOnOffApplication on the node configured with all the attributes set with SetAttrib...
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.