A Discrete-Event Network Simulator
API
mesh-point-device.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008,2009 IITP RAS
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  * Authors: Kirill Andreev <andreev@iitp.ru>
19  * Pavel Boyko <boyko@iitp.ru>
20  */
21 
22 #ifndef L2ROUTING_NET_DEVICE_H
23 #define L2ROUTING_NET_DEVICE_H
24 
25 #include "ns3/net-device.h"
26 #include "ns3/mac48-address.h"
27 #include "ns3/bridge-channel.h"
28 #include "ns3/mesh-l2-routing-protocol.h"
29 
30 namespace ns3 {
31 
32 class Node;
49 class MeshPointDevice : public NetDevice
50 {
51 public:
53  static TypeId GetTypeId ();
55  MeshPointDevice ();
57  virtual ~MeshPointDevice ();
58 
60  //\{
70  uint32_t GetNInterfaces () const;
75  Ptr<NetDevice> GetInterface (uint32_t id) const;
79  std::vector<Ptr<NetDevice> > GetInterfaces () const;
80  //\}
81 
83  //\{
88  //\}
89 
90  // Inherited from NetDevice
91  virtual void SetIfIndex (const uint32_t index);
92  virtual uint32_t GetIfIndex () const;
93  virtual Ptr<Channel> GetChannel () const;
94  virtual Address GetAddress () const;
95  virtual void SetAddress (Address a);
96  virtual bool SetMtu (const uint16_t mtu);
97  virtual uint16_t GetMtu () const;
98  virtual bool IsLinkUp () const;
99  virtual void AddLinkChangeCallback (Callback<void> callback);
100  virtual bool IsBroadcast () const;
101  virtual Address GetBroadcast () const;
102  virtual bool IsMulticast () const;
103  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
104  virtual bool IsPointToPoint () const;
105  virtual bool IsBridge () const;
106  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
107  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
108  virtual Ptr<Node> GetNode () const;
109  virtual void SetNode (Ptr<Node> node);
110  virtual bool NeedsArp () const;
113  virtual bool SupportsSendFrom () const;
114  virtual Address GetMulticast (Ipv6Address addr) const;
115  virtual void DoDispose ();
116 
118  //\{
120  void Report (std::ostream & os) const;
122  void ResetStats ();
123  //\}
124 
125 private:
127  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
128  Address const &source, Address const &destination, PacketType packetType);
130  void Forward (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
131  uint16_t protocol, const Mac48Address src,
132  const Mac48Address dst);
144  void
145  DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol,
146  uint32_t iface);
147 
148 private:
158  std::vector< Ptr<NetDevice> > m_ifaces;
160  uint32_t m_ifIndex;
162  uint16_t m_mtu;
167 
170  struct Statistics
171  {
172  uint32_t unicastData;
174  uint32_t broadcastData;
176 
177  Statistics ();
178  };
182 };
183 } // namespace ns3
184 #endif
uint32_t GetNInterfaces() const
Mac48Address m_address
Mesh point MAC address, supposed to be the address of the first added interface.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual bool IsBridge() const
Return true if the net device is acting as a bridge.
NetDevice::ReceiveCallback m_rxCallback
Receive action.
void ResetStats()
Reset statistics counters.
virtual bool IsBroadcast() const
virtual bool SetMtu(const uint16_t mtu)
virtual ~MeshPointDevice()
D-tor.
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:606
virtual void AddLinkChangeCallback(Callback< void > callback)
Statistics m_txStats
Counters.
virtual bool IsLinkUp() const
virtual bool IsMulticast() const
Ptr< MeshL2RoutingProtocol > m_routingProtocol
Current routing protocol, used mainly by GetRoutingProtocol.
virtual void DoDispose()
Destructor implementation.
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
virtual Address GetAddress() const
std::vector< Ptr< NetDevice > > GetInterfaces() const
virtual void SetAddress(Address a)
Set the address of this interface.
Ptr< NetDevice > GetInterface(uint32_t id) const
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used. Protocol must be already installed on this mesh point...
Statistics m_rxStats
Counters.
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
virtual uint32_t GetIfIndex() const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual Ptr< Node > GetNode() const
virtual uint16_t GetMtu() const
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
virtual void SetNode(Ptr< Node > node)
void Report(std::ostream &os) const
Print statistics counters.
uint16_t m_mtu
MTU in bytes.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
an EUI-48 address
Definition: mac48-address.h:43
Statistics m_fwdStats
Counters.
Ptr< Node > m_node
Parent node.
void DoSend(bool success, Ptr< Packet > packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t iface)
Response callback for L2 routing protocol.
virtual Address GetBroadcast() const
static TypeId GetTypeId()
Object type ID for NS3 object system.
virtual Ptr< Channel > GetChannel() const
Virtual net device modeling mesh point.
uint32_t m_ifIndex
If index.
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
Describes an IPv6 address.
Definition: ipv6-address.h:48
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Network layer to device interface.
Definition: net-device.h:405
virtual bool NeedsArp() const
virtual bool IsPointToPoint() const
Return true if the net device is on a point-to-point link.
std::vector< Ptr< NetDevice > > m_ifaces
List of interfaces.
virtual void SetIfIndex(const uint32_t index)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, PacketType packetType)
Receive packet from interface.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promisc receive action.
a unique identifier for an interface.
Definition: type-id.h:58
virtual bool SupportsSendFrom() const
Ptr< MeshL2RoutingProtocol > GetRoutingProtocol() const
Access current routing protocol.