A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
uan-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) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #ifndef UAN_NET_DEVICE_H
22 #define UAN_NET_DEVICE_H
23 
24 #include "ns3/net-device.h"
25 #include "ns3/pointer.h"
26 #include "ns3/traced-callback.h"
27 #include "uan-address.h"
28 #include <list>
29 
30 namespace ns3 {
31 
32 class UanChannel;
33 class UanPhy;
34 class UanMac;
35 class UanTransducer;
36 
47 class UanNetDevice : public NetDevice
48 {
49 public:
51  typedef std::list<Ptr<UanPhy> > UanPhyList;
53  typedef std::list<Ptr<UanTransducer> > UanTransducerList;
54 
59  static TypeId GetTypeId (void);
60 
62  UanNetDevice ();
64  virtual ~UanNetDevice ();
65 
71  void SetMac (Ptr<UanMac> mac);
72 
78  void SetPhy (Ptr<UanPhy> phy);
79 
85  void SetChannel (Ptr<UanChannel> channel);
86 
92  Ptr<UanMac> GetMac (void) const;
93 
99  Ptr<UanPhy> GetPhy (void) const;
100 
106  Ptr<UanTransducer> GetTransducer (void) const;
112  void SetTransducer (Ptr<UanTransducer> trans);
113 
115  void Clear (void);
116 
122  void SetSleepMode (bool sleep);
123 
124  // Inherited methods
125  virtual void SetIfIndex (const uint32_t index);
126  virtual uint32_t GetIfIndex (void) const;
127  virtual Ptr<Channel> GetChannel (void) const;
128  virtual Address GetAddress (void) const;
129  virtual bool SetMtu (const uint16_t mtu);
130  virtual uint16_t GetMtu (void) const;
131  virtual bool IsLinkUp (void) const;
132  virtual bool IsBroadcast (void) const;
133  virtual Address GetBroadcast (void) const;
134  virtual bool IsMulticast (void) const;
135  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
136  virtual Address GetMulticast (Ipv6Address addr) const;
137  virtual bool IsBridge (void) const;
138  virtual bool IsPointToPoint (void) const;
139  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
140  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
141  virtual Ptr<Node> GetNode (void) const;
142  virtual void SetNode (Ptr<Node> node);
143  virtual bool NeedsArp (void) const;
146  virtual bool SupportsSendFrom (void) const;
147  virtual void AddLinkChangeCallback (Callback<void> callback);
148  virtual void SetAddress (Address address);
149 
150 private:
157  virtual void ForwardUp (Ptr<Packet> pkt, const UanAddress &src);
158 
160  Ptr<UanChannel> DoGetChannel (void) const;
161 
167 
168  //unused: std::string m_name;
169  uint32_t m_ifIndex;
170  uint16_t m_mtu;
171  bool m_linkup;
174 
179 
181  bool m_cleared;
182 
183 protected:
184  virtual void DoDispose ();
185 
186 }; // class UanNetDevice
187 
188 } // namespace ns3
189 
190 #endif /* UAN_NET_DEVICE_H */
virtual bool SetMtu(const uint16_t mtu)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
Ptr< UanMac > GetMac(void) const
Get the MAC used by this device.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
void SetMac(Ptr< UanMac > mac)
Set the MAC layer for this device.
virtual void SetAddress(Address address)
Set the address of this interface.
bool m_linkup
The link state, true if up.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void SetChannel(Ptr< UanChannel > channel)
Attach a channel.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
std::list< Ptr< UanPhy > > UanPhyList
List of UanPhy objects.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual bool IsMulticast(void) const
virtual bool IsLinkUp(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint16_t GetMtu(void) const
virtual Ptr< Channel > GetChannel(void) const
Ptr< Node > m_node
The node hosting this device.
Ptr< UanTransducer > m_trans
The Transducer attached to this device.
virtual Address GetBroadcast(void) const
a polymophic address class
Definition: address.h:86
Ptr< UanTransducer > GetTransducer(void) const
Get the transducer associated with this device.
ReceiveCallback m_forwardUp
The receive callback.
uint16_t m_mtu
The device MTU value, in bytes.
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual uint32_t GetIfIndex(void) const
A class used for addressing UAN MAC's.
Definition: uan-address.h:40
virtual void ForwardUp(Ptr< Packet > pkt, const UanAddress &src)
Forward the packet to a higher level, set with SetReceiveCallback.
TracedCallback m_linkChanges
Callback to invoke when the link state changes to UP.
Ptr< UanPhy > m_phy
The PHY layer attached to this device.
virtual Ptr< Node > GetNode(void) const
TracedCallback< Ptr< const Packet >, UanAddress > m_rxLogger
Trace source triggered when forwarding up received payload from the MAC layer.
UanNetDevice()
Default constructor.
virtual bool IsBroadcast(void) const
std::list< Ptr< UanTransducer > > UanTransducerList
List of UanTransducer objects.
Ptr< UanMac > m_mac
The MAC layer attached to this device.
static TypeId GetTypeId(void)
Register this type.
virtual bool SupportsSendFrom(void) const
TracedCallback< Ptr< const Packet >, UanAddress > m_txLogger
Trace source triggered when sending to the MAC layer.
Net device for UAN models.
Ptr< UanPhy > GetPhy(void) const
Get the Phy used by this device.
virtual Address GetAddress(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
void SetPhy(Ptr< UanPhy > phy)
Set the Phy layer for this device.
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
bool m_cleared
Flag when we've been cleared.
Network layer to device interface.
Definition: net-device.h:75
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Ptr< UanChannel > m_channel
The channel attached to this device.
virtual void SetNode(Ptr< Node > node)
void SetTransducer(Ptr< UanTransducer > trans)
Set the transdcuer used by this device.
virtual ~UanNetDevice()
Dummy destructor, DoDispose.
virtual bool NeedsArp(void) const
Ptr< UanChannel > DoGetChannel(void) const
tuple address
Definition: first.py:37
uint32_t m_ifIndex
The interface index of this device.
a unique identifier for an interface.
Definition: type-id.h:49
void Clear(void)
Clear all pointer references.
virtual void SetIfIndex(const uint32_t index)