satellite-llc.h
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: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
21 #ifndef SATELLITE_LLC_H_
22 #define SATELLITE_LLC_H_
23 
25 
26 #include <ns3/mac48-address.h>
27 #include <ns3/object.h>
28 #include <ns3/ptr.h>
29 #include <ns3/simple-ref-count.h>
30 #include <ns3/traced-callback.h>
31 
32 #include <map>
33 #include <stdint.h>
34 #include <string>
35 #include <vector>
36 
37 namespace ns3
38 {
39 
40 class Time;
41 class Address;
42 class Packet;
43 class SatControlMessage;
44 class SatSchedulingObject;
45 class SatNodeInfo;
46 
52 class EncapKey : public SimpleRefCount<EncapKey>
53 {
54  public:
55  Mac48Address m_encapAddress;
56  Mac48Address m_decapAddress;
57  Mac48Address m_sourceE2EAddress;
58  Mac48Address m_destE2EAddress;
59  int8_t m_flowId;
60 
61  EncapKey(const Mac48Address encapAddress,
62  const Mac48Address decapAddress,
63  const uint8_t flowId,
64  const Mac48Address sourceE2EAddress = Mac48Address(),
65  const Mac48Address destE2EAddress = Mac48Address())
66  : m_encapAddress(encapAddress),
67  m_decapAddress(decapAddress),
68  m_sourceE2EAddress(sourceE2EAddress),
69  m_destE2EAddress(destE2EAddress),
70  m_flowId(flowId)
71  {
72  }
73 };
74 
83 {
84  public:
85  bool operator()(Ptr<EncapKey> key1, Ptr<EncapKey> key2) const
86  {
87  if (key1->m_encapAddress == key2->m_encapAddress)
88  {
89  if (key1->m_decapAddress == key2->m_decapAddress)
90  {
91  return key1->m_flowId < key2->m_flowId;
92  }
93  else
94  {
95  return key1->m_decapAddress < key2->m_decapAddress;
96  }
97  }
98  else
99  {
100  return key1->m_encapAddress < key2->m_encapAddress;
101  }
102  }
103 };
104 
131 class SatLlc : public Object
132 {
133  public:
137  static TypeId GetTypeId(void);
138 
142  SatLlc();
143 
149  virtual ~SatLlc();
150 
156  typedef std::map<Ptr<EncapKey>, Ptr<SatBaseEncapsulator>, EncapKeyCompare> EncapContainer_t;
157 
162  typedef Callback<void, Ptr<const Packet>> ReceiveCallback;
163 
170  typedef Callback<Ptr<SatControlMessage>, uint32_t> ReadCtrlMsgCallback;
171 
177 
186  virtual bool Enque(Ptr<Packet> packet, Address dest, uint8_t flowId);
187 
201  virtual Ptr<Packet> NotifyTxOpportunity(uint32_t bytes,
202  Mac48Address utAddr,
203  uint8_t flowId,
204  uint32_t& bytesLeft,
205  uint32_t& nextMinTxO) = 0;
206 
213  virtual void Receive(Ptr<Packet> packet, Mac48Address source, Mac48Address dest);
214 
222  virtual void ReceiveHigherLayerPdu(Ptr<Packet> packet, Mac48Address source, Mac48Address dest);
223 
230 
239  void AddEncap(Mac48Address source,
240  Mac48Address dest,
241  uint8_t flowId,
242  Ptr<SatBaseEncapsulator> enc);
243 
252  void AddDecap(Mac48Address source,
253  Mac48Address dest,
254  uint8_t flowId,
255  Ptr<SatBaseEncapsulator> dec);
256 
261  virtual void SetNodeInfo(Ptr<SatNodeInfo> nodeInfo);
262 
270  virtual void GetSchedulingContexts(std::vector<Ptr<SatSchedulingObject>>& output) const = 0;
271 
276  virtual bool BuffersEmpty() const;
277 
282  virtual bool ControlBuffersEmpty() const;
283 
293  virtual uint32_t GetNBytesInQueue(Mac48Address utAddress) const = 0;
294 
304  virtual uint32_t GetNPacketsInQueue(Mac48Address utAddress) const = 0;
305 
312  virtual uint32_t GetNBytesInQueue() const;
313 
320  virtual uint32_t GetNPacketsInQueue() const;
321 
326 
331  virtual void SetGwAddress(Mac48Address address);
332 
337  virtual void SetSatelliteAddress(Mac48Address address);
338 
343  void SetAdditionalHeaderSize(uint32_t additionalHeaderSize);
344 
345  protected:
349  virtual void DoDispose();
350 
357  virtual void CreateEncap(Ptr<EncapKey> key) = 0;
358 
365  virtual void CreateDecap(Ptr<EncapKey> key) = 0;
366 
373  virtual void ReceiveAck(Ptr<SatArqAckMessage> ack, Mac48Address source, Mac48Address dest);
374 
380 
386 
390  TracedCallback<Time,
393  uint32_t,
394  Mac48Address,
397  std::string>
399 
404  Ptr<SatNodeInfo> m_nodeInfo;
405 
410 
415 
420 
425 
429  Mac48Address m_gwAddress;
430 
434  Mac48Address m_satelliteAddress;
435 
440 
445 
450 
457 
462 
467 };
468 
469 } // namespace ns3
470 
471 #endif /* SATELLITE_LLC_H_ */
EncapKeyCompare is used as a custom compare method within EncapContainer map.
Definition: satellite-llc.h:83
bool operator()(Ptr< EncapKey > key1, Ptr< EncapKey > key2) const
Definition: satellite-llc.h:85
EncapKey class is used as a key in the encapsulator/decapsulator container.
Definition: satellite-llc.h:53
Mac48Address m_encapAddress
Definition: satellite-llc.h:55
Mac48Address m_decapAddress
Definition: satellite-llc.h:56
EncapKey(const Mac48Address encapAddress, const Mac48Address decapAddress, const uint8_t flowId, const Mac48Address sourceE2EAddress=Mac48Address(), const Mac48Address destE2EAddress=Mac48Address())
Definition: satellite-llc.h:61
Mac48Address m_sourceE2EAddress
Definition: satellite-llc.h:57
Mac48Address m_destE2EAddress
Definition: satellite-llc.h:58
Callback< bool, Ptr< SatControlMessage >, const Address & > SendCtrlCallback
Control msg sending callback.
SatLinkDir_t
Link direction used for packet tracing.
SatNodeType_t
Node type used for packet tracing.
SatPacketEvent_t
Packet event used for packet tracing.
SatLogLevel_t
Log level used for packet tracing.
RegenerationMode_t
The regeneration mode used in satellites.
SatLlc base class holds the UT specific SatBaseEncapsulator instances, which are responsible of fragm...
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
virtual bool BuffersEmpty() const
Are buffers empty?
static TypeId GetTypeId(void)
Derived from Object.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
virtual void SetGwAddress(Mac48Address address)
Set the GW address.
SatLlc::ReadCtrlMsgCallback m_readCtrlCallback
The read control message callback.
Callback< Ptr< SatControlMessage >, uint32_t > ReadCtrlMsgCallback
Callback to read control messages from container storing control messages.
virtual uint32_t GetNBytesInQueue() const
Get the total number of (new) bytes in all encapsulators.
virtual void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
void SetReadCtrlCallback(SatLlc::ReadCtrlMsgCallback cb)
Method to set read control message callback.
uint32_t m_additionalHeaderSize
Additional header size to add to encapsulation/decapsulation.
void SetReceiveCallback(SatLlc::ReceiveCallback cb)
Set Receive callback to forward packet to upper layer.
bool m_fwdLinkArqEnabled
Is FWD link ARQ enabled.
SatBaseEncapsulator::SendCtrlCallback m_sendCtrlCallback
Callback to send control messages.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
EncapContainer_t m_decaps
Map of decapsulator base pointers.
virtual void GetSchedulingContexts(std::vector< Ptr< SatSchedulingObject >> &output) const =0
Create and fill the scheduling objects based on LLC layer information.
virtual void CreateEncap(Ptr< EncapKey > key)=0
Virtual method to create a new encapsulator 'on-a-need-basis' dynamically.
virtual uint32_t GetNPacketsInQueue(Mac48Address utAddress) const =0
Get the number of (new) packets at LLC queues for a certain UT.
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
Trace callback used for packet tracing:
virtual void CreateDecap(Ptr< EncapKey > key)=0
Virtual method to create a new decapsulator 'on-a-need-basis' dynamically.
Mac48Address m_gwAddress
GW address.
virtual void DoDispose()
Dispose of this class instance.
void AddEncap(Mac48Address source, Mac48Address dest, uint8_t flowId, Ptr< SatBaseEncapsulator > enc)
Add an encapsulator entry for the LLC.
virtual void ReceiveAck(Ptr< SatArqAckMessage > ack, Mac48Address source, Mac48Address dest)
Receive a control msg (ARQ ACK) from lower layer.
void SetCtrlMsgCallback(SatBaseEncapsulator::SendCtrlCallback cb)
EncapContainer_t m_encaps
Map of encapsulator base pointers.
virtual ~SatLlc()
Destroy a SatLlc.
void SetAdditionalHeaderSize(uint32_t additionalHeaderSize)
Set the additional header size.
std::map< Ptr< EncapKey >, Ptr< SatBaseEncapsulator >, EncapKeyCompare > EncapContainer_t
Key = Ptr<EncapKey> (source, dest, flowId) Value = Ptr<SatBaseEncapsulator> Compare class = EncapKeyC...
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
virtual bool ControlBuffersEmpty() const
Are buffers empty?
SatLlc()
Construct a SatLlc.
virtual void SetSatelliteAddress(Mac48Address address)
Set the SAT address.
virtual uint32_t GetNPacketsInQueue() const
Get the total number of (new) packets in all encapsulators.
virtual void ReceiveHigherLayerPdu(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive HL PDU from encapsulator/decapsulator entity.
Callback< void, Ptr< const Packet > > ReceiveCallback
Receive callback used for sending packet to netdevice layer.
virtual Ptr< Packet > NotifyTxOpportunity(uint32_t bytes, Mac48Address utAddr, uint8_t flowId, uint32_t &bytesLeft, uint32_t &nextMinTxO)=0
Called from lower layer (MAC) to inform a Tx opportunity of certain amount of bytes.
virtual bool Enque(Ptr< Packet > packet, Address dest, uint8_t flowId)
Called from higher layer (SatNetDevice) to enque packet to LLC.
Mac48Address m_satelliteAddress
SAT address, used in case of network regeneration.
void AddDecap(Mac48Address source, Mac48Address dest, uint8_t flowId, Ptr< SatBaseEncapsulator > dec)
Add an decapsulator entry for the LLC.
bool m_rtnLinkArqEnabled
Is RTN link ARQ enabled.
virtual void Receive(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive user data packet from lower layer.
virtual uint32_t GetNBytesInQueue(Mac48Address utAddress) const =0
Get the number of (new) bytes at LLC queue for a certain UT.
ReceiveCallback m_rxCallback
The upper layer package receive callback.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.