ns-3 PLC model
model/plc-net-device.h
00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
00002 /*
00003  * Copyright (c) 2012 University of British Columbia, Vancouver
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation;
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * Author: Alexander Schloegl <alexander.schloegl@gmx.de>
00019  */
00020 
00021 #ifndef PLC_NET_DEVICE_H_
00022 #define PLC_NET_DEVICE_H_
00023 
00024 #include <string>
00025 #include <stdint.h>
00026 #include "ns3/net-device.h"
00027 #include "ns3/traced-callback.h"
00028 #include "ns3/spectrum-model.h"
00029 #include "ns3/plc-channel.h"
00030 #include "ns3/spectrum-value.h"
00031 #include "ns3/plc-phy.h"
00032 #include "ns3/plc-mac.h"
00033 
00034 namespace ns3 {
00035 
00048 class PLC_NetDevice : public NetDevice
00049 {
00050 public:
00051         static TypeId GetTypeId (void);
00052 
00053         PLC_NetDevice ();
00054         virtual ~PLC_NetDevice ();
00055 
00056         void SetPlcNode(Ptr<PLC_Node> plc_node);
00057         Ptr<PLC_Node> GetPlcNode(void) { return m_plc_node; }
00058         void SetSpectrumModel(Ptr<const SpectrumModel> sm);
00059         void SetNoiseFloor(Ptr<const SpectrumValue> psd);
00060         void SetTxPowerSpectralDensity(Ptr<SpectrumValue> txPsd);
00061 
00062         void SetShuntImpedance(Ptr<PLC_Impedance> shuntImpedance);
00063         void SetRxImpedance(Ptr<PLC_Impedance> rxImpedance);
00064         void SetTxImpedance(Ptr<PLC_Impedance> txImpedance);
00065         Ptr<PLC_Impedance> GetShuntImpedance(void) { return m_shuntImpedance; }
00066         Ptr<PLC_Impedance> GetRxImpedance(void) { return m_rxImpedance; }
00067         Ptr<PLC_Impedance> GetTxImpedance(void) { return m_txImpedance; }
00068 
00069         Ptr<PLC_Outlet> GetOutlet(void) { return m_outlet; }
00070         Ptr<const SpectrumModel> GetSpectrumModel(void);
00071 
00072         void Receive (Ptr<Packet> p, Mac48Address from, Mac48Address to);
00073 
00074         // From class NetDevice
00075         virtual void SetIfIndex (const uint32_t index);
00076         virtual uint32_t GetIfIndex (void) const;
00077         virtual Ptr<Channel> GetChannel (void) const;
00078         virtual void SetAddress (Address address);
00079         virtual Address GetAddress (void) const;
00080         virtual bool SetMtu (const uint16_t mtu);
00081         virtual uint16_t GetMtu (void) const;
00082         virtual bool IsLinkUp (void) const;
00083         virtual void AddLinkChangeCallback (Callback<void> callback);
00084         virtual bool IsBroadcast (void) const;
00085         virtual Address GetBroadcast (void) const;
00086         virtual bool IsMulticast (void) const;
00087         virtual Address GetMulticast (Ipv4Address multicastGroup) const;
00088         virtual Address GetMulticast (Ipv6Address addr) const;
00089         virtual bool IsBridge (void) const;
00090         virtual bool IsPointToPoint (void) const;
00091         virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
00092         virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
00093         virtual Ptr<Node> GetNode (void) const;
00094         virtual void SetNode (Ptr<Node> node);
00095         virtual bool NeedsArp (void) const;
00096 
00097         virtual void SetReceiveCallback (ReceiveCallback cb);
00098         virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
00099         virtual bool SupportsSendFrom (void) const;
00100 
00101         virtual bool ConfigComplete(void);
00102 
00103         virtual void SetPhy (Ptr<PLC_Phy> phy);
00104         virtual void SetMac (Ptr<PLC_Mac> mac);
00105         virtual Ptr<PLC_Phy> GetPhy (void);
00106         virtual Ptr<PLC_Mac> GetMac (void);
00107 
00108         PLC_ChannelTransferImpl *GetChannelTransferImpl(Ptr<PLC_NetDevice> dev);
00109 
00110         void LinkUp (void);
00111         void LinkDown (void);
00112 
00113 protected:
00114         virtual void DoDispose (void);
00115         virtual void DoStart (void);
00116         Ptr<Channel> DoGetChannel (void) const;
00117         virtual void CompleteConfig (void);
00118 
00119         Ptr<const SpectrumModel> m_spectrum_model;
00120         Ptr<const SpectrumValue> m_noiseFloor;
00121         Ptr<SpectrumValue> m_txPsd;
00122         Ptr<Node> m_node;
00123         Ptr<PLC_Node> m_plc_node;
00124         Ptr<PLC_Outlet> m_outlet;
00125 
00126         Ptr<PLC_Phy> m_phy;
00127         Ptr<PLC_Mac> m_mac;
00128 
00129         bool m_linkUp;
00130 
00131         uint32_t m_ifIndex;
00132         uint32_t m_txIfIndex;
00133         uint32_t m_rxIfIndex;
00134         Ptr<PLC_Impedance> m_shuntImpedance;
00135         Ptr<PLC_Impedance> m_txImpedance;
00136         Ptr<PLC_Impedance> m_rxImpedance;
00137 
00138         ModulationAndCodingType m_mcs;
00139 
00140         bool m_configComplete;
00141 
00142         ReceiveCallback m_receive_cb;
00143         PromiscReceiveCallback m_promiscuous_receive_cb;
00144 
00145         TracedCallback<> m_linkChanges;
00146 };
00147 
00148 }
00149 
00150 #endif /* PLC_NET_DEVICE_H_ */
 All Classes Functions Variables Enumerations