A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
24#include "ns3/bridge-channel.h"
25#include "ns3/mac48-address.h"
26#include "ns3/mesh-l2-routing-protocol.h"
27#include "ns3/net-device.h"
28#include "ns3/node.h"
29#include "ns3/random-variable-stream.h"
30
31namespace ns3
32{
33
53{
54 public:
59 static TypeId GetTypeId();
63 ~MeshPointDevice() override;
64
67
87 std::vector<Ptr<NetDevice>> GetInterfaces() const;
89
92
105
106 // Inherited from NetDevice
107 void SetIfIndex(const uint32_t index) override;
108 uint32_t GetIfIndex() const override;
109 Ptr<Channel> GetChannel() const override;
110 Address GetAddress() const override;
111 void SetAddress(Address a) override;
112 bool SetMtu(const uint16_t mtu) override;
113 uint16_t GetMtu() const override;
114 bool IsLinkUp() const override;
115 void AddLinkChangeCallback(Callback<void> callback) override;
116 bool IsBroadcast() const override;
117 Address GetBroadcast() const override;
118 bool IsMulticast() const override;
119 Address GetMulticast(Ipv4Address multicastGroup) const override;
120 bool IsPointToPoint() const override;
121 bool IsBridge() const override;
122 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
123 bool SendFrom(Ptr<Packet> packet,
124 const Address& source,
125 const Address& dest,
126 uint16_t protocolNumber) override;
127 Ptr<Node> GetNode() const override;
128 void SetNode(Ptr<Node> node) override;
129 bool NeedsArp() const override;
132 bool SupportsSendFrom() const override;
133 Address GetMulticast(Ipv6Address addr) const override;
134 void DoDispose() override;
135
138
142 void Report(std::ostream& os) const;
144 void ResetStats();
146
155 int64_t AssignStreams(int64_t stream);
156
163 Time GetForwardingDelay() const;
164
165 private:
177 Ptr<const Packet> packet,
178 uint16_t protocol,
179 const Address& source,
180 const Address& destination,
181 PacketType packetType);
191 void Forward(Ptr<NetDevice> incomingPort,
192 Ptr<const Packet> packet,
193 uint16_t protocol,
194 const Mac48Address src,
195 const Mac48Address dst);
208 void DoSend(bool success,
209 Ptr<Packet> packet,
210 Mac48Address src,
211 Mac48Address dst,
212 uint16_t protocol,
213 uint32_t iface);
214
215 private:
225 std::vector<Ptr<NetDevice>> m_ifaces;
229 uint16_t m_mtu;
236
239 {
244
246 Statistics();
247 };
248
249 // Counters
253};
254} // namespace ns3
255#endif
a polymophic address class
Definition: address.h:100
Callback template class.
Definition: callback.h:438
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:78
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