satellite-net-device.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_NET_DEVICE_H
22 #define SATELLITE_NET_DEVICE_H
23 
24 #include "satellite-enums.h"
26 
27 #include <ns3/mac48-address.h>
28 #include <ns3/net-device.h>
29 #include <ns3/nstime.h>
30 #include <ns3/simulator.h>
31 #include <ns3/traced-callback.h>
32 
33 #include <stdint.h>
34 #include <string>
35 
36 namespace ns3
37 {
38 
39 class SatPhy;
40 class SatMac;
41 class SatLlc;
42 class Node;
43 class ErrorModel;
44 class SatNodeInfo;
45 class SatControlMessage;
46 
51 class SatNetDevice : public NetDevice
52 {
53  public:
58  static TypeId GetTypeId(void);
59 
63  SatNetDevice();
64 
65  /*
66  * \brief Receive the packet from mac layer
67  * \param packet Pointer to the packet to be received.
68  */
69  virtual void Receive(Ptr<const Packet> packet);
70 
71  /*
72  * \brief Attach the SatPhy physical layer to this netdevice.
73  * \param phy SatPhy pointer to be added
74  */
75  void SetPhy(Ptr<SatPhy> phy);
76 
82  Ptr<SatPhy> GetPhy(void) const;
83 
84  /*
85  * \brief Attach the SatMac mac layer to this netdevice.
86  * \param mac SatMac pointer to be added
87  */
88  void SetMac(Ptr<SatMac> mac);
89 
95  Ptr<SatMac> GetMac(void) const;
96 
101  void SetLlc(Ptr<SatLlc> llc);
102 
108  Ptr<SatLlc> GetLlc(void) const;
109 
114  void SetPacketClassifier(Ptr<SatPacketClassifier> classifier);
115 
120  Ptr<SatPacketClassifier> GetPacketClassifier() const;
121 
128  void SetReceiveErrorModel(Ptr<ErrorModel> em);
129 
130  // inherited from NetDevice base class.
131  virtual void SetIfIndex(const uint32_t index);
132  virtual uint32_t GetIfIndex(void) const;
133  virtual void SetAddress(Address address);
134  virtual Address GetAddress(void) const;
135  virtual bool SetMtu(const uint16_t mtu);
136  virtual uint16_t GetMtu(void) const;
137  virtual bool IsLinkUp(void) const;
138  virtual void AddLinkChangeCallback(Callback<void> callback);
139  virtual bool IsBroadcast(void) const;
140  virtual Address GetBroadcast(void) const;
141  virtual bool IsMulticast(void) const;
142  virtual Address GetMulticast(Ipv4Address multicastGroup) const;
143  virtual bool IsPointToPoint(void) const;
144  virtual bool IsBridge(void) const;
145  virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
146  virtual bool SendFrom(Ptr<Packet> packet,
147  const Address& source,
148  const Address& dest,
149  uint16_t protocolNumber);
150  bool SendControlMsg(Ptr<SatControlMessage> msg, const Address& dest);
151  virtual Ptr<Node> GetNode(void) const;
152  virtual void SetNode(Ptr<Node> node);
153  virtual bool NeedsArp(void) const;
154  virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb);
155  virtual Address GetMulticast(Ipv6Address addr) const;
156 
157  virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb);
158  virtual bool SupportsSendFrom(void) const;
159 
160  virtual Ptr<Channel> GetChannel(void) const;
161 
166  void SetNodeInfo(Ptr<SatNodeInfo> nodeInfo);
167 
173  void ToggleState(bool enabled);
174 
175  protected:
179  virtual void DoDispose(void);
180 
181  Ptr<SatPhy> m_phy;
182  Ptr<SatMac> m_mac;
183  Ptr<SatLlc> m_llc;
185  Ptr<SatPacketClassifier> m_classifier;
186  NetDevice::ReceiveCallback m_rxCallback;
187  NetDevice::PromiscReceiveCallback m_promiscCallback;
188  Ptr<Node> m_node;
189  uint16_t m_mtu;
190  uint32_t m_ifIndex;
191  Mac48Address m_address;
192  Ptr<ErrorModel> m_receiveErrorModel;
193 
194  Ptr<SatNodeInfo> m_nodeInfo;
195 
200 
205 
206  TracedCallback<Time,
209  uint32_t,
210  Mac48Address,
213  std::string>
215 
219  TracedCallback<Ptr<const Packet>> m_txTrace;
220 
225  TracedCallback<Ptr<const Packet>, const Address&> m_signallingTxTrace;
226 
231  TracedCallback<Ptr<const Packet>, const Address&> m_rxTrace;
232 
237  TracedCallback<const Time&, const Address&> m_rxDelayTrace;
238 
243  TracedCallback<const Time&, const Address&> m_rxJitterTrace;
244 
249  TracedCallback<const Time&, const Address&> m_rxLinkDelayTrace;
250 
255  TracedCallback<const Time&, const Address&> m_rxLinkJitterTrace;
256 };
257 
258 } // namespace ns3
259 
260 #endif /* SATELLITE_NET_DEVICE_H */
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.
SatNetDevice to be utilized in the UT and GW nodes.
Time m_lastLinkDelay
Last link delay measurement.
TracedCallback< const Time &, const Address & > m_rxDelayTrace
Traced callback for all received packets, including delay information and the address of the senders.
virtual bool SetMtu(const uint16_t mtu)
virtual bool IsLinkUp(void) const
virtual Ptr< Channel > GetChannel(void) const
void ToggleState(bool enabled)
Toggle the state of the device.
void SetLlc(Ptr< SatLlc > llc)
Attach the SatLlc llc layer to this netdevice.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Ptr< SatMac > GetMac(void) const
Get a Mac pointer.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
SatNetDevice()
Default constructor.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced callback for all packets received to be transmitted.
Ptr< SatPacketClassifier > m_classifier
Ptr< ErrorModel > m_receiveErrorModel
Time m_lastDelay
Last delay measurement.
virtual uint16_t GetMtu(void) const
virtual bool SupportsSendFrom(void) const
virtual bool NeedsArp(void) const
virtual Address GetAddress(void) const
virtual void DoDispose(void)
Dispose of this class instance.
TracedCallback< const Time &, const Address & > m_rxLinkDelayTrace
Traced callback for all received packets, including link delay information and the address of the sen...
void SetPhy(Ptr< SatPhy > phy)
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced callback for all received packets, including the address of the senders.
virtual bool IsBroadcast(void) const
Ptr< SatLlc > GetLlc(void) const
Get Llc pointer.
Ptr< SatNodeInfo > m_nodeInfo
virtual Address GetMulticast(Ipv4Address multicastGroup) const
virtual void Receive(Ptr< const Packet > packet)
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
static TypeId GetTypeId(void)
Get the type ID.
Ptr< SatPhy > GetPhy(void) const
Get a Phy pointer.
virtual Address GetBroadcast(void) const
virtual uint32_t GetIfIndex(void) const
void SetMac(Ptr< SatMac > mac)
virtual void SetIfIndex(const uint32_t index)
virtual void SetAddress(Address address)
Ptr< SatPacketClassifier > GetPacketClassifier() const
Get a pointer to packet classifier class.
bool SendControlMsg(Ptr< SatControlMessage > msg, const Address &dest)
NetDevice::PromiscReceiveCallback m_promiscCallback
virtual Ptr< Node > GetNode(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
TracedCallback< const Time &, const Address & > m_rxJitterTrace
Traced callback for all received packets, including jitter information and the address of the senders...
void SetPacketClassifier(Ptr< SatPacketClassifier > classifier)
Set the packet classifier class.
NetDevice::ReceiveCallback m_rxCallback
void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
TracedCallback< const Time &, const Address & > m_rxLinkJitterTrace
Traced callback for all received packets, including link jitter information and the address of the se...
virtual bool IsPointToPoint(void) const
virtual bool IsMulticast(void) const
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SatNetDevice.
virtual bool IsBridge(void) const
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
TracedCallback< Ptr< const Packet >, const Address & > m_signallingTxTrace
Traced callback for all signalling (control message) packets sent, including the destination address.
virtual void SetNode(Ptr< Node > node)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.