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/node.h"
26 #include "ns3/net-device.h"
27 #include "ns3/mac48-address.h"
28 #include "ns3/bridge-channel.h"
29 #include "ns3/mesh-l2-routing-protocol.h"
30 
31 namespace ns3 {
32 
49 class MeshPointDevice : public NetDevice
50 {
51 public:
56  static TypeId GetTypeId ();
58  MeshPointDevice ();
60  virtual ~MeshPointDevice ();
61 
63  //\{
74  uint32_t GetNInterfaces () const;
79  Ptr<NetDevice> GetInterface (uint32_t id) const;
83  std::vector<Ptr<NetDevice> > GetInterfaces () const;
84  //\}
85 
87  //\{
92  //\}
93 
94  // Inherited from NetDevice
95  virtual void SetIfIndex (const uint32_t index);
96  virtual uint32_t GetIfIndex () const;
97  virtual Ptr<Channel> GetChannel () const;
98  virtual Address GetAddress () const;
99  virtual void SetAddress (Address a);
100  virtual bool SetMtu (const uint16_t mtu);
101  virtual uint16_t GetMtu () const;
102  virtual bool IsLinkUp () const;
103  virtual void AddLinkChangeCallback (Callback<void> callback);
104  virtual bool IsBroadcast () const;
105  virtual Address GetBroadcast () const;
106  virtual bool IsMulticast () const;
107  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
108  virtual bool IsPointToPoint () const;
109  virtual bool IsBridge () const;
110  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
111  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
112  virtual Ptr<Node> GetNode () const;
113  virtual void SetNode (Ptr<Node> node);
114  virtual bool NeedsArp () const;
117  virtual bool SupportsSendFrom () const;
118  virtual Address GetMulticast (Ipv6Address addr) const;
119  virtual void DoDispose ();
120 
122  //\{
124  void Report (std::ostream & os) const;
126  void ResetStats ();
127  //\}
128 
129 private:
140  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
141  Address const &source, Address const &destination, PacketType packetType);
151  void Forward (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
152  uint16_t protocol, const Mac48Address src,
153  const Mac48Address dst);
165  void
166  DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol,
167  uint32_t iface);
168 
169 private:
179  std::vector< Ptr<NetDevice> > m_ifaces;
181  uint32_t m_ifIndex;
183  uint16_t m_mtu;
188 
190  struct Statistics
191  {
192  uint32_t unicastData;
193  uint32_t unicastDataBytes;
194  uint32_t broadcastData;
196 
198  Statistics ();
199  };
204 };
205 } // namespace ns3
206 #endif
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
Ptr< MeshL2RoutingProtocol > GetRoutingProtocol() const
Access current routing protocol.
uint32_t GetNInterfaces() const
NetDevice::ReceiveCallback m_rxCallback
Receive action.
void ResetStats()
Reset statistics counters.
virtual bool SetMtu(const uint16_t mtu)
virtual ~MeshPointDevice()
D-tor.
virtual Ptr< Node > GetNode() const
virtual void AddLinkChangeCallback(Callback< void > callback)
Statistics m_txStats
transmit statistics
virtual bool IsLinkUp() const
Ptr< MeshL2RoutingProtocol > m_routingProtocol
Current routing protocol, used mainly by GetRoutingProtocol.
virtual void DoDispose()
Destructor implementation.
virtual bool NeedsArp() const
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
uint16_t port
Definition: dsdv-manet.cc:45
a polymophic address class
Definition: address.h:90
virtual void SetAddress(Address a)
Set the address of this interface.
virtual bool IsBroadcast() const
virtual bool IsBridge() const
Return true if the net device is acting as a bridge.
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used. Protocol must be already installed on this mesh point...
Statistics m_rxStats
Counters.
virtual bool SupportsSendFrom() const
virtual Address GetAddress() const
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
virtual Address GetBroadcast() const
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
uint32_t broadcastDataBytes
broadcast data bytes
virtual void SetNode(Ptr< Node > node)
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 uint32_t GetIfIndex() const
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
std::vector< Ptr< NetDevice > > GetInterfaces() const
an EUI-48 address
Definition: mac48-address.h:43
Statistics m_fwdStats
forward statistics
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.
uint32_t unicastDataBytes
unicast data bytes
virtual Ptr< Channel > GetChannel() const
static TypeId GetTypeId()
Get the type ID.
Virtual net device modeling mesh point.
uint32_t m_ifIndex
If index.
uint32_t broadcastData
broadcast data
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
virtual uint16_t GetMtu() const
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Network layer to device interface.
Definition: net-device.h:95
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)
Ptr< NetDevice > GetInterface(uint32_t id) const
void Report(std::ostream &os) const
Print statistics counters.
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:296
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
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 IsMulticast() const