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
ns3::MeshPointDevice
Virtual net device modeling mesh point.
Definition: mesh-point-device.h:50
ns3::MeshPointDevice::IsPointToPoint
virtual bool IsPointToPoint() const
Return true if the net device is on a point-to-point link.
Definition: mesh-point-device.cc:246
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::MeshPointDevice::m_promiscRxCallback
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promisc receive action.
Definition: mesh-point-device.h:185
ns3::MeshPointDevice::GetAddress
virtual Address GetAddress() const
Definition: mesh-point-device.cc:172
ns3::MeshPointDevice::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition: mesh-point-device.cc:73
ns3::MeshPointDevice::Statistics
statistics counters
Definition: mesh-point-device.h:203
ns3::MeshPointDevice::SetMtu
virtual bool SetMtu(const uint16_t mtu)
Definition: mesh-point-device.cc:187
ns3::MeshPointDevice::m_node
Ptr< Node > m_node
Parent node.
Definition: mesh-point-device.h:189
ns3::Callback< void >
ns3::MeshPointDevice::ResetStats
void ResetStats()
Reset statistics counters.
Definition: mesh-point-device.cc:482
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MeshPointDevice::MeshPointDevice
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
Definition: mesh-point-device.cc:57
ns3::MeshPointDevice::IsBroadcast
virtual bool IsBroadcast() const
Definition: mesh-point-device.cc:217
ns3::MeshPointDevice::SetPromiscReceiveCallback
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Definition: mesh-point-device.cc:308
ns3::MeshPointDevice::m_routingProtocol
Ptr< MeshL2RoutingProtocol > m_routingProtocol
Current routing protocol, used mainly by GetRoutingProtocol.
Definition: mesh-point-device.h:199
ns3::MeshPointDevice::IsLinkUp
virtual bool IsLinkUp() const
Definition: mesh-point-device.cc:202
ns3::MeshPointDevice::Statistics::unicastData
uint32_t unicastData
unicast data
Definition: mesh-point-device.h:204
ns3::MeshPointDevice::SetReceiveCallback
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Definition: mesh-point-device.cc:301
ns3::MeshPointDevice::GetMtu
virtual uint16_t GetMtu() const
Definition: mesh-point-device.cc:195
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::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::MeshPointDevice::m_ifIndex
uint32_t m_ifIndex
If index.
Definition: mesh-point-device.h:193
ns3::MeshPointDevice::DoSend
void DoSend(bool success, Ptr< Packet > packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t iface)
Response callback for L2 routing protocol.
Definition: mesh-point-device.cc:418
ns3::MeshPointDevice::Statistics::Statistics
Statistics()
constructor
Definition: mesh-point-device.cc:455
ns3::MeshPointDevice::SetAddress
virtual void SetAddress(Address a)
Set the address of this interface.
Definition: mesh-point-device.cc:179
ns3::MeshPointDevice::ReceiveFromDevice
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, PacketType packetType)
Receive packet from interface.
Definition: mesh-point-device.cc:93
ns3::MeshPointDevice::GetBroadcast
virtual Address GetBroadcast() const
Definition: mesh-point-device.cc:224
ns3::MeshPointDevice::m_rxStats
Statistics m_rxStats
receive statistics
Definition: mesh-point-device.h:213
ns3::MeshPointDevice::m_txStats
Statistics m_txStats
transmit statistics
Definition: mesh-point-device.h:214
ns3::MeshPointDevice::SetNode
virtual void SetNode(Ptr< Node > node)
Definition: mesh-point-device.cc:287
ns3::MeshPointDevice::m_channel
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
Definition: mesh-point-device.h:197
ns3::Ptr< NetDevice >
ns3::MeshPointDevice::GetNode
virtual Ptr< Node > GetNode() const
Definition: mesh-point-device.cc:280
ns3::MeshPointDevice::m_ifaces
std::vector< Ptr< NetDevice > > m_ifaces
List of interfaces.
Definition: mesh-point-device.h:191
ns3::MeshPointDevice::Statistics::broadcastDataBytes
uint32_t broadcastDataBytes
broadcast data bytes
Definition: mesh-point-device.h:207
ns3::MeshPointDevice::GetInterfaces
std::vector< Ptr< NetDevice > > GetInterfaces() const
Definition: mesh-point-device.cc:353
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::MeshPointDevice::SetIfIndex
virtual void SetIfIndex(const uint32_t index)
Definition: mesh-point-device.cc:151
ns3::MeshPointDevice::m_fwdStats
Statistics m_fwdStats
forward statistics
Definition: mesh-point-device.h:215
ns3::MeshPointDevice::SupportsSendFrom
virtual bool SupportsSendFrom() const
Definition: mesh-point-device.cc:315
ns3::MeshPointDevice::GetNInterfaces
uint32_t GetNInterfaces() const
Definition: mesh-point-device.cc:332
ns3::MeshPointDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition: mesh-point-device.cc:260
ns3::MeshPointDevice::~MeshPointDevice
virtual ~MeshPointDevice()
D-tor.
Definition: mesh-point-device.cc:64
ns3::MeshPointDevice::Statistics::unicastDataBytes
uint32_t unicastDataBytes
unicast data bytes
Definition: mesh-point-device.h:205
ns3::MeshPointDevice::GetIfIndex
virtual uint32_t GetIfIndex() const
Definition: mesh-point-device.cc:158
ns3::MeshPointDevice::GetMulticast
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Definition: mesh-point-device.cc:238
ns3::MeshPointDevice::m_rxCallback
NetDevice::ReceiveCallback m_rxCallback
Receive action.
Definition: mesh-point-device.h:183
ns3::MeshPointDevice::m_mtu
uint16_t m_mtu
MTU in bytes.
Definition: mesh-point-device.h:195
ns3::MeshPointDevice::NeedsArp
virtual bool NeedsArp() const
Definition: mesh-point-device.cc:294
ns3::MeshPointDevice::AddInterface
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
Definition: mesh-point-device.cc:358
ns3::MeshPointDevice::SendFrom
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Definition: mesh-point-device.cc:269
ns3::MeshPointDevice::IsBridge
virtual bool IsBridge() const
Return true if the net device is acting as a bridge.
Definition: mesh-point-device.cc:253
ns3::MeshPointDevice::SetRoutingProtocol
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used.
Definition: mesh-point-device.cc:402
ns3::MeshPointDevice::Statistics::broadcastData
uint32_t broadcastData
broadcast data
Definition: mesh-point-device.h:206
ns3::MeshPointDevice::m_address
Mac48Address m_address
Mesh point MAC address, supposed to be the address of the first added interface.
Definition: mesh-point-device.h:187
ns3::NetDevice::PacketType
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:297
ns3::MeshPointDevice::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition: mesh-point-device.cc:36
ns3::MeshPointDevice::Report
void Report(std::ostream &os) const
Print statistics counters.
Definition: mesh-point-device.cc:462
ns3::MeshPointDevice::GetRoutingProtocol
Ptr< MeshL2RoutingProtocol > GetRoutingProtocol() const
Access current routing protocol.
Definition: mesh-point-device.cc:411
ns3::MeshPointDevice::IsMulticast
virtual bool IsMulticast() const
Definition: mesh-point-device.cc:231
ns3::MeshPointDevice::GetInterface
Ptr< NetDevice > GetInterface(uint32_t id) const
Definition: mesh-point-device.cc:339
ns3::MeshPointDevice::AddLinkChangeCallback
virtual void AddLinkChangeCallback(Callback< void > callback)
Definition: mesh-point-device.cc:209
ns3::MeshPointDevice::Forward
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
Definition: mesh-point-device.cc:136
ns3::NetDevice
Network layer to device interface.
Definition: net-device.h:96
port
uint16_t port
Definition: dsdv-manet.cc:45
ns3::MeshPointDevice::GetChannel
virtual Ptr< Channel > GetChannel() const
Definition: mesh-point-device.cc:165