src/devices/mesh/mesh-l2-routing-protocol.h
author Andrey Mazo <mazo@iitp.ru>
Fri, 23 Apr 2010 15:09:31 +0400
changeset 6273 8d70de29d514
parent 5167 a3ede758b713
permissions -rw-r--r--
spell check, mostly in comments.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     2
/*
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2008,2009 IITP RAS
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     4
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     8
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    13
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    20
 */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    24
4817
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4816
diff changeset
    25
#include "ns3/object.h"
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    28
5132
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    29
namespace ns3 {
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    30
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    31
class Packet;
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    32
class MeshPointDevice;
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    33
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    36
 *
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    37
 * \brief Interface for L2 mesh routing protocol and mesh point communication.
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    38
 *
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    39
 * Every mesh routing protocol must implement this interface. Each mesh point (MeshPointDevice) is supposed
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    40
 * to know single L2RoutingProtocol to work with, see MeshPointDevice::SetRoutingProtocol ().
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    43
 */
4817
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4816
diff changeset
    44
class MeshL2RoutingProtocol : public Object
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    52
   * Callback to be invoked when route discovery  procedure is completed.
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    53
   *
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    56
   *
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    57
   * \param packet      for which the route was resolved. All routing information for MAC layer
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    58
   *                    must be stored in proper tags (like in case of HWMP, when WifiMacHeader
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    59
   *                    needs address of next hop), or must be added as a packet header (if MAC
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    60
   *                    does not need any additional information). So, the packet is returned back
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    61
   *                    to MeshPointDevice looks like a pure packet with ethernet header
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    62
   *                    (i.e data + src +dst + protocol). The only special information addressed
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    63
   *                    to MeshPointDevice is an outcoming interface ID.
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    64
   *
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    65
   * \param src         source address of the packet
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    68
   *
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    69
   * \param protocol    ethernet 'Protocol' field, needed to form a proper MAC-layer header
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    70
   *
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    79
          uint32_t     /* out interface ID */
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    80
          > RouteReplyCallback;
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4807
diff changeset
    81
  /**
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    82
   * Request routing information, all packets must go through this request.
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    83
   *
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4993
diff changeset
    84
   * Note that route discovery works async. -- RequestRoute returns immediately, while
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4993
diff changeset
    85
   * reply callback will be called when routing information will be available.
4816
2efabacfb585 L2RoutingProcotol refactoring in progress
pavlo
parents: 4813
diff changeset
    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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    94
   * \param routeReply    callback to be invoked after route discovery procedure, supposed
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4993
diff changeset
    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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    97
  virtual bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, Ptr<
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    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
a3ede758b713 Doxygen: fixed warnings
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   113
  virtual bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr<
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   116
  void
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   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
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   119
  Ptr<MeshPointDevice>
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   124
};
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   125
}//namespace ns3
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   126
#endif