Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(229)

Unified Diff: src/wave/model/wave-net-device.h

Issue 11480044: implement WAVE 1609.4 without some important features
Patch Set: updates after midterm review Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wave/model/channel-scheduler.cc ('k') | src/wave/model/wave-net-device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wave/model/wave-net-device.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/wave/model/wave-net-device.h
@@ -0,0 +1,432 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,2006 INRIA
+ * Copyright (c) 2013 Dalian University of Technology
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Junling Bu <linlinjavaer@gmail.com>
+ */
+#ifndef WAVE_NET_DEVICE_H
+#define WAVE_NET_DEVICE_H
+
+#include "ns3/net-device.h"
+#include "ns3/packet.h"
+#include "ns3/traced-callback.h"
+#include "ns3/mac48-address.h"
+
+#include "channel-manager.h"
+#include "channel-scheduler.h"
+#include "channel-coordinator.h"
+#include "vsa-repeater.h"
+#include "vendor-specific-action.h"
+namespace ns3 {
+
+class WifiRemoteStationManager;
+class WifiChannel;
+class WifiPhy;
+class WifiMac;
+class ChannelScheduler;
+
+/**
+ * indicate which interval the VSA frames will be transmitted in.
+ * CchInterval will only allow in CCH Interval;
+ * SchInterval will only allow in SCH Interval;
+ * BothInterval will allow anytime.
+ */
+enum ChannelInterval
+{
+ CchInterval,
+ SchInerval,
+ BothInterval,
+};
+/**
+ * \param peer The address of the peer MAC entity to which the
+ * VSA is sent.
+ * \param oi Identifies the source of the data when the source
+ * is not an IEEE 1609 entity. See IEEE Std 802.11p.
+ * \param managementId Identifies the source of the data when the source
+ * is an IEEE 1609 entity. Values are specified in IEEE P1609.0.
+ * Valid range: 0-15
+ * \param vsc pointer to Information that will be sent as vendor specific content.
+ * \param vscLength the length of vendor specific content
+ * \param channelNumber The channel on which the transmissions are to occur
+ * While section 7.2 of the standard specifies that channel identification
+ * comprises Country String, Operating Class, and Channel Number, channel
+ * number is all that is needed for simulation.
+ * \param repeatRate The number of Vendor Specific Action frames to
+ * be transmitted per 5 s. A value of 0 indicates a single message is to be sent.
+ * If Destination MAC Address is an individual address, Repeat Rate is ignored.
+ * \param channelInterval The channel interval in which the transmissions
+ * are to occur.
+ */
+struct VsaInfo
+{
+ Mac48Address peer;
+ OrganizationIdentifier oi;
+ uint8_t management_id;
+ uint8_t *vsc;
+ uint32_t vscLength;
+ uint32_t channelNumber;
+ uint8_t repeatRate;
+ enum ChannelInterval channelInterval;
+};
+/**
+ * \param channelNumber channel number that the SCH service
+ * can be made available for communications.
+ * \param operationalRateSet OperationalRateSet if present, as specified in IEEE Std 802.11.
+ * valid range: 1-127
+ * \param immediateAccess Indicates that the MLME should provide immediate
+ * access to the SCH and not wait until the next SCH interval.
+ * \param extendedAccess Indicates that the MLME should provide continuous
+ * access (during both SCH interval and CCH interval) to the SCH for ExtendedAccess
+ * control channel intervals. A value of 255 indicates indefinite access.
+ * \param edcaParameterSet If present, as specified in IEEE Std 802.11.
+ *
+ * note: operationalRateSet and edcaParameterSet are not implemented.
+ */
+struct SchInfo
+{
+ uint32_t channelNumber;
+ //OperationalRateSet operationalRateSet;
+ bool immediateAccess;
+ uint8_t extendedAccess;
+ //EDCA_Parameter_Set edcaParameterSet;
+ SchInfo ()
+ : channelNumber (CCH),
+ immediateAccess (false),
+ extendedAccess (0xff)
+ {
+
+ }
+ SchInfo (uint32_t c, bool i, uint32_t e)
+ : channelNumber (c),
+ immediateAccess (i),
+ extendedAccess (e)
+ {
+
+ }
+};
+/**
+ * \param channelNumber the specific channel
+ * \param priority the priority of packet with range 0-7
+ * \param dataRate the transmit data rate of packet
+ * \param txPowerLevel the transmit power level
+ * \param expireTime indicate how many milliseconds the packet
+ * can stay before sent
+ *
+ * normally these parameters are used by high layer to control
+ * the transmission characteristics of WSMP data.
+ */
+struct TxInfo
+{
+ uint32_t channelNumber;
+ uint32_t priority;
+ uint32_t dataRate;
+ uint32_t txPowerLevel;
+ uint32_t expiryTime;
+ TxInfo ()
+ : channelNumber (CCH),
+ priority (0),
+ dataRate (0),
+ txPowerLevel (0),
+ expiryTime (0)
+ {
+
+ }
+ TxInfo (uint32_t c, uint32_t p, uint32_t d, uint32_t t, uint32_t e)
+ : channelNumber (c),
+ priority (p),
+ dataRate (d),
+ txPowerLevel (t),
+ expiryTime (e)
+ {
+
+ }
+};
+/**
+ * \param channelNumber the channel number for the SCH.
+ * \param adaptable if true, the actual power level and data
+ * rate for transmission are adaptable. TxPwr_Level is the maximum
+ * transmit power that sets the upper bound for the actual transmit
+ * power; DataRate is the minimum data rate that sets the lower
+ * bound for the actual data rate. If false, the actual power level
+ * and data rate for transmission are nonadaptable. TxPwr_Level and
+ * DataRate are the actual values to be used for transmission.
+ * \param dataRate
+ *
+ * note: txPowerLevel and dataRate are not supported yet,
+ * I find the new 802.11n patch provides WifiTxVector that is perfect.
+ * We will use that class to control datarate and txpower
+ */
+struct TxProfile
+{
+ uint32_t channelNumber;
+ bool adaptable;
+ uint32_t txPowerLevel;
+ uint32_t dataRate;
+ TxProfile (void)
+ : channelNumber (SCH1),
+ adaptable (false),
+ txPowerLevel (0),
+ dataRate (0)
+ {
+
+ }
+ TxProfile (uint32_t c, bool a, uint32_t t, uint32_t d)
+ : channelNumber (c),
+ adaptable (a),
+ txPowerLevel (t),
+ dataRate (d)
+ {
+
+ }
+};
+/**
+ * This class holds together ns3::WifiChannel, ns3::WifiPhy,
+ * ns3::WifiMac, and ns3::WifiRemoteStationManager.
+ * Besides that, to support multiple channel operation this
+ * class also holds ns3::ChannelScheduler, ns3::ChannelManager,
+ * ns3::Coordinator and ns3::VsaRepeater.
+ *
+ * these methods are not implemented because of limited use in simulation
+ * void StartTimingAdvertisement ();
+ * void StopTimingAdvertisement ();
+ * UtcTime GetUtcTime ();
+ * void SetUtcTime ();
+ * void CancelTx (uint32_t channelNumber, AcIndex ac);
+ */
+class WaveNetDevice : public NetDevice
+{
+public:
+ static TypeId GetTypeId (void);
+
+ WaveNetDevice ();
+ virtual ~WaveNetDevice ();
+
+ /**
+ * \param mac.
+ */
+ void AddMac (Ptr<WifiMac> mac);
+ /**
+ * \param phy the phy layer to use.
+ */
+ void SetPhy (Ptr<WifiPhy> phy);
+ /**
+ * \param manager the manager to use.
+ *
+ * Note: If high layer sets data rate for packets or register in
+ * profile or channel table, the date rate selected from manager
+ * will not used. And we suggest users should control data rate
+ * all the time or just let manager select, mixed with these two
+ * ways maybe will get trouble.
+ */
+ void SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager);
+ /**
+ * \returns the macs we are currently using.
+ */
+ std::vector< Ptr<WifiMac> > GetMacs (void) const;
+ /**
+ * \returns the phy we are currently using.
+ */
+ Ptr<WifiPhy> GetPhy (void) const;
+ /**
+ * \returns the remote station manager we are currently using.
+ */
+ Ptr<WifiRemoteStationManager> GetRemoteStationManager (void) const;
+
+ /**
+ * \param vsa_info the parameters about how to send VSA frame
+ *
+ * before this method is called, channel access should be assigned.
+ * note: although this method supports sending management information
+ * that not indicates IEEE 1609 by setting OrganizationIdentifier
+ * instead of management id, the 1609.4 standard declares that if
+ * OrganizationIdentifier not indicates IEEE 1609, the management
+ * frames will be not delivered to the IEEE 1609.4 MLME.
+ * In a word, you can send other management frames, but cannot receive.
+ */
+ bool StartVsa (VsaInfo & vsaInfo);
+ /**
+ * \param channelNumber the channel on which VSA frames send event
+ * will be canceled.
+ * Unimplemented now
+ */
+ void StopVsa (uint32_t channelNumber);
+ /**
+ * \param packet the packet is Vendor Specific Action frame.
+ * \param address the address of the MAC from which the management frame
+ * was received.
+ * \param managementID idenfify the originator of the data.
+ * Values are specified in IEEE P1609.0 with range 0-15.
+ * \param channelNumber the channel on which the frame was received.
+ * \returns true if the callback could handle the packet successfully, false
+ * otherwise.
+ */
+ typedef Callback<bool, Ptr<const Packet>,const Address &, uint32_t, uint32_t> VsaCallback;
+
+ void SetVsaReceiveCallback (VsaCallback vsaCallback);
+ /**
+ * \param sch_info the parameters about how to start SCH service
+ *
+ * This method is used to assign channel access for sending packets.
+ */
+ bool StartSch (const SchInfo & schInfo);
+ /**
+ * \param channelNumber the channel which access resource will be released.
+ */
+ void StopSch (uint32_t channelNumber);
+ /**
+ * \param txprofile transmit profile for IP-based data
+ * register a transmitter profile in the MLME before
+ * the associated IP-based data transfer starts.
+ * So normally this method should be called before Send
+ * method is called.
+ * And txprofile can only be registered once unless
+ * users unregister.
+ */
+ bool RegisterTxProfile (const TxProfile &txprofile);
+ /**
+ * \param channelNumber the specific channel number
+ * delete a registered transmitter profile in the MLME
+ * after the associated IP-based data transfer is complete
+ */
+ void UnregisterTxProfile (uint32_t channelNumber);
+
+ /**
+ * \param packet packet sent from above down to Network Device
+ * \param dest mac address of the destination (already resolved)
+ * \param protocol identifies the type of payload contained in the packet.
+ * Used to call the right L3Protocol when the packet is received.
+ * note: although this method is mainly used for WSMP packets, users
+ * can send any packets they like even this protocol is IP-based.
+ * \param txInfo WSMP or other packets parameters for sending
+ * \return whether the SendX operation succeeded
+ *
+ * SendX method implements MA-UNITDATAX.request primitive.
+ * comparing to WaveNetDevice::Send, here is two differences
+ * 1) WaveNetDevice::Send cannot control phy parameters for generality,
+ * but WaveNetDevice::SendX can allow user control packets on a per-message basis;
+ * 2) If users want to use priority in WifiNetDevice, they should insert
+ * a QosTag into Packet before Send method, however with SendX method,
+ * users should set the priority in TxInfo.
+ * Normally this method is called by high 1609.3 standard to send WSMP packets.
+ */
+ bool SendX (Ptr<Packet> packet, const Address& dest, uint32_t protocol, const TxInfo & txInfo);
+ /**
+ * \param newAddress
+ * an immediate MAC-layer address change is required
+ * (e.g., to support device pseudonymity)
+ * note: this function is useful in real environment,
+ * but seems useless in simulation.
+ * And this method is similar to SetAddress method, but
+ * SetAddress is suggested when initialize a device, and this method
+ * is used when change address, a addressChange TracedCallback
+ * will be called.
+ */
+ void ChangeAddress (Mac48Address newAddress);
+
+ // inherited from NetDevice base class.
+ virtual void SetIfIndex (const uint32_t index);
+ virtual uint32_t GetIfIndex (void) const;
+ virtual Ptr<Channel> GetChannel (void) const;
+ virtual void SetAddress (Address address);
+ virtual Address GetAddress (void) const;
+ virtual bool SetMtu (const uint16_t mtu);
+ virtual uint16_t GetMtu (void) const;
+ /**
+ * Different from WifiNetDevice::IsLinkUp, a WaveNetDevice device
+ * is always link up so the m_linkup variable is true forever,
+ * even the device is in channel switch state, packets can be queued
+ */
+ virtual bool IsLinkUp (void) const;
+ virtual void AddLinkChangeCallback (Callback<void> callback);
+ virtual bool IsBroadcast (void) const;
+ virtual Address GetBroadcast (void) const;
+ virtual bool IsMulticast (void) const;
+ virtual Address GetMulticast (Ipv4Address multicastGroup) const;
+ virtual bool IsPointToPoint (void) const;
+ virtual bool IsBridge (void) const;
+ /**
+ * WAVE supports both WSMP and IPv6 packets in data plane
+ * Here we will not prevent IPv4 packets, users can use this method
+ * to send any packet, even WSMP packets.
+ */
+ virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
+ virtual Ptr<Node> GetNode (void) const;
+ virtual void SetNode (Ptr<Node> node);
+ /**
+ * Whether NeedsArp or not?
+ * For IP-based Packets , yes;
+ * For WSMP packets, no;
+ * so now return true always.
+ */
+ virtual bool NeedsArp (void) const;
+ /**
+ * see 1609.4-2010 chapter 5.3.3
+ * SendX method for WSMP packets and Send method for IP-based packets,
+ * Here is to use this method to receive packets regardless of whether
+ * the frame contains a WSMP or an IPv6 packet.
+ */
+ virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
+
+ virtual Address GetMulticast (Ipv6Address addr) const;
+
+ virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
+ virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
+ // now return false, maybe change in the future
+ virtual bool SupportsSendFrom (void) const;
+
+ void SetChannelManager (Ptr<ChannelManager> channelManager);
+ Ptr<ChannelManager> GetChannelManager (void) const;
+ void SetChannelScheduler (Ptr<ChannelScheduler> channelScheduler);
+ Ptr<ChannelScheduler> GetChannelScheduler (void) const;
+ void SetChannelCoordinator (Ptr<ChannelCoordinator> channelCoordinator);
+ Ptr<ChannelCoordinator> GetChannelCoordinator (void) const;
+
+private:
+ // This value conforms to the 802.11 specification
+ static const uint16_t MAX_MSDU_SIZE = 2304;
+
+ virtual void DoDispose (void);
+ virtual void DoInitialize (void);
+ void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
+ Ptr<WifiChannel> DoGetChannel (void) const;
+
+ Ptr<Node> m_node;
+ Ptr<WifiRemoteStationManager> m_stationManager;
+ std::vector< Ptr<WifiMac> > m_macs;
+ Ptr<WifiPhy> m_phy;
+
+ NetDevice::ReceiveCallback m_forwardUp;
+ NetDevice::PromiscReceiveCallback m_promiscRx;
+ VsaCallback m_vsaReceived;
+
+ TracedCallback<Ptr<const Packet>, Mac48Address> m_rxLogger;
+ TracedCallback<Ptr<const Packet>, Mac48Address> m_txLogger;
+
+ uint32_t m_ifIndex;
+ mutable uint16_t m_mtu;
+
+ Ptr<ChannelManager> m_channelManager;
+ Ptr<ChannelScheduler> m_channelScheduler;
+ Ptr<ChannelCoordinator> m_channelCoordinator;
+ TxProfile *m_txProfile;
+
+ TracedCallback<Mac48Address, Mac48Address> m_addressChange;
+};
+
+} // namespace ns3
+
+#endif /* WAVE_NET_DEVICE_H */
« no previous file with comments | « src/wave/model/channel-scheduler.cc ('k') | src/wave/model/wave-net-device.cc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b