A Discrete-Event Network Simulator
API
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) 2005,2006 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Modified by Emmanuelle Laprise to remove dependence on LLC headers
20  */
21 #ifndef NET_DEVICE_H
22 #define NET_DEVICE_H
23 
24 #include <stdint.h>
25 #include "ns3/callback.h"
26 #include "ns3/object.h"
27 #include "ns3/ptr.h"
28 #include "packet.h"
29 #include "address.h"
30 #include "ns3/ipv4-address.h"
31 #include "ns3/ipv6-address.h"
32 
33 namespace ns3 {
34 
35 class Node;
36 class Channel;
37 
95 class NetDevice : public Object
96 {
97 public:
102  static TypeId GetTypeId (void);
103  virtual ~NetDevice();
104 
108  virtual void SetIfIndex (const uint32_t index) = 0;
112  virtual uint32_t GetIfIndex (void) const = 0;
113 
114 
122  virtual Ptr<Channel> GetChannel (void) const = 0;
123 
128  virtual void SetAddress (Address address) = 0;
129 
133  virtual Address GetAddress (void) const = 0;
134 
141  virtual bool SetMtu (const uint16_t mtu) = 0;
148  virtual uint16_t GetMtu (void) const = 0;
152  virtual bool IsLinkUp (void) const = 0;
156  typedef void (* LinkChangeTracedCallback) (void);
165  virtual void AddLinkChangeCallback (Callback<void> callback) = 0;
170  virtual bool IsBroadcast (void) const = 0;
178  virtual Address GetBroadcast (void) const = 0;
179 
183  virtual bool IsMulticast (void) const = 0;
184 
212  virtual Address GetMulticast (Ipv4Address multicastGroup) const = 0;
213 
221  virtual Address GetMulticast (Ipv6Address addr) const = 0;
222 
228  virtual bool IsBridge (void) const = 0;
229 
235  virtual bool IsPointToPoint (void) const = 0;
248  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
262  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
271  virtual Ptr<Node> GetNode (void) const = 0;
272 
278  virtual void SetNode (Ptr<Node> node) = 0;
279 
286  virtual bool NeedsArp (void) const = 0;
287 
288 
297  {
306  };
307 
319 
327  virtual void SetReceiveCallback (ReceiveCallback cb) = 0;
328 
329 
344 
356 
360  virtual bool SupportsSendFrom (void) const = 0;
361 
362 };
363 
364 } // namespace ns3
365 
366 #endif /* NET_DEVICE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::NetDevice::PACKET_BROADCAST
@ PACKET_BROADCAST
Packet addressed to all.
Definition: net-device.h:300
ns3::NetDevice::IsMulticast
virtual bool IsMulticast(void) const =0
ns3::NetDevice::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: net-device.cc:30
ns3::NetDevice::LinkChangeTracedCallback
void(* LinkChangeTracedCallback)(void)
TracedCallback signature for link changed event.
Definition: net-device.h:156
ns3::NetDevice::NS3_PACKET_MULTICAST
@ NS3_PACKET_MULTICAST
Definition: net-device.h:303
ns3::Callback< void >
ns3::NetDevice::GetAddress
virtual Address GetAddress(void) const =0
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::NetDevice::SetIfIndex
virtual void SetIfIndex(const uint32_t index)=0
ns3::NetDevice::NS3_PACKET_HOST
@ NS3_PACKET_HOST
Definition: net-device.h:299
ns3::NetDevice::~NetDevice
virtual ~NetDevice()
Definition: net-device.cc:39
ns3::NetDevice::SetNode
virtual void SetNode(Ptr< Node > node)=0
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::NetDevice::PACKET_HOST
@ PACKET_HOST
Packet addressed oo us.
Definition: net-device.h:298
ns3::NetDevice::GetMtu
virtual uint16_t GetMtu(void) const =0
ns3::NetDevice::SendFrom
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)=0
ns3::NetDevice::SetReceiveCallback
virtual void SetReceiveCallback(ReceiveCallback cb)=0
ns3::NetDevice::IsPointToPoint
virtual bool IsPointToPoint(void) const =0
Return true if the net device is on a point-to-point link.
ns3::NetDevice::SetAddress
virtual void SetAddress(Address address)=0
Set the address of this interface.
ns3::Ptr< Channel >
ns3::NetDevice::SetMtu
virtual bool SetMtu(const uint16_t mtu)=0
address.h
ns3::NetDevice::IsLinkUp
virtual bool IsLinkUp(void) const =0
ns3::NetDevice::PACKET_OTHERHOST
@ PACKET_OTHERHOST
Packet addressed to someone else.
Definition: net-device.h:304
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::NetDevice::ReceiveCallback
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition: net-device.h:318
ns3::NetDevice::GetMulticast
virtual Address GetMulticast(Ipv6Address addr) const =0
Get the MAC multicast address corresponding to the IPv6 address provided.
ns3::NetDevice::NeedsArp
virtual bool NeedsArp(void) const =0
ns3::NetDevice::PromiscReceiveCallback
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
Definition: net-device.h:343
ns3::NetDevice::GetNode
virtual Ptr< Node > GetNode(void) const =0
first.address
address
Definition: first.py:44
ns3::NetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
ns3::NetDevice::GetChannel
virtual Ptr< Channel > GetChannel(void) const =0
ns3::NetDevice::GetMulticast
virtual Address GetMulticast(Ipv4Address multicastGroup) const =0
Make and return a MAC multicast address using the provided multicast group.
ns3::NetDevice::NS3_PACKET_OTHERHOST
@ NS3_PACKET_OTHERHOST
Definition: net-device.h:305
packet.h
ns3::NetDevice::AddLinkChangeCallback
virtual void AddLinkChangeCallback(Callback< void > callback)=0
ns3::NetDevice::IsBroadcast
virtual bool IsBroadcast(void) const =0
ns3::NetDevice::PacketType
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:297
ns3::NetDevice::GetBroadcast
virtual Address GetBroadcast(void) const =0
ns3::NetDevice::IsBridge
virtual bool IsBridge(void) const =0
Return true if the net device is acting as a bridge.
ns3::NetDevice::NS3_PACKET_BROADCAST
@ NS3_PACKET_BROADCAST
Definition: net-device.h:301
ns3::NetDevice::SupportsSendFrom
virtual bool SupportsSendFrom(void) const =0
ns3::NetDevice::GetIfIndex
virtual uint32_t GetIfIndex(void) const =0
ns3::NetDevice::SetPromiscReceiveCallback
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)=0
ns3::NetDevice
Network layer to device interface.
Definition: net-device.h:96
ns3::NetDevice::PACKET_MULTICAST
@ PACKET_MULTICAST
Packet addressed to multicast group.
Definition: net-device.h:302