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 namespace ns3
27 {
28 
29 SatOnOffHelper::SatOnOffHelper(std::string protocol, Address address)
30 {
31  m_factory.SetTypeId("ns3::SatOnOffApplication");
32  m_factory.Set("Protocol", StringValue(protocol));
33  m_factory.Set("Remote", AddressValue(address));
34 }
35 
36 void
37 SatOnOffHelper::SetAttribute(std::string name, const AttributeValue& value)
38 {
39  m_factory.Set(name, value);
40 }
41 
42 ApplicationContainer
43 SatOnOffHelper::Install(Ptr<Node> node) const
44 {
45  return ApplicationContainer(InstallPriv(node));
46 }
47 
48 ApplicationContainer
49 SatOnOffHelper::Install(NodeContainer c) const
50 {
51  ApplicationContainer apps;
52  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
53  {
54  apps.Add(InstallPriv(*i));
55  }
56 
57  return apps;
58 }
59 
60 Ptr<Application>
61 SatOnOffHelper::InstallPriv(Ptr<Node> node) const
62 {
63  Ptr<Application> app = m_factory.Create<Application>();
64  node->AddApplication(app);
65 
66  return app;
67 }
68 
69 void
70 SatOnOffHelper::SetConstantRate(DataRate dataRate, uint32_t packetSize)
71 {
72  m_factory.Set("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1000]"));
73  m_factory.Set("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
74  m_factory.Set("DataRate", DataRateValue(dataRate));
75  m_factory.Set("PacketSize", UintegerValue(packetSize));
76 }
77 
78 } // 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.