Loading...
Searching...
No Matches
satellite-orbiter-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
22
27
28#include <stdint.h>
29#include <utility>
30
31NS_LOG_COMPONENT_DEFINE("SatOrbiterUserLlc");
32
33namespace ns3
34{
35
36NS_OBJECT_ENSURE_REGISTERED(SatOrbiterUserLlc);
37
38TypeId
40{
41 static TypeId tid = TypeId("ns3::SatOrbiterUserLlc").SetParent<SatOrbiterLlc>();
42 return tid;
43}
44
47{
48 NS_LOG_FUNCTION(this);
49}
50
52{
53 NS_LOG_FUNCTION(this);
54}
55
56void
58{
59 Object::DoDispose();
60}
61
62void
64{
65 NS_LOG_FUNCTION(this << key->m_encapAddress << key->m_decapAddress
66 << (uint32_t)(key->m_flowId));
67
68 Ptr<SatBaseEncapsulator> userEncap;
69
71 {
72 // Control packet
73 userEncap = CreateObject<SatBaseEncapsulator>(key->m_encapAddress,
74 key->m_decapAddress,
75 key->m_sourceE2EAddress,
76 key->m_destE2EAddress,
77 key->m_flowId);
78 }
79 else if (m_fwdLinkArqEnabled)
80 {
81 userEncap = CreateObject<SatGenericStreamEncapsulatorArq>(key->m_encapAddress,
82 key->m_decapAddress,
83 key->m_sourceE2EAddress,
84 key->m_destE2EAddress,
85 key->m_flowId,
87 }
88 else
89 {
90 userEncap = CreateObject<SatGenericStreamEncapsulator>(key->m_encapAddress,
91 key->m_decapAddress,
92 key->m_sourceE2EAddress,
93 key->m_destE2EAddress,
94 key->m_flowId,
96 }
97
98 Ptr<SatQueue> queue = CreateObject<SatQueue>(key->m_flowId);
99
100 userEncap->SetQueue(queue);
101
102 NS_LOG_INFO("Create encapsulator with key (" << key->m_encapAddress << ", "
103 << key->m_decapAddress << ", "
104 << (uint32_t)key->m_flowId << ")");
105
106 // Store the encapsulator
107 std::pair<EncapContainer_t::iterator, bool> result =
108 m_encaps.insert(std::make_pair(key, userEncap));
109 if (result.second == false)
110 {
111 NS_FATAL_ERROR("Insert to map with key (" << key->m_encapAddress << ", "
112 << key->m_decapAddress << ", "
113 << (uint32_t)key->m_flowId << ") failed!");
114 }
115}
116
117void
119{
120 NS_LOG_FUNCTION(this << key->m_encapAddress << key->m_decapAddress
121 << (uint32_t)(key->m_flowId));
122
123 Ptr<SatBaseEncapsulator> userDecap;
124
126 {
127 // Control packet
128 userDecap = CreateObject<SatBaseEncapsulator>(key->m_encapAddress,
129 key->m_decapAddress,
130 key->m_sourceE2EAddress,
131 key->m_destE2EAddress,
132 key->m_flowId);
133 }
134 else if (m_rtnLinkArqEnabled)
135 {
136 userDecap = CreateObject<SatReturnLinkEncapsulatorArq>(key->m_encapAddress,
137 key->m_decapAddress,
138 key->m_sourceE2EAddress,
139 key->m_destE2EAddress,
140 key->m_flowId,
142 }
143 else
144 {
145 userDecap = CreateObject<SatReturnLinkEncapsulator>(key->m_encapAddress,
146 key->m_decapAddress,
147 key->m_sourceE2EAddress,
148 key->m_destE2EAddress,
149 key->m_flowId,
151 }
152
153 userDecap->SetReceiveCallback(MakeCallback(&SatLlc::ReceiveHigherLayerPdu, this));
154
155 NS_LOG_INFO("Create decapsulator with key (" << key->m_encapAddress << ", "
156 << key->m_decapAddress << ", "
157 << (uint32_t)key->m_flowId << ")");
158
159 // Store the decapsulator
160 std::pair<EncapContainer_t::iterator, bool> result =
161 m_decaps.insert(std::make_pair(key, userDecap));
162 if (result.second == false)
163 {
164 NS_FATAL_ERROR("Insert to map with key (" << key->m_encapAddress << ", "
165 << key->m_decapAddress << ", "
166 << (uint32_t)key->m_flowId << ") failed!");
167 }
168}
169
170} // namespace ns3
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.
SatOrbiterLlc()
Construct a SatOrbiterLlc.
SatOrbiterUserLlc holds the orbiter user implementation of LLC layer.
static TypeId GetTypeId(void)
Derived from Object.
SatOrbiterUserLlc()
Construct a SatOrbiterUserLlc.
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.
virtual void CreateDecap(Ptr< EncapKey > key)
Virtual method to create a new decapsulator 'on-a-need-basis' dynamically.
virtual ~SatOrbiterUserLlc()
Destroy a SatOrbiterUserLlc.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.