Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | |
2 /* | |
3 * Copyright (c) 2005,2006 INRIA | |
4 * Copyright (c) 2013 Dalian University of Technology | |
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 * Junling Bu <linlinjavaer@gmail.com> | |
20 */ | |
21 #ifndef WAVE_NET_DEVICE_H | |
22 #define WAVE_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 | |
29 #include "channel-manager.h" | |
30 #include "channel-scheduler.h" | |
31 #include "channel-coordinator.h" | |
32 #include "vendor-specific-action.h" | |
33 namespace ns3 { | |
34 | |
35 class WifiRemoteStationManager; | |
36 class WifiChannel; | |
37 class WifiPhy; | |
38 class WifiMac; | |
39 class ChannelScheduler; | |
40 | |
41 /** | |
42 * CchInterval means VSA frames are transmitted only on CCH interval; | |
43 * SchInterval means VSA frames are transmitted only on SCH interval; | |
44 * BothInterval means VSA frames are transmitted always; | |
45 */ | |
46 enum ChannelInterval | |
47 { | |
48 CchInterval, | |
49 SchInerval, | |
50 BothInterval, | |
51 }; | |
52 /** | |
53 * \param peer The address of the peer MAC entity to which the | |
54 * VSA is sent. | |
55 * \param oi Identifies the source of the data when the source | |
56 * is not an IEEE 1609 entity. See IEEE Std 802.11p. | |
57 * \param managementId Identifies the source of the data when the source | |
58 * is an IEEE 1609 entity. Values are specified in IEEE P1609.0. | |
59 * Valid range: 0-15 | |
60 * \param vsc pointer to Information that will be sent as vendor specific conten t. | |
61 * \param vscLength the length of vendor specific content | |
62 * \param channelNumber The channel on which the transmissions are to occur | |
63 * While section 7.2 of the standard specifies that channel identification | |
64 * comprises Country String, Operating Class, and Channel Number, channel | |
65 * number is all that is needed for simulation. | |
66 * \param repeatRate The number of Vendor Specific Action frames to | |
67 * be transmitted per 5 s. A value of 0 indicates a single message is to be sent . | |
68 * If Destination MAC Address is an individual address, Repeat Rate is ignored. | |
69 * \param channelInterval The channel interval in which the transmissions | |
70 * are to occur. | |
71 */ | |
72 struct VsaInfo | |
73 { | |
74 Mac48Address peer; | |
75 OrganizationIdentifier oi; | |
76 uint8_t management_id; | |
77 uint8_t *vsc; | |
78 uint32_t vscLength; | |
79 uint32_t channelNumber; | |
80 uint8_t repeatRate; | |
81 enum ChannelInterval channelInterval; | |
82 }; | |
83 /** | |
84 * \param channelNumber channel number that the SCH service | |
85 * can be made available for communications. | |
86 * \param operationalRateSet OperationalRateSet if present, as specified in IEEE Std 802.11. | |
87 * valid range: 1-127 | |
88 * \param immediateAccess Indicates that the MLME should provide immediate | |
89 * access to the SCH and not wait until the next SCH interval. | |
90 * \param extendedAccess Indicates that the MLME should provide continuous | |
91 * access (during both SCH interval and CCH interval) to the SCH for ExtendedAcc ess | |
92 * control channel intervals. A value of 255 indicates indefinite access. | |
93 * \param edcaParameterSet If present, as specified in IEEE Std 802.11. | |
94 * | |
95 * note: operationalRateSet and edcaParameterSet are not implemented. | |
96 */ | |
97 struct SchInfo | |
98 { | |
99 uint32_t channelNumber; | |
100 //OperationalRateSet operationalRateSet; | |
101 bool immediateAccess; | |
102 uint8_t extendedAccess; | |
103 //EDCA_Parameter_Set edcaParameterSet; | |
104 SchInfo () | |
105 : channelNumber (CCH), | |
106 immediateAccess (false), | |
107 extendedAccess (0xff) | |
108 { | |
109 | |
110 } | |
111 SchInfo (uint32_t c, bool i, uint32_t e) | |
112 : channelNumber (c), | |
113 immediateAccess (i), | |
114 extendedAccess (e) | |
115 { | |
116 | |
117 } | |
118 }; | |
119 /** | |
120 * | |
121 */ | |
122 struct TxInfo | |
123 { | |
124 uint32_t channelNumber; | |
125 uint32_t priority; | |
126 uint32_t dataRate; | |
127 uint32_t txPowerLevel; | |
128 uint32_t expiryTime; | |
129 TxInfo () | |
130 : channelNumber (CCH), | |
131 priority (0), | |
132 dataRate (0), | |
133 txPowerLevel (0), | |
134 expiryTime (0) | |
135 { | |
136 | |
137 } | |
138 TxInfo (uint32_t c, uint32_t p, uint32_t d, uint32_t t, uint32_t e) | |
139 : channelNumber (c), | |
140 priority (p), | |
141 dataRate (d), | |
142 txPowerLevel (t), | |
143 expiryTime (e) | |
144 { | |
145 | |
146 } | |
147 }; | |
148 /** | |
149 * \param channelNumber the channel number for the SCH. | |
150 * \param adaptable if true, the actual power level and data | |
151 * rate for transmission are adaptable. TxPwr_Level is the maximum | |
152 * transmit power that sets the upper bound for the actual transmit | |
153 * power; DataRate is the minimum data rate that sets the lower | |
154 * bound for the actual data rate. If false, the actual power level | |
155 * and data rate for transmission are nonadaptable. TxPwr_Level and | |
156 * DataRate are the actual values to be used for transmission. | |
157 * \param dataRate | |
158 * | |
159 * note: txPowerLevel and dataRate are not supported yet, | |
160 * I find the new 802.11n patch provides WifiTxVector that is perfect. | |
161 * We will use that class to control datarate and txpower | |
162 */ | |
163 struct TxProfile | |
164 { | |
165 uint32_t channelNumber; | |
166 bool adaptable; | |
167 uint32_t txPowerLevel; | |
168 uint32_t dataRate; | |
169 TxProfile (void) | |
170 : channelNumber (SCH1), | |
171 adaptable (false), | |
172 txPowerLevel (0), | |
173 dataRate (0) | |
174 { | |
175 | |
176 } | |
177 TxProfile (uint32_t c, bool a, uint32_t t, uint32_t d) | |
178 : channelNumber (c), | |
179 adaptable (a), | |
180 txPowerLevel (t), | |
181 dataRate (d) | |
182 { | |
183 | |
184 } | |
185 }; | |
186 /** | |
187 * This class holds together ns3::WifiChannel, ns3::WifiPhy, | |
188 * ns3::WifiMac, and, ns3::WifiRemoteStationManager. | |
189 * | |
190 * However WaveNetDevice inherits from NetDevice instead of WifiNetDevice | |
Nicola Baldo
2013/07/29 10:50:04
I think no one expected that WaveNetDevice inherit
Junling Bu
2013/07/30 16:49:11
I have asked myself many times which is better to
| |
191 * The reason is that we need multiple OcbWifiMac to deal with multi-channel ope ration | |
192 * and WifiNetDevice only deals with one WifiMac object. | |
193 * | |
194 * these methods are not implemented because of limited use in simulation | |
195 * void StartTimingAdvertisement (); | |
196 * void StopTimingAdvertisement (); | |
197 * UtcTime GetUtcTime (); | |
198 * void SetUtcTime (); | |
199 * void CancelTx (uint32_t channelNumber, AcIndex ac); | |
200 */ | |
201 class WaveNetDevice : public NetDevice | |
202 { | |
203 public: | |
204 static TypeId GetTypeId (void); | |
205 | |
206 WaveNetDevice (); | |
207 virtual ~WaveNetDevice (); | |
208 | |
209 /** | |
210 * \param mac. | |
211 */ | |
212 void AddMac (Ptr<WifiMac> mac); | |
213 /** | |
214 * \param phy the phy layer to use. | |
215 */ | |
216 void SetPhy (Ptr<WifiPhy> phy); | |
217 /** | |
218 * \param manager the manager to use. | |
219 * | |
220 * Note: If high layer sets data rate for packets or register in | |
221 * profile or channel table, the date rate selected from manager | |
222 * will not used. And we suggest users should control data rate | |
223 * all the time or just let manager select, mixed with these two | |
224 * ways maybe will get trouble. | |
225 */ | |
226 void SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager); | |
227 /** | |
228 * \returns the macs we are currently using. | |
229 */ | |
230 std::vector< Ptr<WifiMac> > GetMacs (void) const; | |
231 /** | |
232 * \returns the phy we are currently using. | |
233 */ | |
234 Ptr<WifiPhy> GetPhy (void) const; | |
235 /** | |
236 * \returns the remote station manager we are currently using. | |
237 */ | |
238 Ptr<WifiRemoteStationManager> GetRemoteStationManager (void) const; | |
239 | |
240 /** | |
241 * \param vsa_info the parameters about how to send VSA frame | |
242 * | |
243 * before this method is called, channel access should be assigned. | |
244 * Unimplemented now | |
245 */ | |
246 bool StartVsa (const VsaInfo & vsaInfo); | |
247 /** | |
248 * \param channelNumber the channel on which VSA frames send event | |
249 * will be canceled. | |
250 * Unimplemented now | |
251 */ | |
252 void StopVsa (uint32_t channelNumber); | |
253 /** | |
254 * \param packet the packet is Vendor Specific Action frame. | |
255 * \param address the address of the MAC from which the management frame | |
256 * was received. | |
257 * \param managementID idenfify the originator of the data. | |
258 * Values are specified in IEEE P1609.0 with range 0-15. | |
259 * \param channelNumber the channel on which the frame was received. | |
260 * \returns true if the callback could handle the packet successfully, false | |
261 * otherwise. | |
262 */ | |
263 typedef Callback<bool, Ptr<const Packet>,const Address &, uint32_t, uint32_t> VsaCallback; | |
264 | |
265 void SetVsaReceiveCallback (VsaCallback vsaCallback); | |
266 /** | |
267 * \param sch_info the parameters about how to start SCH service | |
268 * | |
269 * This method is used to assign channel access for sending packets. | |
270 */ | |
271 bool StartSch (const SchInfo & schInfo); | |
272 /** | |
273 * \param channelNumber the channel which access resource will be released. | |
274 */ | |
275 void StopSch (uint32_t channelNumber); | |
276 /** | |
277 * \param txprofile transmit profile for IP-based data | |
278 * register a transmitter profile in the MLME before | |
279 * the associated IP-based data transfer starts. | |
280 * So normally this method should be called before Send | |
281 * method is called. | |
282 * And txprofile can only be registered once unless | |
283 * users unregister. | |
284 */ | |
285 bool RegisterTxProfile (const TxProfile &txprofile); | |
286 /** | |
287 * \param channelNumber the specific channel number | |
288 * delete a registered transmitter profile in the MLME | |
289 * after the associated IP-based data transfer is complete | |
290 */ | |
291 void UnregisterTxProfile (uint32_t channelNumber); | |
292 | |
293 /** | |
294 * \param packet packet sent from above down to Network Device | |
295 * \param dest mac address of the destination (already resolved) | |
296 * \param protocol identifies the type of payload contained in the packet. | |
297 * Used to call the right L3Protocol when the packet is received. | |
298 * note: although this method is mainly used for WSMP packets, users | |
299 * can send any packets they like even this protocol is IP-based. | |
300 * \param txInfo WSMP or other packets parameters for sending | |
301 * \return whether the SendX operation succeeded | |
302 * | |
303 * SendX method implements MA-UNITDATAX.request primitive. | |
304 * comparing to WaveNetDevice::Send, here is two differences | |
305 * 1) WaveNetDevice::Send cannot control phy parameters for generality, | |
306 * but WaveNetDevice::SendX can allow user control packets on a per-message b asis; | |
307 * 2) If users want to use priority in WifiNetDevice, they should insert | |
308 * a QosTag into Packet before Send method, however with SendX method, | |
309 * users should set the priority in TxInfo. | |
310 * Normally this method is called by high 1609.3 standard to send WSMP packets . | |
311 */ | |
312 bool SendX (Ptr<Packet> packet, const Address& dest, uint32_t protocol, const TxInfo & txInfo); | |
313 /** | |
314 * \param newAddress | |
315 * an immediate MAC-layer address change is required | |
316 * (e.g., to support device pseudonymity) | |
317 * note: this function is useful in real environment, | |
318 * but seems useless in simulation. | |
319 * And this method is similar to SetAddress method, but | |
320 * SetAddress is suggested when initialize a device, and this method | |
321 * is used when change address, a addressChange TracedCallback | |
322 * will be called. | |
323 */ | |
324 void ChangeAddress (Mac48Address newAddress); | |
325 | |
326 // inherited from NetDevice base class. | |
327 virtual void SetIfIndex (const uint32_t index); | |
328 virtual uint32_t GetIfIndex (void) const; | |
329 virtual Ptr<Channel> GetChannel (void) const; | |
330 virtual void SetAddress (Address address); | |
331 virtual Address GetAddress (void) const; | |
332 virtual bool SetMtu (const uint16_t mtu); | |
333 virtual uint16_t GetMtu (void) const; | |
334 /** | |
335 * Different from WifiNetDevice::IsLinkUp, a WaveNetDevice device | |
336 * is always link up so the m_linkup variable is true forever, | |
337 * even the device is in channel switch state, packets can be queued | |
338 */ | |
339 virtual bool IsLinkUp (void) const; | |
340 virtual void AddLinkChangeCallback (Callback<void> callback); | |
341 virtual bool IsBroadcast (void) const; | |
342 virtual Address GetBroadcast (void) const; | |
343 virtual bool IsMulticast (void) const; | |
344 virtual Address GetMulticast (Ipv4Address multicastGroup) const; | |
345 virtual bool IsPointToPoint (void) const; | |
346 virtual bool IsBridge (void) const; | |
347 /** | |
348 * WAVE supports both WSMP and IPv6 packets in data plane | |
349 * Here we will not prevent IPv4 packets, users can use this method | |
350 * to send any packet, even WSMP packets. | |
351 */ | |
352 virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolN umber); | |
353 virtual Ptr<Node> GetNode (void) const; | |
354 virtual void SetNode (Ptr<Node> node); | |
355 /** | |
356 * Whether NeedsArp or not? | |
357 * For IP-based Packets , yes; | |
358 * For WSMP packets, no; | |
359 * so now return true always. | |
360 */ | |
361 virtual bool NeedsArp (void) const; | |
362 /** | |
363 * see 1609.4-2010 chapter 5.3.3 | |
364 * SendX method for WSMP packets and Send method for IP-based packets, | |
365 * Here is to use this method to receive packets regardless of whether | |
366 * the frame contains a WSMP or an IPv6 packet. | |
367 */ | |
368 virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); | |
369 | |
370 virtual Address GetMulticast (Ipv6Address addr) const; | |
371 | |
372 virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Addres s& dest, uint16_t protocolNumber); | |
373 virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb); | |
374 // now return false, maybe change in the future | |
375 virtual bool SupportsSendFrom (void) const; | |
376 | |
377 void SetChannelManager (Ptr<ChannelManager> channelManager); | |
378 Ptr<ChannelManager> GetChannelManager (void) const; | |
379 void SetChannelScheduler (Ptr<ChannelScheduler> channelScheduler); | |
380 Ptr<ChannelScheduler> GetChannelScheduler (void) const; | |
381 void SetChannelCoordinator (Ptr<ChannelCoordinator> channelCoordinator); | |
382 Ptr<ChannelCoordinator> GetChannelCoordinator (void) const; | |
383 | |
384 private: | |
385 // This value conforms to the 802.11 specification | |
386 static const uint16_t MAX_MSDU_SIZE = 2304; | |
387 | |
388 virtual void DoDispose (void); | |
389 virtual void DoInitialize (void); | |
390 void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to); | |
391 Ptr<WifiChannel> DoGetChannel (void) const; | |
392 | |
393 Ptr<Node> m_node; | |
394 Ptr<WifiRemoteStationManager> m_stationManager; | |
395 std::vector< Ptr<WifiMac> > m_macs; | |
396 Ptr<WifiPhy> m_phy; | |
397 | |
398 NetDevice::ReceiveCallback m_forwardUp; | |
399 NetDevice::PromiscReceiveCallback m_promiscRx; | |
400 VsaCallback m_vsaReceived; | |
401 | |
402 TracedCallback<Ptr<const Packet>, Mac48Address> m_rxLogger; | |
403 TracedCallback<Ptr<const Packet>, Mac48Address> m_txLogger; | |
404 | |
405 uint32_t m_ifIndex; | |
406 mutable uint16_t m_mtu; | |
407 | |
408 Ptr<ChannelManager> m_channelManager; | |
409 Ptr<ChannelScheduler> m_channelScheduler; | |
410 Ptr<ChannelCoordinator> m_channelCoordinator; | |
411 TxProfile *m_txProfile; | |
412 | |
413 TracedCallback<Mac48Address, Mac48Address> m_addressChange; | |
414 }; | |
415 | |
416 } // namespace ns3 | |
417 | |
418 #endif /* WAVE_NET_DEVICE_H */ | |
OLD | NEW |