A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
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
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
21 #ifndef WIFI_NET_DEVICE_H
22 #define WIFI_NET_DEVICE_H
24 #include "ns3/net-device.h"
25 #include "ns3/packet.h"
26 #include "ns3/traced-callback.h"
27 #include "ns3/mac48-address.h"
28 #include <string>
30 namespace ns3 {
32 class WifiRemoteStationManager;
33 class WifiChannel;
34 class WifiPhy;
35 class WifiMac;
51 class WifiNetDevice : public NetDevice
52 {
53 public:
54  static TypeId GetTypeId (void);
56  WifiNetDevice ();
57  virtual ~WifiNetDevice ();
62  void SetMac (Ptr<WifiMac> mac);
66  void SetPhy (Ptr<WifiPhy> phy);
74  Ptr<WifiMac> GetMac (void) const;
78  Ptr<WifiPhy> GetPhy (void) const;
85  // inherited from NetDevice base class.
86  virtual void SetIfIndex (const uint32_t index);
87  virtual uint32_t GetIfIndex (void) const;
88  virtual Ptr<Channel> GetChannel (void) const;
89  virtual void SetAddress (Address address);
90  virtual Address GetAddress (void) const;
91  virtual bool SetMtu (const uint16_t mtu);
92  virtual uint16_t GetMtu (void) const;
93  virtual bool IsLinkUp (void) const;
94  virtual void AddLinkChangeCallback (Callback<void> callback);
95  virtual bool IsBroadcast (void) const;
96  virtual Address GetBroadcast (void) const;
97  virtual bool IsMulticast (void) const;
98  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
99  virtual bool IsPointToPoint (void) const;
100  virtual bool IsBridge (void) const;
101  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
102  virtual Ptr<Node> GetNode (void) const;
103  virtual void SetNode (Ptr<Node> node);
104  virtual bool NeedsArp (void) const;
107  virtual Address GetMulticast (Ipv6Address addr) const;
109  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
111  virtual bool SupportsSendFrom (void) const;
112 protected:
113  virtual void DoDispose (void);
114  virtual void DoInitialize (void);
123  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
124 private:
125  // This value conforms to the 802.11 specification
126  static const uint16_t MAX_MSDU_SIZE = 2304;
132  void LinkUp (void);
136  void LinkDown (void);
142  Ptr<WifiChannel> DoGetChannel (void) const;
147  void CompleteConfig (void);
159  uint32_t m_ifIndex;
160  bool m_linkUp;
162  mutable uint16_t m_mtu;
164 };
166 } // namespace ns3
168 #endif /* WIFI_NET_DEVICE_H */
virtual void SetNode(Ptr< Node > node)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual bool SetMtu(const uint16_t mtu)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
TracedCallback< Ptr< const Packet >, Mac48Address > m_txLogger
void LinkUp(void)
Set that the link is up.
virtual uint16_t GetMtu(void) const
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual Address GetAddress(void) const
Ptr< WifiRemoteStationManager > m_stationManager
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
TracedCallback< Ptr< const Packet >, Mac48Address > m_rxLogger
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
virtual Ptr< Channel > GetChannel(void) const
virtual bool IsBroadcast(void) const
a polymophic address class
Definition: address.h:86
void SetMac(Ptr< WifiMac > mac)
virtual bool IsMulticast(void) const
Ptr< WifiPhy > GetPhy(void) const
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
void SetPhy(Ptr< WifiPhy > phy)
Ptr< WifiChannel > DoGetChannel(void) const
Return the WifiChannel this device is connected to.
Ptr< WifiMac > m_mac
virtual bool SupportsSendFrom(void) const
Ptr< WifiPhy > m_phy
Hold together all Wifi-related objects.
void SetRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
virtual Ptr< Node > GetNode(void) const
TracedCallback m_linkChanges
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint32_t GetIfIndex(void) const
static const uint16_t MAX_MSDU_SIZE
an EUI-48 address
Definition: mac48-address.h:41
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
virtual bool NeedsArp(void) const
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual Address GetBroadcast(void) const
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual void SetIfIndex(const uint32_t index)
NetDevice::ReceiveCallback m_forwardUp
Network layer to device interface.
Definition: net-device.h:75
virtual bool IsLinkUp(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
void CompleteConfig(void)
Complete the configuration of this Wi-Fi device by connecting all lower components (e...
Ptr< WifiMac > GetMac(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
tuple address
Definition: first.py:37
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
void LinkDown(void)
Set that the link is down (i.e.
a unique identifier for an interface.
Definition: type-id.h:49
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
static TypeId GetTypeId(void)
NetDevice::PromiscReceiveCallback m_promiscRx
virtual void SetAddress(Address address)
Set the address of this interface.