A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
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  */
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"
30 namespace ns3 {
32 class Node;
49 class MeshPointDevice : public NetDevice
50 {
51 public:
53  static TypeId GetTypeId ();
55  MeshPointDevice ();
57  virtual ~MeshPointDevice ();
60  //\{
66  void AddInterface (Ptr<NetDevice> port);
70  uint32_t GetNInterfaces () const;
75  Ptr<NetDevice> GetInterface (uint32_t id) const;
79  std::vector<Ptr<NetDevice> > GetInterfaces () const;
80  //\}
83  //\{
88  //\}
91  //\{
92  virtual void SetIfIndex (const uint32_t index);
93  virtual uint32_t GetIfIndex () const;
94  virtual Ptr<Channel> GetChannel () const;
95  virtual Address GetAddress () const;
96  virtual void SetAddress (Address a);
97  virtual bool SetMtu (const uint16_t mtu);
98  virtual uint16_t GetMtu () const;
99  virtual bool IsLinkUp () const;
100  virtual void AddLinkChangeCallback (Callback<void> callback);
101  virtual bool IsBroadcast () const;
102  virtual Address GetBroadcast () const;
103  virtual bool IsMulticast () const;
104  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
105  virtual bool IsPointToPoint () const;
106  virtual bool IsBridge () const;
107  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
108  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
109  virtual Ptr<Node> GetNode () const;
110  virtual void SetNode (Ptr<Node> node);
111  virtual bool NeedsArp () const;
114  virtual bool SupportsSendFrom () const;
115  virtual Address GetMulticast (Ipv6Address addr) const;
116  virtual void DoDispose ();
117  //\}
120  //\{
122  void Report (std::ostream & os) const;
124  void ResetStats ();
125  //\}
127 private:
129  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
130  Address const &source, Address const &destination, PacketType packetType);
132  void Forward (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
133  uint16_t protocol, const Mac48Address src,
134  const Mac48Address dst);
145  void
146  DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol,
147  uint32_t iface);
149 private:
159  std::vector< Ptr<NetDevice> > m_ifaces;
161  uint32_t m_ifIndex;
163  uint16_t m_mtu;
171  struct Statistics
172  {
173  uint32_t unicastData;
174  uint32_t unicastDataBytes;
175  uint32_t broadcastData;
176  uint32_t broadcastDataBytes;
178  Statistics ();
179  };
181  Statistics m_rxStats, m_txStats, m_fwdStats;
183 };
184 } // namespace ns3
185 #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:59
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()
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual bool IsLinkUp() const
virtual bool IsMulticast() const
Ptr< MeshL2RoutingProtocol > m_routingProtocol
Current routing protocol, used mainly by GetRoutingProtocol.
virtual void DoDispose()
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
a polymophic address class
Definition: address.h:86
virtual Address GetAddress() const
std::vector< Ptr< NetDevice > > GetInterfaces() const
virtual void SetAddress(Address a)
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
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. Interface must support 48-bit MAC address and SendFrom method...
virtual void SetNode(Ptr< Node > node)
void Report(std::ostream &os) const
Print statistics counters.
uint16_t m_mtu
MTU in bytes.
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:41
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. This will be executed when routing information is ready...
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.
C-tor create empty (without interfaces and protocols) mesh point.
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Network layer to device interface.
Definition: net-device.h:75
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:44
virtual bool SupportsSendFrom() const
Ptr< MeshL2RoutingProtocol > GetRoutingProtocol() const
Access current routing protocol.