A Discrete-Event Network Simulator
API
mesh-point-device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008,2009 IITP RAS
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Kirill Andreev <andreev@iitp.ru>
18  * Pavel Boyko <boyko@iitp.ru>
19  */
20 
21 #ifndef L2ROUTING_NET_DEVICE_H
22 #define L2ROUTING_NET_DEVICE_H
23 
25 
26 #include "ns3/bridge-channel.h"
27 #include "ns3/mac48-address.h"
28 #include "ns3/net-device.h"
29 #include "ns3/node.h"
30 #include "ns3/random-variable-stream.h"
31 
32 namespace ns3
33 {
34 
53 class MeshPointDevice : public NetDevice
54 {
55  public:
60  static TypeId GetTypeId();
64  ~MeshPointDevice() override;
65 
68 
79  uint32_t GetNInterfaces() const;
84  Ptr<NetDevice> GetInterface(uint32_t id) const;
88  std::vector<Ptr<NetDevice>> GetInterfaces() const;
90 
93 
106 
107  // Inherited from NetDevice
108  void SetIfIndex(const uint32_t index) override;
109  uint32_t GetIfIndex() const override;
110  Ptr<Channel> GetChannel() const override;
111  Address GetAddress() const override;
112  void SetAddress(Address a) override;
113  bool SetMtu(const uint16_t mtu) override;
114  uint16_t GetMtu() const override;
115  bool IsLinkUp() const override;
116  void AddLinkChangeCallback(Callback<void> callback) override;
117  bool IsBroadcast() const override;
118  Address GetBroadcast() const override;
119  bool IsMulticast() const override;
120  Address GetMulticast(Ipv4Address multicastGroup) const override;
121  bool IsPointToPoint() const override;
122  bool IsBridge() const override;
123  bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
124  bool SendFrom(Ptr<Packet> packet,
125  const Address& source,
126  const Address& dest,
127  uint16_t protocolNumber) override;
128  Ptr<Node> GetNode() const override;
129  void SetNode(Ptr<Node> node) override;
130  bool NeedsArp() const override;
133  bool SupportsSendFrom() const override;
134  Address GetMulticast(Ipv6Address addr) const override;
135  void DoDispose() override;
136 
139 
143  void Report(std::ostream& os) const;
145  void ResetStats();
147 
156  int64_t AssignStreams(int64_t stream);
157 
164  Time GetForwardingDelay() const;
165 
166  private:
177  void ReceiveFromDevice(Ptr<NetDevice> device,
178  Ptr<const Packet> packet,
179  uint16_t protocol,
180  const Address& source,
181  const Address& destination,
182  PacketType packetType);
192  void Forward(Ptr<NetDevice> incomingPort,
193  Ptr<const Packet> packet,
194  uint16_t protocol,
195  const Mac48Address src,
196  const Mac48Address dst);
209  void DoSend(bool success,
210  Ptr<Packet> packet,
211  Mac48Address src,
212  Mac48Address dst,
213  uint16_t protocol,
214  uint32_t iface);
215 
216  private:
226  std::vector<Ptr<NetDevice>> m_ifaces;
228  uint32_t m_ifIndex;
230  uint16_t m_mtu;
237 
239  struct Statistics
240  {
241  uint32_t unicastData;
242  uint32_t unicastDataBytes;
243  uint32_t broadcastData;
245 
247  Statistics();
248  };
249 
250  // Counters
254 };
255 } // namespace ns3
256 #endif
a polymophic address class
Definition: address.h:101
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
an EUI-48 address
Definition: mac48-address.h:46
Virtual net device modeling mesh point.
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
Ptr< Node > GetNode() const override
void DoSend(bool success, Ptr< Packet > packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t iface)
Response callback for L2 routing protocol.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
uint32_t m_ifIndex
If index.
void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb) override
uint16_t m_mtu
MTU in bytes.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
Ptr< Node > m_node
Parent node.
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used.
void SetIfIndex(const uint32_t index) override
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void DoDispose() override
Destructor implementation.
bool SupportsSendFrom() const override
Ptr< Channel > GetChannel() const override
Ptr< RandomVariableStream > m_forwardingRandomVariable
Random variable used for forwarding delay and jitter.
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
void SetAddress(Address a) override
Set the address of this interface.
Ptr< NetDevice > GetInterface(uint32_t id) const
NetDevice::ReceiveCallback m_rxCallback
Receive action.
bool IsMulticast() const override
Statistics m_fwdStats
forward statistics
std::vector< Ptr< NetDevice > > GetInterfaces() const
void AddLinkChangeCallback(Callback< void > callback) override
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
std::vector< Ptr< NetDevice > > m_ifaces
List of interfaces.
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
bool IsLinkUp() const override
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
Receive packet from interface.
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
static TypeId GetTypeId()
Get the type ID.
uint16_t GetMtu() const override
bool IsBroadcast() const override
void Report(std::ostream &os) const
Print statistics counters.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promisc receive action.
Statistics m_rxStats
receive statistics
bool IsBridge() const override
Return true if the net device is acting as a bridge.
uint32_t GetIfIndex() const override
bool SetMtu(const uint16_t mtu) override
void SetNode(Ptr< Node > node) override
Statistics m_txStats
transmit statistics
Mac48Address m_address
Mesh point MAC address, supposed to be the address of the first added interface.
Address GetAddress() const override
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.
uint32_t GetNInterfaces() const
Address GetBroadcast() const override
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.
~MeshPointDevice() override
D-tor.
bool NeedsArp() const override
Network layer to device interface.
Definition: net-device.h:98
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:300
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
uint16_t port
Definition: dsdv-manet.cc:44
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