A Discrete-Event Network Simulator
API
aloha-noack-net-device.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010
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: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #ifndef ALOHA_NOACK_NET_DEVICE_H
22 #define ALOHA_NOACK_NET_DEVICE_H
23 
24 #include <cstring>
25 #include <ns3/node.h>
26 #include <ns3/address.h>
27 #include <ns3/net-device.h>
28 #include <ns3/callback.h>
29 #include <ns3/packet.h>
30 #include <ns3/traced-callback.h>
31 #include <ns3/nstime.h>
32 #include <ns3/ptr.h>
33 #include <ns3/mac48-address.h>
34 #include <ns3/generic-phy.h>
35 
36 namespace ns3 {
37 
38 
39 class SpectrumChannel;
40 class Channel;
41 class SpectrumErrorModel;
42 template <typename Item> class Queue;
43 
44 
45 
60 {
61 public:
65  enum State
66  {
67  IDLE,
68  TX,
69  RX
70  };
71 
76  static TypeId GetTypeId (void);
77 
79  virtual ~AlohaNoackNetDevice ();
80 
81 
87  virtual void SetQueue (Ptr<Queue<Packet> > queue);
88 
89 
95 
100  void NotifyReceptionStart ();
101 
102 
107  void NotifyReceptionEndError ();
108 
115 
116 
126  void SetChannel (Ptr<Channel> c);
127 
128 
135 
136 
137 
149  void SetPhy (Ptr<Object> phy);
150 
154  Ptr<Object> GetPhy () const;
155 
156 
157 
158  // inherited from NetDevice
159  virtual void SetIfIndex (const uint32_t index);
160  virtual uint32_t GetIfIndex (void) const;
161  virtual Ptr<Channel> GetChannel (void) const;
162  virtual bool SetMtu (const uint16_t mtu);
163  virtual uint16_t GetMtu (void) const;
164  virtual void SetAddress (Address address);
165  virtual Address GetAddress (void) const;
166  virtual bool IsLinkUp (void) const;
167  virtual void AddLinkChangeCallback (Callback<void> callback);
168  virtual bool IsBroadcast (void) const;
169  virtual Address GetBroadcast (void) const;
170  virtual bool IsMulticast (void) const;
171  virtual bool IsPointToPoint (void) const;
172  virtual bool IsBridge (void) const;
173  virtual bool Send (Ptr<Packet> packet, const Address& dest,
174  uint16_t protocolNumber);
175  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest,
176  uint16_t protocolNumber);
177  virtual Ptr<Node> GetNode (void) const;
178  virtual void SetNode (Ptr<Node> node);
179  virtual bool NeedsArp (void) const;
181  virtual Address GetMulticast (Ipv4Address addr) const;
182  virtual Address GetMulticast (Ipv6Address addr) const;
184  virtual bool SupportsSendFrom (void) const;
185 
186 private:
190  void NotifyGuardIntervalEnd ();
191  virtual void DoDispose (void);
192 
196  void StartTransmission ();
197 
198 
200 
205 
208 
210 
213 
215 
220 
221 
222  uint32_t m_ifIndex;
223  mutable uint32_t m_mtu;
224  bool m_linkUp;
225 
229 };
230 
231 
232 } // namespace ns3
233 
234 #endif /* ALOHA_NOACK_NET_DEVICE_H */
Mac48Address m_address
MAC address.
virtual void SetIfIndex(const uint32_t index)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void NotifyReceptionStart()
Notify the MAC that the PHY has started a reception.
virtual bool IsBroadcast(void) const
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool NeedsArp(void) const
void SetGenericPhyTxStartCallback(GenericPhyTxStartCallback c)
set the callback used to instruct the lower layer to start a TX
Forward calls to a chain of Callback.
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
Tx Drop trace.
State m_state
State of the NetDevice.
virtual Ptr< Channel > GetChannel(void) const
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
Promiscuous Rx trace.
Ptr< Queue< Packet > > m_queue
packet queue
virtual void AddLinkChangeCallback(Callback< void > callback)
Ptr< Object > m_phy
PHY object.
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
a polymophic address class
Definition: address.h:90
phy
Definition: third.py:86
void NotifyReceptionEndOk(Ptr< Packet > p)
Notify the MAC that the PHY finished a reception successfully.
GenericPhyTxStartCallback m_phyMacTxStartCallback
Tx Start callback.
virtual Address GetAddress(void) const
uint32_t m_mtu
NetDevice MTU.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Ptr< Node > m_node
Node owning this NetDevice.
virtual void SetQueue(Ptr< Queue< Packet > > queue)
set the queue which is going to be used by this device
void NotifyTransmissionEnd(Ptr< const Packet >)
Notify the MAC that the PHY has finished a previously started transmission.
virtual bool SetMtu(const uint16_t mtu)
virtual uint32_t GetIfIndex(void) const
virtual void DoDispose(void)
Destructor implementation.
TracedCallback< Ptr< const Packet > > m_macRxTrace
Rx trace.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
Definition: net-device.h:343
virtual uint16_t GetMtu(void) const
TracedCallback< Ptr< const Packet > > m_macTxTrace
Tx trace.
void SetChannel(Ptr< Channel > c)
This class doesn&#39;t talk directly with the underlying channel (a dedicated PHY class is expected to do...
address
Definition: first.py:37
static TypeId GetTypeId(void)
Get the type ID.
void StartTransmission()
start the transmission of a packet by contacting the PHY layer
State
State of the NetDevice.
an EUI-48 address
Definition: mac48-address.h:43
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual Ptr< Node > GetNode(void) const
This devices implements the following features:
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promiscuous Rx callback.
void NotifyReceptionEndError()
Notify the MAC that the PHY finished a reception with an error.
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Ptr< Packet > m_currentPkt
Current packet.
Network layer to device interface.
Definition: net-device.h:95
void SetPhy(Ptr< Object > phy)
Set the Phy object which is attached to this device.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual bool IsLinkUp(void) const
void NotifyGuardIntervalEnd()
Notification of Guard Interval end.
virtual Address GetBroadcast(void) const
Ptr< Channel > m_channel
Channel.
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual void SetNode(Ptr< Node > node)
virtual bool SupportsSendFrom(void) const
bool m_linkUp
true if the link is up
NetDevice::ReceiveCallback m_rxCallback
Rx callback.
uint32_t m_ifIndex
Interface index.
virtual bool IsMulticast(void) const
virtual void SetAddress(Address address)
Set the address of this interface.