A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 class Queue;
43 
44 
45 
60 {
61 public:
62  enum State
63  {
65  };
66 
67  static TypeId GetTypeId (void);
68 
70  virtual ~AlohaNoackNetDevice ();
71 
72 
78  virtual void SetQueue (Ptr<Queue> queue);
79 
80 
86 
91  void NotifyReceptionStart ();
92 
93 
99 
106 
107 
117  void SetChannel (Ptr<Channel> c);
118 
119 
126 
127 
128 
140  void SetPhy (Ptr<Object> phy);
141 
145  Ptr<Object> GetPhy () const;
146 
147 
148 
149  // inherited from NetDevice
150  virtual void SetIfIndex (const uint32_t index);
151  virtual uint32_t GetIfIndex (void) const;
152  virtual Ptr<Channel> GetChannel (void) const;
153  virtual bool SetMtu (const uint16_t mtu);
154  virtual uint16_t GetMtu (void) const;
155  virtual void SetAddress (Address address);
156  virtual Address GetAddress (void) const;
157  virtual bool IsLinkUp (void) const;
158  virtual void AddLinkChangeCallback (Callback<void> callback);
159  virtual bool IsBroadcast (void) const;
160  virtual Address GetBroadcast (void) const;
161  virtual bool IsMulticast (void) const;
162  virtual bool IsPointToPoint (void) const;
163  virtual bool IsBridge (void) const;
164  virtual bool Send (Ptr<Packet> packet, const Address& dest,
165  uint16_t protocolNumber);
166  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest,
167  uint16_t protocolNumber);
168  virtual Ptr<Node> GetNode (void) const;
169  virtual void SetNode (Ptr<Node> node);
170  virtual bool NeedsArp (void) const;
172  virtual Address GetMulticast (Ipv4Address addr) const;
173  virtual Address GetMulticast (Ipv6Address addr) const;
175  virtual bool SupportsSendFrom (void) const;
176 
177 
178 
179 
180 
181 private:
182  void NotifyGuardIntervalEnd ();
183  virtual void DoDispose (void);
184 
189  void StartTransmission ();
190 
191 
193 
198 
201 
203 
206 
208 
213 
214 
215  uint32_t m_ifIndex;
216  mutable uint32_t m_mtu;
217  bool m_linkUp;
218 
219 
221 
223 
225 };
226 
227 
228 } // namespace ns3
229 
230 #endif /* ALOHA_NOACK_NET_DEVICE_H */
virtual void SetIfIndex(const uint32_t index)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
void NotifyReceptionStart()
Notify the MAC that the PHY has started a reception.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
void SetGenericPhyTxStartCallback(GenericPhyTxStartCallback c)
set the callback used to instruct the lower layer to start a TX
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual Address GetBroadcast(void) const
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
virtual void AddLinkChangeCallback(Callback< void > callback)
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
a polymophic address class
Definition: address.h:86
virtual Ptr< Node > GetNode(void) const
void NotifyReceptionEndOk(Ptr< Packet > p)
Notify the MAC that the PHY finished a reception successfully.
GenericPhyTxStartCallback m_phyMacTxStartCallback
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual uint16_t GetMtu(void) const
virtual bool IsBroadcast(void) const
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 void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
TracedCallback< Ptr< const Packet > > m_macRxTrace
virtual bool IsLinkUp(void) const
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
Definition: net-device.h:319
virtual bool SupportsSendFrom(void) const
TracedCallback< Ptr< const Packet > > m_macTxTrace
void SetChannel(Ptr< Channel > c)
This class doesn't talk directly with the underlying channel (a dedicated PHY class is expected to do...
void StartTransmission()
start the transmission of a packet by contacting the PHY layer
virtual bool NeedsArp(void) const
an EUI-48 address
Definition: mac48-address.h:41
Ptr< Object > GetPhy() const
virtual void SetQueue(Ptr< Queue > queue)
set the queue which is going to be used by this device
virtual bool IsMulticast(void) const
This devices implements the following features:
NetDevice::PromiscReceiveCallback m_promiscRxCallback
void NotifyReceptionEndError()
Notify the MAC that the PHY finished a reception with an error.
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Network layer to device interface.
Definition: net-device.h:75
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)
tuple address
Definition: first.py:37
a unique identifier for an interface.
Definition: type-id.h:49
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual uint32_t GetIfIndex(void) const
virtual void SetNode(Ptr< Node > node)
NetDevice::ReceiveCallback m_rxCallback
virtual Ptr< Channel > GetChannel(void) const
virtual Address GetAddress(void) const
virtual void SetAddress(Address address)
Set the address of this interface.