A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
mesh-l2-routing-protocol.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008,2009 IITP RAS
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Kirill Andreev <andreev@iitp.ru>
7
* Pavel Boyko <boyko@iitp.ru>
8
*/
9
10
#ifndef MESH_L2_ROUTING_PROTOCOL_H
11
#define MESH_L2_ROUTING_PROTOCOL_H
12
13
#include "ns3/mac48-address.h"
14
#include "ns3/object.h"
15
#include "ns3/packet.h"
16
17
namespace
ns3
18
{
19
20
class
Packet;
21
class
MeshPointDevice;
22
23
/**
24
* \ingroup mesh
25
*
26
* \brief Interface for L2 mesh routing protocol and mesh point communication.
27
*
28
* Every mesh routing protocol must implement this interface. Each mesh point (MeshPointDevice) is
29
* supposed to know single L2RoutingProtocol to work with, see MeshPointDevice::SetRoutingProtocol
30
* ().
31
*
32
* This interface is similar to ipv4 routing protocol base class.
33
*/
34
class
MeshL2RoutingProtocol
:
public
Object
35
{
36
public
:
37
/**
38
* \brief Get the type ID.
39
* \return the object TypeId
40
*/
41
static
TypeId
GetTypeId
();
42
/// virtual D-tor for subclasses
43
~MeshL2RoutingProtocol
()
override
;
44
/**
45
* Callback to be invoked when route discovery procedure is completed.
46
*
47
* \param flag indicating whether a route was actually found and all needed information
48
* is added to the packet successfully
49
*
50
* \param packet for which the route was resolved. All routing information for MAC layer
51
* must be stored in proper tags (like in case of HWMP, when WifiMacHeader
52
* needs address of next hop), or must be added as a packet header (if MAC
53
* does not need any additional information). So, the packet is returned back
54
* to MeshPointDevice looks like a pure packet with ethernet header
55
* (i.e data + src +dst + protocol). The only special information addressed
56
* to MeshPointDevice is an outcoming interface ID.
57
*
58
* \param src source address of the packet
59
*
60
* \param dst destination address of the packet
61
*
62
* \param protocol ethernet 'Protocol' field, needed to form a proper MAC-layer header
63
*
64
* \param uint32_t outcoming interface to use or 0xffffffff if packet should be sent by ALL
65
* interfaces
66
*/
67
typedef
Callback
<void,
/* return type */
68
bool,
/* flag */
69
Ptr<Packet>
,
/* packet */
70
Mac48Address
,
/* src */
71
Mac48Address
,
/* dst */
72
uint16_t,
/* protocol */
73
uint32_t
/* out interface ID */
74
>
75
RouteReplyCallback
;
76
/**
77
* Request routing information, all packets must go through this request.
78
*
79
* Note that route discovery works async. -- RequestRoute returns immediately, while
80
* reply callback will be called when routing information will be available.
81
* \return true if valid route is already known
82
* \param sourceIface the incoming interface of the packet
83
* \param source source address
84
* \param destination destination address
85
* \param packet the packet to be resolved (needed the whole packet, because
86
* routing information is added as tags or headers). The packet
87
* will be returned to reply callback.
88
* \param protocolType protocol ID, needed to form a proper MAC-layer header
89
* \param routeReply callback to be invoked after route discovery procedure, supposed
90
* to really send packet using routing information.
91
*/
92
virtual
bool
RequestRoute
(
uint32_t
sourceIface,
93
const
Mac48Address
source,
94
const
Mac48Address
destination,
95
Ptr<const Packet>
packet,
96
uint16_t protocolType,
97
RouteReplyCallback
routeReply) = 0;
98
/**
99
* \brief When packet is ready to go to upper layer, protocol must
100
* remove all its information: tags, header, etc. So,
101
* MeshPointDevice must call this method when passing a packet to
102
* upper layer.
103
* \returns true if packet shall not be dropped, false otherwise.
104
* \param fromIface the incoming interface of the packet
105
* \param source source address
106
* \param destination destination address
107
* \param packet the packet to be handled
108
* \param protocolType protocol ID, needed to form a proper MAC-layer header
109
* \attention protocol type is passed by reference, because may be
110
* changed
111
*/
112
virtual
bool
RemoveRoutingStuff
(
uint32_t
fromIface,
113
const
Mac48Address
source,
114
const
Mac48Address
destination,
115
Ptr<Packet>
packet,
116
uint16_t& protocolType) = 0;
117
/**
118
* Set host mesh point, analog of SetNode (...) methods for upper layer protocols.
119
*
120
* \param mp the mesh point device
121
*/
122
void
SetMeshPoint
(
Ptr<MeshPointDevice>
mp);
123
/**
124
* Each mesh protocol must be installed on the mesh point to work.
125
*
126
* \returns the mesh point device
127
*/
128
Ptr<MeshPointDevice>
GetMeshPoint
()
const
;
129
130
protected
:
131
/// Host mesh point
132
Ptr<MeshPointDevice>
m_mp
;
133
};
134
}
// namespace ns3
135
#endif
ns3::Callback
Callback template class.
Definition
callback.h:422
ns3::Mac48Address
an EUI-48 address
Definition
mac48-address.h:35
ns3::MeshL2RoutingProtocol
Interface for L2 mesh routing protocol and mesh point communication.
Definition
mesh-l2-routing-protocol.h:35
ns3::MeshL2RoutingProtocol::~MeshL2RoutingProtocol
~MeshL2RoutingProtocol() override
virtual D-tor for subclasses
Definition
mesh-l2-routing-protocol.cc:31
ns3::MeshL2RoutingProtocol::RouteReplyCallback
Callback< void, bool, Ptr< Packet >, Mac48Address, Mac48Address, uint16_t, uint32_t > RouteReplyCallback
Callback to be invoked when route discovery procedure is completed.
Definition
mesh-l2-routing-protocol.h:75
ns3::MeshL2RoutingProtocol::SetMeshPoint
void SetMeshPoint(Ptr< MeshPointDevice > mp)
Set host mesh point, analog of SetNode (...) methods for upper layer protocols.
Definition
mesh-l2-routing-protocol.cc:37
ns3::MeshL2RoutingProtocol::RequestRoute
virtual bool RequestRoute(uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, Ptr< const Packet > packet, uint16_t protocolType, RouteReplyCallback routeReply)=0
Request routing information, all packets must go through this request.
ns3::MeshL2RoutingProtocol::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
mesh-l2-routing-protocol.cc:24
ns3::MeshL2RoutingProtocol::GetMeshPoint
Ptr< MeshPointDevice > GetMeshPoint() const
Each mesh protocol must be installed on the mesh point to work.
Definition
mesh-l2-routing-protocol.cc:43
ns3::MeshL2RoutingProtocol::RemoveRoutingStuff
virtual bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType)=0
When packet is ready to go to upper layer, protocol must remove all its information: tags,...
ns3::MeshL2RoutingProtocol::m_mp
Ptr< MeshPointDevice > m_mp
Host mesh point.
Definition
mesh-l2-routing-protocol.h:132
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
mesh
model
mesh-l2-routing-protocol.h
Generated on Fri Nov 8 2024 13:59:04 for ns-3 by
1.11.0