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 
64 
74  uint32_t GetNInterfaces () const;
79  Ptr<NetDevice> GetInterface (uint32_t id) const;
83  std::vector<Ptr<NetDevice> > GetInterfaces () const;
85 
86 
89 
102 
103  // Inherited from NetDevice
104  virtual void SetIfIndex (const uint32_t index);
105  virtual uint32_t GetIfIndex () const;
106  virtual Ptr<Channel> GetChannel () const;
107  virtual Address GetAddress () const;
108  virtual void SetAddress (Address a);
109  virtual bool SetMtu (const uint16_t mtu);
110  virtual uint16_t GetMtu () const;
111  virtual bool IsLinkUp () const;
112  virtual void AddLinkChangeCallback (Callback<void> callback);
113  virtual bool IsBroadcast () const;
114  virtual Address GetBroadcast () const;
115  virtual bool IsMulticast () const;
116  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
117  virtual bool IsPointToPoint () const;
118  virtual bool IsBridge () const;
119  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
120  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
121  virtual Ptr<Node> GetNode () const;
122  virtual void SetNode (Ptr<Node> node);
123  virtual bool NeedsArp () const;
126  virtual bool SupportsSendFrom () const;
127  virtual Address GetMulticast (Ipv6Address addr) const;
128  virtual void DoDispose ();
129 
132 
136  void Report (std::ostream & os) const;
138  void ResetStats ();
140 
141 private:
152  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
153  Address const &source, Address const &destination, PacketType packetType);
163  void Forward (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
164  uint16_t protocol, const Mac48Address src,
165  const Mac48Address dst);
177  void
178  DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol,
179  uint32_t iface);
180 
181 private:
191  std::vector< Ptr<NetDevice> > m_ifaces;
193  uint32_t m_ifIndex;
195  uint16_t m_mtu;
200 
202  struct Statistics
203  {
204  uint32_t unicastData;
205  uint32_t unicastDataBytes;
206  uint32_t broadcastData;
208 
210  Statistics ();
211  };
212  // Counters
216 };
217 } // namespace ns3
218 #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.
Statistics m_rxStats
receive statistics
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:41
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