A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
aloha-noack-net-device.h
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  {
64  IDLE, TX, RX
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 
192  Ptr<Queue> m_queue;
193 
194  TracedCallback<Ptr<const Packet> > m_macTxTrace;
195  TracedCallback<Ptr<const Packet> > m_macTxDropTrace;
196  TracedCallback<Ptr<const Packet> > m_macPromiscRxTrace;
197  TracedCallback<Ptr<const Packet> > m_macRxTrace;
198 
199  Ptr<Node> m_node;
200  Ptr<Channel> m_channel;
201 
202  Mac48Address m_address;
203 
204  NetDevice::ReceiveCallback m_rxCallback;
205  NetDevice::PromiscReceiveCallback m_promiscRxCallback;
206 
207  GenericPhyTxStartCallback m_phyMacTxStartCallback;
208 
213 
214 
215  uint32_t m_ifIndex;
216  mutable uint32_t m_mtu;
217  bool m_linkUp;
218 
219 
220  State m_state;
221 
222  Ptr<Packet> m_currentPkt;
223 
224  Ptr<Object> m_phy;
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:59
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)
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual Address GetBroadcast(void) const
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual void AddLinkChangeCallback(Callback< void > callback)
a polymophic address class
Definition: address.h:86
virtual Ptr< Node > GetNode(void) const
void NotifyReceptionEndOk(Ptr< Packet > p)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual uint16_t GetMtu(void) const
virtual bool IsBroadcast(void) const
void NotifyTransmissionEnd(Ptr< const Packet >)
virtual bool SetMtu(const uint16_t mtu)
virtual bool IsLinkUp(void) const
virtual bool SupportsSendFrom(void) const
void SetChannel(Ptr< Channel > c)
virtual bool NeedsArp(void) const
an EUI-48 address
Definition: mac48-address.h:41
Ptr< Object > GetPhy() const
virtual void SetQueue(Ptr< Queue > queue)
virtual bool IsMulticast(void) const
Describes an IPv6 address.
Definition: ipv6-address.h:44
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)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
a unique identifier for an interface.
Definition: type-id.h:44
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual uint32_t GetIfIndex(void) const
virtual void SetNode(Ptr< Node > node)
virtual Ptr< Channel > GetChannel(void) const
virtual Address GetAddress(void) const
virtual void SetAddress(Address address)