satellite-geo-user-llc.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 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: Bastien TAURAN <bastien.tauran@viveris.fr>
19  */
20 
21 #include "satellite-geo-user-llc.h"
22 
27 
28 NS_LOG_COMPONENT_DEFINE("SatGeoUserLlc");
29 
30 namespace ns3
31 {
32 
33 NS_OBJECT_ENSURE_REGISTERED(SatGeoUserLlc);
34 
35 TypeId
37 {
38  static TypeId tid = TypeId("ns3::SatGeoUserLlc").SetParent<SatGeoLlc>();
39  return tid;
40 }
41 
43  : SatGeoLlc()
44 {
45  NS_LOG_FUNCTION(this);
46  NS_ASSERT(false); // this version of the constructor should not been used
47 }
48 
50  SatEnums::RegenerationMode_t returnLinkRegenerationMode)
51  : SatGeoLlc(forwardLinkRegenerationMode, returnLinkRegenerationMode)
52 {
53  NS_LOG_FUNCTION(this);
54 }
55 
57 {
58  NS_LOG_FUNCTION(this);
59 }
60 
61 void
63 {
64  Object::DoDispose();
65 }
66 
67 void
68 SatGeoUserLlc::CreateEncap(Ptr<EncapKey> key)
69 {
70  NS_LOG_FUNCTION(this << key->m_encapAddress << key->m_decapAddress
71  << (uint32_t)(key->m_flowId));
72 
73  Ptr<SatBaseEncapsulator> userEncap;
74 
76  {
77  // Control packet
78  userEncap = CreateObject<SatBaseEncapsulator>(key->m_encapAddress,
79  key->m_decapAddress,
80  key->m_sourceE2EAddress,
81  key->m_destE2EAddress,
82  key->m_flowId);
83  }
84  else if (m_fwdLinkArqEnabled)
85  {
86  userEncap = CreateObject<SatGenericStreamEncapsulatorArq>(key->m_encapAddress,
87  key->m_decapAddress,
88  key->m_sourceE2EAddress,
89  key->m_destE2EAddress,
90  key->m_flowId,
92  }
93  else
94  {
95  userEncap = CreateObject<SatGenericStreamEncapsulator>(key->m_encapAddress,
96  key->m_decapAddress,
97  key->m_sourceE2EAddress,
98  key->m_destE2EAddress,
99  key->m_flowId,
101  }
102 
103  Ptr<SatQueue> queue = CreateObject<SatQueue>(key->m_flowId);
104 
105  userEncap->SetQueue(queue);
106 
107  NS_LOG_INFO("Create encapsulator with key (" << key->m_encapAddress << ", "
108  << key->m_decapAddress << ", "
109  << (uint32_t)key->m_flowId << ")");
110 
111  // Store the encapsulator
112  std::pair<EncapContainer_t::iterator, bool> result =
113  m_encaps.insert(std::make_pair(key, userEncap));
114  if (result.second == false)
115  {
116  NS_FATAL_ERROR("Insert to map with key (" << key->m_encapAddress << ", "
117  << key->m_decapAddress << ", "
118  << (uint32_t)key->m_flowId << ") failed!");
119  }
120 }
121 
122 void
123 SatGeoUserLlc::CreateDecap(Ptr<EncapKey> key)
124 {
125  NS_LOG_FUNCTION(this << key->m_encapAddress << key->m_decapAddress
126  << (uint32_t)(key->m_flowId));
127 
128  Ptr<SatBaseEncapsulator> userDecap;
129 
131  {
132  // Control packet
133  userDecap = CreateObject<SatBaseEncapsulator>(key->m_encapAddress,
134  key->m_decapAddress,
135  key->m_sourceE2EAddress,
136  key->m_destE2EAddress,
137  key->m_flowId);
138  }
139  else if (m_rtnLinkArqEnabled)
140  {
141  userDecap = CreateObject<SatReturnLinkEncapsulatorArq>(key->m_encapAddress,
142  key->m_decapAddress,
143  key->m_sourceE2EAddress,
144  key->m_destE2EAddress,
145  key->m_flowId,
147  }
148  else
149  {
150  userDecap = CreateObject<SatReturnLinkEncapsulator>(key->m_encapAddress,
151  key->m_decapAddress,
152  key->m_sourceE2EAddress,
153  key->m_destE2EAddress,
154  key->m_flowId,
156  }
157 
158  userDecap->SetReceiveCallback(MakeCallback(&SatLlc::ReceiveHigherLayerPdu, this));
159 
160  NS_LOG_INFO("Create decapsulator with key (" << key->m_encapAddress << ", "
161  << key->m_decapAddress << ", "
162  << (uint32_t)key->m_flowId << ")");
163 
164  // Store the decapsulator
165  std::pair<EncapContainer_t::iterator, bool> result =
166  m_decaps.insert(std::make_pair(key, userDecap));
167  if (result.second == false)
168  {
169  NS_FATAL_ERROR("Insert to map with key (" << key->m_encapAddress << ", "
170  << key->m_decapAddress << ", "
171  << (uint32_t)key->m_flowId << ") failed!");
172  }
173 }
174 
175 } // namespace ns3
RegenerationMode_t
The regeneration mode used in satellites.
SatGeoLlc holds the GEO implementation of LLC layer.
virtual void DoDispose()
Dispose of this class instance.
virtual void CreateEncap(Ptr< EncapKey > key)
Virtual method to create a new encapsulator 'on-a-need-basis' dynamically.
SatGeoUserLlc()
Construct a SatGeoUserLlc, should not be used.
virtual void CreateDecap(Ptr< EncapKey > key)
Virtual method to create a new decapsulator 'on-a-need-basis' dynamically.
static TypeId GetTypeId(void)
Derived from Object.
virtual ~SatGeoUserLlc()
Destroy a SatGeoUserLlc.
uint32_t m_additionalHeaderSize
Additional header size to add to encapsulation/decapsulation.
bool m_fwdLinkArqEnabled
Is FWD link ARQ enabled.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
EncapContainer_t m_decaps
Map of decapsulator base pointers.
EncapContainer_t m_encaps
Map of encapsulator base pointers.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
virtual void ReceiveHigherLayerPdu(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive HL PDU from encapsulator/decapsulator entity.
bool m_rtnLinkArqEnabled
Is RTN link ARQ enabled.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.