author | Andrey Mazo <mazo@iitp.ru> |
Fri, 23 Apr 2010 15:09:31 +0400 | |
changeset 6273 | 8d70de29d514 |
parent 5167 | a3ede758b713 |
permissions | -rw-r--r-- |
4793 | 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 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4807
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4793 | 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 |
* |
|
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
18 |
* Authors: Kirill Andreev <andreev@iitp.ru> |
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
19 |
* Pavel Boyko <boyko@iitp.ru> |
4793 | 20 |
*/ |
21 |
||
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
22 |
#ifndef MESH_L2_ROUTING_PROTOCOL_H |
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
23 |
#define MESH_L2_ROUTING_PROTOCOL_H |
4793 | 24 |
|
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
25 |
#include "ns3/object.h" |
4793 | 26 |
#include "ns3/mac48-address.h" |
4985
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4933
diff
changeset
|
27 |
#include "ns3/packet.h" |
4793 | 28 |
|
5132
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
29 |
namespace ns3 { |
4793 | 30 |
|
31 |
class Packet; |
|
4816 | 32 |
class MeshPointDevice; |
33 |
||
4793 | 34 |
/** |
4807
a1f43e372f9f
1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents:
4793
diff
changeset
|
35 |
* \ingroup mesh |
4793 | 36 |
* |
5129 | 37 |
* \brief Interface for L2 mesh routing protocol and mesh point communication. |
4793 | 38 |
* |
4816 | 39 |
* Every mesh routing protocol must implement this interface. Each mesh point (MeshPointDevice) is supposed |
5129 | 40 |
* to know single L2RoutingProtocol to work with, see MeshPointDevice::SetRoutingProtocol (). |
41 |
* |
|
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
5167
diff
changeset
|
42 |
* This interface is similar to ipv4 routing protocol base class. |
4793 | 43 |
*/ |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
44 |
class MeshL2RoutingProtocol : public Object |
4793 | 45 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4807
diff
changeset
|
46 |
public: |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
47 |
/// Never forget to support NS3 object model |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
48 |
static TypeId GetTypeId (); |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
49 |
/// virtual D-tor for subclasses |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
50 |
virtual ~MeshL2RoutingProtocol (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4807
diff
changeset
|
51 |
/** |
4816 | 52 |
* Callback to be invoked when route discovery procedure is completed. |
5129 | 53 |
* |
54 |
* \param flag indicating whether a route was actually found and all needed information is |
|
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
5167
diff
changeset
|
55 |
* added to the packet successfully |
5129 | 56 |
* |
4816 | 57 |
* \param packet for which the route was resolved. All routing information for MAC layer |
5129 | 58 |
* must be stored in proper tags (like in case of HWMP, when WifiMacHeader |
4816 | 59 |
* needs address of next hop), or must be added as a packet header (if MAC |
5129 | 60 |
* does not need any additional information). So, the packet is returned back |
61 |
* to MeshPointDevice looks like a pure packet with ethernet header |
|
4816 | 62 |
* (i.e data + src +dst + protocol). The only special information addressed |
63 |
* to MeshPointDevice is an outcoming interface ID. |
|
5129 | 64 |
* |
4816 | 65 |
* \param src source address of the packet |
5129 | 66 |
* |
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
5167
diff
changeset
|
67 |
* \param dst destination address of the packet |
5129 | 68 |
* |
4816 | 69 |
* \param protocol ethernet 'Protocol' field, needed to form a proper MAC-layer header |
5129 | 70 |
* |
4816 | 71 |
* \param uint32_t outcoming interface to use or 0xffffffff if packet should be sent by ALL interfaces |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4807
diff
changeset
|
72 |
*/ |
4885
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
73 |
typedef Callback<void,/* return type */ |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
74 |
bool, /* flag */ |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
75 |
Ptr<Packet>, /* packet */ |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
76 |
Mac48Address,/* src */ |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
77 |
Mac48Address,/* dst */ |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
78 |
uint16_t, /* protocol */ |
5129 | 79 |
uint32_t /* out interface ID */ |
4816 | 80 |
> RouteReplyCallback; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4807
diff
changeset
|
81 |
/** |
4816 | 82 |
* Request routing information, all packets must go through this request. |
5129 | 83 |
* |
5063 | 84 |
* Note that route discovery works async. -- RequestRoute returns immediately, while |
85 |
* reply callback will be called when routing information will be available. |
|
4816 | 86 |
* \return true if valid route is already known |
4885
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
87 |
* \param sourceIface the incoming interface of the packet |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
88 |
* \param source source address |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
89 |
* \param destination destination address |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
90 |
* \param packet the packet to be resolved (needed the whole packet, because |
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
91 |
* routing information is added as tags or headers). The packet |
5129 | 92 |
* will be returned to reply callback. |
4885
2761d3e01723
HWMP rtable and tag added back to wscripts without any changes
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
93 |
* \param protocolType protocol ID, needed to form a proper MAC-layer header |
5129 | 94 |
* \param routeReply callback to be invoked after route discovery procedure, supposed |
5063 | 95 |
* to really send packet using routing information. |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4807
diff
changeset
|
96 |
*/ |
5129 | 97 |
virtual bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, Ptr< |
98 |
const Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply) = 0; |
|
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
99 |
/** |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
100 |
* \brief When packet is ready to go to upper layer, protocol must |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
101 |
* remove all its information: tags, header, etc. So, |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
102 |
* MeshPointDevice must call this method when passing a packet to |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
103 |
* upper layer. |
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
5167
diff
changeset
|
104 |
* \returns true if packet shall not be dropped, false otherwise. |
5167 | 105 |
* \param fromIface the incoming interface of the packet |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
106 |
* \param source source address |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
107 |
* \param destination destination address |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
108 |
* \param packet the packet to be handled |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
109 |
* \param protocolType protocol ID, needed to form a proper MAC-layer header |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
110 |
* \attention protocol type is passed by reference, because may be |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
111 |
* changed |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
112 |
*/ |
5129 | 113 |
virtual bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< |
114 |
Packet> packet, uint16_t & protocolType) = 0; |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
115 |
/// Set host mesh point, analog of SetNode (...) methods for upper layer protocols. |
5129 | 116 |
void |
117 |
SetMeshPoint (Ptr<MeshPointDevice> mp); |
|
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
118 |
/// Each mesh protocol must be installed on the mesh point to work. |
5129 | 119 |
Ptr<MeshPointDevice> |
120 |
GetMeshPoint () const; |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4807
diff
changeset
|
121 |
protected: |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
122 |
/// Host mesh point |
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4816
diff
changeset
|
123 |
Ptr<MeshPointDevice> m_mp; |
4793 | 124 |
}; |
125 |
}//namespace ns3 |
|
126 |
#endif |