satellite-simple-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: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
21 #ifndef SATELLITE_SIMPLE_NET_DEVICE_H
22 #define SATELLITE_SIMPLE_NET_DEVICE_H
23 
25 
26 #include <ns3/error-model.h>
27 #include <ns3/net-device.h>
28 #include <ns3/packet.h>
29 #include <ns3/traced-callback.h>
30 
31 namespace ns3
32 {
33 
48 class SatSimpleNetDevice : public NetDevice
49 {
50  public:
55  static TypeId GetTypeId(void);
56 
61 
66 
77  void Receive(Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
78 
87  void SetChannel(Ptr<SatSimpleChannel> channel);
88 
98  void SetReceiveErrorModel(Ptr<ErrorModel> em);
99 
100  // inherited from NetDevice base class.
101  virtual void SetIfIndex(const uint32_t index);
102  virtual uint32_t GetIfIndex(void) const;
103  virtual Ptr<Channel> GetChannel(void) const;
104  virtual void SetAddress(Address address);
105  virtual Address GetAddress(void) const;
106  virtual bool SetMtu(const uint16_t mtu);
107  virtual uint16_t GetMtu(void) const;
108  virtual bool IsLinkUp(void) const;
109  virtual void AddLinkChangeCallback(Callback<void> callback);
110  virtual bool IsBroadcast(void) const;
111  virtual Address GetBroadcast(void) const;
112  virtual bool IsMulticast(void) const;
113  virtual Address GetMulticast(Ipv4Address multicastGroup) const;
114  virtual bool IsPointToPoint(void) const;
115  virtual bool IsBridge(void) const;
116  virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
117  virtual bool SendFrom(Ptr<Packet> packet,
118  const Address& source,
119  const Address& dest,
120  uint16_t protocolNumber);
121  virtual Ptr<Node> GetNode(void) const;
122  virtual void SetNode(Ptr<Node> node);
123  virtual bool NeedsArp(void) const;
124  virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb);
125 
126  virtual Address GetMulticast(Ipv6Address addr) const;
127 
128  virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb);
129  virtual bool SupportsSendFrom(void) const;
130 
131  protected:
135  virtual void DoDispose(void);
136 
137  private:
138  Ptr<SatSimpleChannel> m_channel;
139  NetDevice::ReceiveCallback m_rxCallback;
140  NetDevice::PromiscReceiveCallback m_promiscCallback;
141  Ptr<Node> m_node;
142  uint16_t m_mtu;
143  uint32_t m_ifIndex;
144  Mac48Address m_address;
145  Ptr<ErrorModel> m_receiveErrorModel;
154  TracedCallback<Ptr<const Packet>> m_phyRxDropTrace;
155 };
156 
157 } // namespace ns3
158 
159 #endif /* SATELLITE_SIMPLE_NET_DEVICE_H */
Satellite simple net device for satellite public and backbone network use.
virtual Address GetBroadcast(void) const
virtual uint16_t GetMtu(void) const
void Receive(Ptr< Packet > packet, uint16_t protocol, Mac48Address to, Mac48Address from)
Receive a packet from a connected SatSimpleChannel.
virtual void SetNode(Ptr< Node > node)
void SetChannel(Ptr< SatSimpleChannel > channel)
Attach a channel to this net device.
virtual uint32_t GetIfIndex(void) const
virtual bool IsBridge(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
static TypeId GetTypeId(void)
Get the type ID.
virtual bool SupportsSendFrom(void) const
virtual bool NeedsArp(void) const
virtual void SetIfIndex(const uint32_t index)
virtual Ptr< Node > GetNode(void) const
Ptr< SatSimpleChannel > m_channel
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual bool IsBroadcast(void) const
virtual bool IsLinkUp(void) const
SatSimpleNetDevice()
Default constructor.
NetDevice::ReceiveCallback m_rxCallback
virtual Address GetAddress(void) const
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
NetDevice::PromiscReceiveCallback m_promiscCallback
virtual void AddLinkChangeCallback(Callback< void > callback)
~SatSimpleNetDevice()
Destructor for SatSimpleNetDevice.
virtual void DoDispose(void)
Dispose of this class instance.
virtual bool IsPointToPoint(void) const
virtual void SetAddress(Address address)
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received due to the error model being...
virtual bool SetMtu(const uint16_t mtu)
virtual Ptr< Channel > GetChannel(void) const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
virtual bool IsMulticast(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.