A Discrete-Event Network Simulator
API
aloha-noack-net-device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Nicola Baldo <nbaldo@cttc.es>
18  */
19 
20 #ifndef ALOHA_NOACK_NET_DEVICE_H
21 #define ALOHA_NOACK_NET_DEVICE_H
22 
23 #include "ns3/queue-fwd.h"
24 #include <ns3/address.h>
25 #include <ns3/callback.h>
26 #include <ns3/generic-phy.h>
27 #include <ns3/mac48-address.h>
28 #include <ns3/net-device.h>
29 #include <ns3/node.h>
30 #include <ns3/nstime.h>
31 #include <ns3/packet.h>
32 #include <ns3/ptr.h>
33 #include <ns3/traced-callback.h>
34 
35 #include <cstring>
36 
37 namespace ns3
38 {
39 
40 class SpectrumChannel;
41 class Channel;
42 class SpectrumErrorModel;
43 
58 {
59  public:
63  enum State
64  {
65  IDLE,
66  TX,
67  RX
68  };
69 
74  static TypeId GetTypeId();
75 
77  ~AlohaNoackNetDevice() override;
78 
84  virtual void SetQueue(Ptr<Queue<Packet>> queue);
85 
91 
96  void NotifyReceptionStart();
97 
103 
110 
120  void SetChannel(Ptr<Channel> c);
121 
128 
140  void SetPhy(Ptr<Object> phy);
141 
145  Ptr<Object> GetPhy() const;
146 
147  // inherited from NetDevice
148  void SetIfIndex(const uint32_t index) override;
149  uint32_t GetIfIndex() const override;
150  Ptr<Channel> GetChannel() const override;
151  bool SetMtu(const uint16_t mtu) override;
152  uint16_t GetMtu() const override;
153  void SetAddress(Address address) override;
154  Address GetAddress() const override;
155  bool IsLinkUp() const override;
156  void AddLinkChangeCallback(Callback<void> callback) override;
157  bool IsBroadcast() const override;
158  Address GetBroadcast() const override;
159  bool IsMulticast() const override;
160  bool IsPointToPoint() const override;
161  bool IsBridge() const override;
162  bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
163  bool SendFrom(Ptr<Packet> packet,
164  const Address& source,
165  const Address& dest,
166  uint16_t protocolNumber) override;
167  Ptr<Node> GetNode() const override;
168  void SetNode(Ptr<Node> node) override;
169  bool NeedsArp() const override;
171  Address GetMulticast(Ipv4Address addr) const override;
172  Address GetMulticast(Ipv6Address addr) const override;
174  bool SupportsSendFrom() const override;
175 
176  private:
181  void DoDispose() override;
182 
186  void StartTransmission();
187 
189 
194 
197 
199 
202 
204 
209 
210  uint32_t m_ifIndex;
211  mutable uint32_t m_mtu;
212  bool m_linkUp;
213 
217 };
218 
219 } // namespace ns3
220 
221 #endif /* ALOHA_NOACK_NET_DEVICE_H */
a polymophic address class
Definition: address.h:101
This devices implements the following features:
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
void NotifyReceptionEndError()
Notify the MAC that the PHY finished a reception with an error.
TracedCallback< Ptr< const Packet > > m_macRxTrace
Rx trace.
Ptr< Queue< Packet > > m_queue
packet queue
bool IsLinkUp() const override
void AddLinkChangeCallback(Callback< void > callback) override
Mac48Address m_address
MAC address.
Address GetAddress() const override
bool m_linkUp
true if the link is up
NetDevice::ReceiveCallback m_rxCallback
Rx callback.
void SetIfIndex(const uint32_t index) override
void StartTransmission()
start the transmission of a packet by contacting the PHY layer
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promiscuous Rx callback.
void NotifyReceptionStart()
Notify the MAC that the PHY has started a reception.
Ptr< Object > m_phy
PHY object.
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
void SetAddress(Address address) override
Set the address of this interface.
Ptr< Packet > m_currentPkt
Current packet.
Ptr< Channel > m_channel
Channel.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
Promiscuous Rx trace.
void NotifyGuardIntervalEnd()
Notification of Guard Interval end.
Ptr< Node > m_node
Node owning this NetDevice.
Ptr< Channel > GetChannel() const override
void SetGenericPhyTxStartCallback(GenericPhyTxStartCallback c)
set the callback used to instruct the lower layer to start a TX
Address GetBroadcast() const override
uint16_t GetMtu() const override
uint32_t GetIfIndex() const override
GenericPhyTxStartCallback m_phyMacTxStartCallback
Tx Start callback.
bool SupportsSendFrom() const override
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
static TypeId GetTypeId()
Get the type ID.
void NotifyTransmissionEnd(Ptr< const Packet >)
Notify the MAC that the PHY has finished a previously started transmission.
void SetChannel(Ptr< Channel > c)
This class doesn't talk directly with the underlying channel (a dedicated PHY class is expected to do...
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Address GetMulticast(Ipv4Address addr) const override
Make and return a MAC multicast address using the provided multicast group.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
State m_state
State of the NetDevice.
void SetNode(Ptr< Node > node) override
bool IsMulticast() const override
bool NeedsArp() const override
uint32_t m_ifIndex
Interface index.
void DoDispose() override
Destructor implementation.
bool IsBroadcast() const override
uint32_t m_mtu
NetDevice MTU.
void SetPhy(Ptr< Object > phy)
Set the Phy object which is attached to this device.
TracedCallback< Ptr< const Packet > > m_macTxTrace
Tx trace.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
void NotifyReceptionEndOk(Ptr< Packet > p)
Notify the MAC that the PHY finished a reception successfully.
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
Tx Drop trace.
State
State of the NetDevice.
bool SetMtu(const uint16_t mtu) override
virtual void SetQueue(Ptr< Queue< Packet >> queue)
set the queue which is going to be used by this device
Ptr< Node > GetNode() const override
bool IsBridge() const override
Return true if the net device is acting as a bridge.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
an EUI-48 address
Definition: mac48-address.h:46
Network layer to device interface.
Definition: net-device.h:98
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, PacketType > PromiscReceiveCallback
Definition: net-device.h:352
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Template class for packet Queues.
Definition: queue.h:268
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
phy
Definition: third.py:89