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 #include "ns3/random-variable-stream.h"
31 
32 namespace ns3 {
33 
50 class MeshPointDevice : public NetDevice
51 {
52 public:
57  static TypeId GetTypeId ();
59  MeshPointDevice ();
61  virtual ~MeshPointDevice ();
62 
65 
75  uint32_t GetNInterfaces () const;
80  Ptr<NetDevice> GetInterface (uint32_t id) const;
84  std::vector<Ptr<NetDevice> > GetInterfaces () const;
86 
87 
90 
103 
104  // Inherited from NetDevice
105  virtual void SetIfIndex (const uint32_t index);
106  virtual uint32_t GetIfIndex () const;
107  virtual Ptr<Channel> GetChannel () const;
108  virtual Address GetAddress () const;
109  virtual void SetAddress (Address a);
110  virtual bool SetMtu (const uint16_t mtu);
111  virtual uint16_t GetMtu () const;
112  virtual bool IsLinkUp () const;
113  virtual void AddLinkChangeCallback (Callback<void> callback);
114  virtual bool IsBroadcast () const;
115  virtual Address GetBroadcast () const;
116  virtual bool IsMulticast () const;
117  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
118  virtual bool IsPointToPoint () const;
119  virtual bool IsBridge () const;
120  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
121  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
122  virtual Ptr<Node> GetNode () const;
123  virtual void SetNode (Ptr<Node> node);
124  virtual bool NeedsArp () const;
127  virtual bool SupportsSendFrom () const;
128  virtual Address GetMulticast (Ipv6Address addr) const;
129  virtual void DoDispose ();
130 
133 
137  void Report (std::ostream & os) const;
139  void ResetStats ();
141 
150  int64_t AssignStreams (int64_t stream);
151 
158  Time GetForwardingDelay () const;
159 
160 private:
171  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
172  Address const &source, Address const &destination, PacketType packetType);
182  void Forward (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
183  uint16_t protocol, const Mac48Address src,
184  const Mac48Address dst);
196  void
197  DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol,
198  uint32_t iface);
199 
200 private:
210  std::vector< Ptr<NetDevice> > m_ifaces;
212  uint32_t m_ifIndex;
214  uint16_t m_mtu;
221 
223  struct Statistics
224  {
225  uint32_t unicastData;
226  uint32_t unicastDataBytes;
227  uint32_t broadcastData;
229 
231  Statistics ();
232  };
233  // Counters
237 };
238 } // namespace ns3
239 #endif
a polymophic address class
Definition: address.h:91
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Describes an IPv6 address.
Definition: ipv6-address.h:50
an EUI-48 address
Definition: mac48-address.h:44
Virtual net device modeling mesh point.
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
void DoSend(bool success, Ptr< Packet > packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t iface)
Response callback for L2 routing protocol.
virtual bool IsLinkUp() const
virtual Ptr< Channel > GetChannel() const
virtual bool NeedsArp() const
virtual bool IsPointToPoint() const
Return true if the net device is on a point-to-point link.
uint32_t m_ifIndex
If index.
virtual bool IsBridge() const
Return true if the net device is acting as a bridge.
virtual bool IsBroadcast() const
uint16_t m_mtu
MTU in bytes.
Ptr< Node > m_node
Parent node.
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used.
virtual bool IsMulticast() const
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Ptr< RandomVariableStream > m_forwardingRandomVariable
Random variable used for forwarding delay and jitter.
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, PacketType packetType)
Receive packet from interface.
virtual bool SetMtu(const uint16_t mtu)
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
virtual uint32_t GetIfIndex() const
virtual void SetIfIndex(const uint32_t index)
std::vector< Ptr< NetDevice > > m_ifaces
List of interfaces.
Ptr< NetDevice > GetInterface(uint32_t id) const
virtual void DoDispose()
Destructor implementation.
NetDevice::ReceiveCallback m_rxCallback
Receive action.
Statistics m_fwdStats
forward statistics
std::vector< Ptr< NetDevice > > GetInterfaces() const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
virtual ~MeshPointDevice()
D-tor.
static TypeId GetTypeId()
Get the type ID.
void Report(std::ostream &os) const
Print statistics counters.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promisc receive action.
virtual Address GetAddress() const
Statistics m_rxStats
receive statistics
virtual Ptr< Node > GetNode() const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Statistics m_txStats
transmit statistics
Mac48Address m_address
Mesh point MAC address, supposed to be the address of the first added interface.
virtual void SetNode(Ptr< Node > node)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< MeshL2RoutingProtocol > m_routingProtocol
Current routing protocol, used mainly by GetRoutingProtocol.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
uint32_t GetNInterfaces() const
virtual uint16_t GetMtu() const
virtual void SetAddress(Address a)
Set the address of this interface.
virtual Address GetBroadcast() const
void ResetStats()
Reset statistics counters.
Time GetForwardingDelay() const
Return a (random) forwarding delay value from the random variable ForwardingDelay attribute.
Ptr< MeshL2RoutingProtocol > GetRoutingProtocol() const
Access current routing protocol.
virtual bool SupportsSendFrom() const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void AddLinkChangeCallback(Callback< void > callback)
Network layer to device interface.
Definition: net-device.h:96
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:297
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
uint16_t port
Definition: dsdv-manet.cc:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t broadcastData
broadcast data
uint32_t unicastDataBytes
unicast data bytes
uint32_t broadcastDataBytes
broadcast data bytes