A Discrete-Event Network Simulator
API
loopback-net-device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
19 #ifndef LOOPBACK_NET_DEVICE_H
20 #define LOOPBACK_NET_DEVICE_H
21 
22 #include "ns3/mac48-address.h"
23 #include "ns3/net-device.h"
24 
25 #include <stdint.h>
26 #include <string>
27 
28 namespace ns3
29 {
30 
31 class Node;
32 
44 {
45  public:
50  static TypeId GetTypeId();
52 
53  // inherited from NetDevice base class.
54  void SetIfIndex(const uint32_t index) override;
55  uint32_t GetIfIndex() const override;
56  Ptr<Channel> GetChannel() const override;
57  void SetAddress(Address address) override;
58  Address GetAddress() const override;
59  bool SetMtu(const uint16_t mtu) override;
60  uint16_t GetMtu() const override;
61  bool IsLinkUp() const override;
62  void AddLinkChangeCallback(Callback<void> callback) override;
63  bool IsBroadcast() const override;
64  Address GetBroadcast() const override;
65  bool IsMulticast() const override;
66  Address GetMulticast(Ipv4Address multicastGroup) const override;
67  bool IsPointToPoint() const override;
68  bool IsBridge() const override;
69  bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
70  bool SendFrom(Ptr<Packet> packet,
71  const Address& source,
72  const Address& dest,
73  uint16_t protocolNumber) override;
74  Ptr<Node> GetNode() const override;
75  void SetNode(Ptr<Node> node) override;
76  bool NeedsArp() const override;
78 
79  Address GetMulticast(Ipv6Address addr) const override;
80 
82  bool SupportsSendFrom() const override;
83 
84  protected:
85  void DoDispose() override;
86 
87  private:
96  void Receive(Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
97 
102 
108 
110  uint16_t m_mtu;
111  uint32_t m_ifIndex;
113 };
114 
115 } // namespace ns3
116 
117 #endif /* LOOPBACK_NET_DEVICE_H */
a polymophic address class
Definition: address.h:101
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
Virtual network interface that loops back any data sent to it to be immediately received on the same ...
static TypeId GetTypeId()
Get the type ID.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void DoDispose() override
Destructor implementation.
uint32_t m_ifIndex
interface index
bool IsMulticast() const override
void Receive(Ptr< Packet > packet, uint16_t protocol, Mac48Address to, Mac48Address from)
Receive a packet from tge Loopback NetDevice.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
bool NeedsArp() const override
Ptr< Node > GetNode() const override
uint16_t GetMtu() const override
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
Ptr< Node > m_node
the node this NetDevice is associated with
bool IsBroadcast() const override
void SetIfIndex(const uint32_t index) override
bool IsLinkUp() const override
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
Mac48Address m_address
NetDevice MAC address.
uint32_t GetIfIndex() const override
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
void AddLinkChangeCallback(Callback< void > callback) override
Address GetAddress() const override
bool SupportsSendFrom() const override
NetDevice::PromiscReceiveCallback m_promiscCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode.
uint16_t m_mtu
device MTU
void SetAddress(Address address) override
Set the address of this interface.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
Ptr< Channel > GetChannel() const override
bool SetMtu(const uint16_t mtu) override
Address GetBroadcast() const override
void SetNode(Ptr< Node > node) override
an EUI-48 address
Definition: mac48-address.h:46
Network layer to device interface.
Definition: net-device.h:98
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.