satellite-point-to-point-isl-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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * (based on point-to-point helper)
20  * Author: Andre Aguas March 2020
21  * Simon 2020
22  * Adapted to SNS-3 by: Bastien Tauran <bastien.tauran@viveris.fr>
23  */
24 
25 #include "ns3/satellite-point-to-point-isl-helper.h"
26 
27 #include "ns3/drop-tail-queue.h"
28 #include "ns3/log.h"
29 #include "ns3/net-device-queue-interface.h"
30 #include "ns3/packet.h"
31 #include "ns3/satellite-const-variables.h"
32 #include "ns3/satellite-point-to-point-isl-channel.h"
33 #include "ns3/string.h"
34 
35 NS_LOG_COMPONENT_DEFINE("PointToPointIslHelper");
36 
37 namespace ns3
38 {
39 
40 NS_OBJECT_ENSURE_REGISTERED(PointToPointIslHelper);
41 
42 TypeId
44 {
45  static TypeId tid =
46  TypeId("ns3::PointToPointIslHelper")
47  .SetParent<Object>()
48  .AddConstructor<PointToPointIslHelper>()
49  .AddAttribute("IslDataRate",
50  "Data rate of ISL links",
51  DataRateValue(DataRate("1Gb/s")),
52  MakeDataRateAccessor(&PointToPointIslHelper::m_dataRate),
53  MakeDataRateChecker())
54  .AddAttribute("QueueMaxPackets",
55  "The maximum number of packets accepted by ISL queues.",
56  UintegerValue(100),
57  MakeUintegerAccessor(&PointToPointIslHelper::m_maxPackets),
58  MakeUintegerChecker<uint32_t>())
59  .AddAttribute("QueueMaxBytes",
60  "The maximum number of bytes accepted by ISL queues.",
61  UintegerValue(100 * 65535),
62  MakeUintegerAccessor(&PointToPointIslHelper::m_maxBytes),
63  MakeUintegerChecker<uint32_t>());
64  return tid;
65 }
66 
68 {
69  m_queueFactory.SetTypeId("ns3::DropTailQueue<Packet>");
70  m_deviceFactory.SetTypeId("ns3::PointToPointIslNetDevice");
71  m_channelFactory.SetTypeId("ns3::PointToPointIslChannel");
72 }
73 
74 NetDeviceContainer
75 PointToPointIslHelper::Install(Ptr<Node> a, Ptr<Node> b)
76 {
77  NS_LOG_FUNCTION(this << a << b);
78 
79  NetDeviceContainer container;
80 
81  Ptr<PointToPointIslNetDevice> devA = m_deviceFactory.Create<PointToPointIslNetDevice>();
82  devA->SetAddress(Mac48Address::Allocate());
83  devA->SetDestinationNode(b);
84  devA->SetDataRate(m_dataRate);
85  a->AddDevice(devA);
86  Ptr<DropTailQueue<Packet>> queueA = m_queueFactory.Create<DropTailQueue<Packet>>();
87  // queueA->SetAttribute ("MaxPackets", UintegerValue (m_maxPackets)); // For ns 3.37
88  // queueA->SetAttribute ("MaxBytes", UintegerValue (m_maxBytes)); // For ns 3.37
89  queueA->SetAttribute("MaxSize",
90  QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, m_maxPackets)));
91  devA->SetQueue(queueA);
92 
93  Ptr<PointToPointIslNetDevice> devB = m_deviceFactory.Create<PointToPointIslNetDevice>();
94  devB->SetAddress(Mac48Address::Allocate());
95  devB->SetDestinationNode(a);
96  devB->SetDataRate(m_dataRate);
97  b->AddDevice(devB);
98  Ptr<DropTailQueue<Packet>> queueB = m_queueFactory.Create<DropTailQueue<Packet>>();
99  // queueB->SetAttribute ("MaxPackets", UintegerValue (m_maxPackets)); // For ns 3.37
100  // queueB->SetAttribute ("MaxBytes", UintegerValue (m_maxBytes)); // For ns 3.37
101  queueB->SetAttribute("MaxSize",
102  QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, m_maxPackets)));
103  devB->SetQueue(queueB);
104 
105  // Aggregate NetDeviceQueueInterface objects
106  Ptr<NetDeviceQueueInterface> ndqiA = CreateObject<NetDeviceQueueInterface>();
107  ndqiA->GetTxQueue(0)->ConnectQueueTraces(queueA);
108  devA->AggregateObject(ndqiA);
109  Ptr<NetDeviceQueueInterface> ndqiB = CreateObject<NetDeviceQueueInterface>();
110  ndqiB->GetTxQueue(0)->ConnectQueueTraces(queueB);
111  devB->AggregateObject(ndqiB);
112 
113  // Create and attach channel
114  Ptr<PointToPointIslChannel> channel = m_channelFactory.Create<PointToPointIslChannel>();
115  devA->Attach(channel);
116  devB->Attach(channel);
117  container.Add(devA);
118  container.Add(devB);
119 
120  return container;
121 }
122 
123 } // namespace ns3
void Attach(Ptr< PointToPointIslNetDevice > device)
Attach a given netdevice to this channel.
uint32_t m_maxBytes
The maximum number of bytes accepted by ISL queues.
ObjectFactory m_deviceFactory
Device Factory.
ObjectFactory m_channelFactory
Channel Factory.
DataRate m_dataRate
Data rate of ISL link.
NetDeviceContainer Install(Ptr< Node > a, Ptr< Node > b)
static TypeId GetTypeId(void)
Get the type ID.
uint32_t m_maxPackets
The maximum number of packets accepted by ISL queues.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.