author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Tue, 02 Sep 2008 11:28:03 -0700 | |
changeset 3584 | 4eb48239b4dc |
parent 3480 | a920df6b9f02 |
child 3604 | a84d99890289 |
permissions | -rw-r--r-- |
1899
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005,2006 INRIA |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
|
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#ifndef WIFI_NET_DEVICE_H |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#define WIFI_NET_DEVICE_H |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "ns3/net-device.h" |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "ns3/packet.h" |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
26 |
#include "ns3/traced-callback.h" |
1899
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "ns3/mac48-address.h" |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
28 |
#include "wifi-remote-station-manager.h" |
1899
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
#include <string> |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
namespace ns3 { |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
class WifiChannel; |
1954
d1fde26bcb1c
add WifiNetDevice to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1922
diff
changeset
|
34 |
class WifiPhy; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
35 |
class WifiMac; |
2053
012487e16e31
basic tracing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2029
diff
changeset
|
36 |
|
012487e16e31
basic tracing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2029
diff
changeset
|
37 |
/** |
2687 | 38 |
* \brief Hold together all Wifi-related objects. |
2029
234f9a8c49af
basic doxygen documentation for users
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2002
diff
changeset
|
39 |
* |
2687 | 40 |
* This class holds together ns3::WifiChannel, ns3::WifiPhy, |
41 |
* ns3::WifiMac, and, ns3::WifiRemoteStationManager. |
|
2029
234f9a8c49af
basic doxygen documentation for users
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2002
diff
changeset
|
42 |
*/ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
43 |
class WifiNetDevice : public NetDevice |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
44 |
{ |
1899
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
public: |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
46 |
static TypeId GetTypeId (void); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
47 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
48 |
WifiNetDevice (); |
1899
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
virtual ~WifiNetDevice (); |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
|
2687 | 51 |
/** |
52 |
* \param mac the mac layer to use. |
|
53 |
*/ |
|
2601
4297e8c61615
rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
54 |
void SetMac (Ptr<WifiMac> mac); |
2687 | 55 |
/** |
56 |
* \param phy the phy layer to use. |
|
57 |
*/ |
|
2601
4297e8c61615
rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
58 |
void SetPhy (Ptr<WifiPhy> phy); |
2687 | 59 |
/** |
60 |
* \param manager the manager to use. |
|
61 |
*/ |
|
2601
4297e8c61615
rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
62 |
void SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager); |
2687 | 63 |
/** |
64 |
* \param channel the channel to connect to. |
|
65 |
*/ |
|
2601
4297e8c61615
rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
66 |
void SetChannel (Ptr<WifiChannel> channel); |
2687 | 67 |
/** |
68 |
* \returns the mac we are currently using. |
|
69 |
*/ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
70 |
Ptr<WifiMac> GetMac (void) const; |
2687 | 71 |
/** |
72 |
* \returns the phy we are currently using. |
|
73 |
*/ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
74 |
Ptr<WifiPhy> GetPhy (void) const; |
2687 | 75 |
/** |
76 |
* \returns the remote station manager we are currently using. |
|
77 |
*/ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
78 |
Ptr<WifiRemoteStationManager> GetRemoteStationManager (void) const; |
1899
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
|
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
|
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
81 |
// inherited from NetDevice base class. |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
82 |
virtual void SetName(const std::string name); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
83 |
virtual std::string GetName(void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
84 |
virtual void SetIfIndex(const uint32_t index); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
85 |
virtual uint32_t GetIfIndex(void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
86 |
virtual Ptr<Channel> GetChannel (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
87 |
virtual Address GetAddress (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
88 |
virtual bool SetMtu (const uint16_t mtu); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
89 |
virtual uint16_t GetMtu (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
90 |
virtual bool IsLinkUp (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
91 |
virtual void SetLinkChangeCallback (Callback<void> callback); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
92 |
virtual bool IsBroadcast (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
93 |
virtual Address GetBroadcast (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
94 |
virtual bool IsMulticast (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
95 |
virtual Address GetMulticast (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
96 |
virtual Address MakeMulticastAddress (Ipv4Address multicastGroup) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
97 |
virtual bool IsPointToPoint (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
98 |
virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
99 |
virtual Ptr<Node> GetNode (void) const; |
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2530
diff
changeset
|
100 |
virtual void SetNode (Ptr<Node> node); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
101 |
virtual bool NeedsArp (void) const; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
102 |
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
103 |
|
3480
a920df6b9f02
Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3464
diff
changeset
|
104 |
virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber); |
a920df6b9f02
Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3464
diff
changeset
|
105 |
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb); |
3584
4eb48239b4dc
bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3480
diff
changeset
|
106 |
virtual bool SupportsSendFrom (void) const; |
3480
a920df6b9f02
Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3464
diff
changeset
|
107 |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1954
diff
changeset
|
108 |
private: |
2530
05f9cec44621
avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
109 |
virtual void DoDispose (void); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
110 |
void ForwardUp (Ptr<Packet> packet, const Mac48Address &from); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
111 |
void LinkUp (void); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
112 |
void LinkDown (void); |
2601
4297e8c61615
rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
113 |
void Setup (void); |
2620
0131b5889305
make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2601
diff
changeset
|
114 |
Ptr<WifiChannel> DoGetChannel (void) const; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
115 |
Ptr<Node> m_node; |
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2053
diff
changeset
|
116 |
Ptr<WifiPhy> m_phy; |
2601
4297e8c61615
rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
117 |
Ptr<WifiChannel> m_channel; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
118 |
Ptr<WifiMac> m_mac; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
119 |
Ptr<WifiRemoteStationManager> m_stationManager; |
3448
0bd851bb1225
Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3442
diff
changeset
|
120 |
ReceiveCallback m_forwardUp; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
121 |
TracedCallback<Ptr<const Packet>, Mac48Address> m_rxLogger; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
122 |
TracedCallback<Ptr<const Packet>, Mac48Address> m_txLogger; |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
123 |
uint32_t m_ifIndex; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
124 |
std::string m_name; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2284
diff
changeset
|
125 |
bool m_linkUp; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
126 |
Callback<void> m_linkChange; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2508
diff
changeset
|
127 |
mutable uint16_t m_mtu; |
1899
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
128 |
}; |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
129 |
|
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
130 |
} // namespace ns3 |
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
131 |
|
f601585e8e89
add missing header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
132 |
#endif /* WIFI_NET_DEVICE_H */ |