A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
wifi-net-device.h
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
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef WIFI_NET_DEVICE_H
22 #define WIFI_NET_DEVICE_H
23 
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>
29 
30 namespace ns3 {
31 
32 class WifiRemoteStationManager;
33 class WifiChannel;
34 class WifiPhy;
35 class WifiMac;
36 
51 class WifiNetDevice : public NetDevice
52 {
53 public:
54  static TypeId GetTypeId (void);
55 
56  WifiNetDevice ();
57  virtual ~WifiNetDevice ();
58 
62  void SetMac (Ptr<WifiMac> mac);
66  void SetPhy (Ptr<WifiPhy> phy);
74  Ptr<WifiMac> GetMac (void) const;
78  Ptr<WifiPhy> GetPhy (void) const;
83 
84 
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;
106 
107  virtual Address GetMulticast (Ipv6Address addr) const;
108 
109  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
111  virtual bool SupportsSendFrom (void) const;
112 
113 private:
114  // This value conforms to the 802.11 specification
115  static const uint16_t MAX_MSDU_SIZE = 2304;
116 
117  virtual void DoDispose (void);
118  virtual void DoInitialize (void);
119  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
120  void LinkUp (void);
121  void LinkDown (void);
122  void Setup (void);
123  Ptr<WifiChannel> DoGetChannel (void) const;
124  void CompleteConfig (void);
125 
126  Ptr<Node> m_node;
127  Ptr<WifiPhy> m_phy;
128  Ptr<WifiMac> m_mac;
129  Ptr<WifiRemoteStationManager> m_stationManager;
130  NetDevice::ReceiveCallback m_forwardUp;
132 
135 
136  uint32_t m_ifIndex;
137  bool m_linkUp;
138  TracedCallback<> m_linkChanges;
139  mutable uint16_t m_mtu;
140  bool m_configComplete;
141 };
142 
143 } // namespace ns3
144 
145 #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:59
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
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
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)
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
void SetPhy(Ptr< WifiPhy > phy)
virtual bool SupportsSendFrom(void) const
Hold together all Wifi-related objects.This class holds together ns3::WifiChannel, ns3::WifiPhy, ns3::WifiMac, and, ns3::WifiRemoteStationManager.
void SetRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
virtual Ptr< Node > GetNode(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint32_t GetIfIndex(void) const
an EUI-48 address
Definition: mac48-address.h:41
virtual void DoInitialize(void)
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:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual void SetIfIndex(const uint32_t index)
Network layer to device interface.
Definition: net-device.h:75
virtual bool IsLinkUp(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
Ptr< WifiMac > GetMac(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
a unique identifier for an interface.
Definition: type-id.h:44
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual void SetAddress(Address address)