An Overlay-based
Virtual Network Substrate
SpoVNet

source: source/ariba/CommunicationListener.h @ 12438

Last change on this file since 12438 was 12060, checked in by hock@…, 9 years ago

Reintegrate branch: 20130111-hock-message_classes

improvements:

  • new message classes (reboost, zero-copy)
  • "fast path" for direct links (skip overlay layer)
  • link-properties accessible from the application
  • SystemQueue? can call boost::bind functions
  • protlib compatibility removed (32bit overhead saved in every message)
  • addressing2
  • AddressDiscovery? discoveres only addresses on which we're actually listening
  • ariba serialization usage reduced (sill used in OverlayMsg?)
  • Node::connect, easier and cleaner interface to start-up ariba from the application
  • ariba configs via JSON, XML, etc (boost::property_tree)
  • keep-alive overhead greatly reduced
  • (relayed) overlay links can actually be closed now
  • lost messages are detected in most cases
  • notification to the application when link is transformed into direct-link
  • overlay routing: send message to second best hop if it would be dropped otherwise
  • SequenceNumbers? (only mechanisms, so for: upward compatibility)
  • various small fixes


regressions:

  • bluetooth is not yet working again
  • bootstrap modules deactivated
  • liblog4xx is not working (use cout-logging)

This patch brings great performance and stability improvements at cost of backward compatibility.
Also bluetooth and the bootstrap modules have not been ported to the new interfaces, yet.

File size: 5.6 KB
Line 
1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#ifndef COMMUNICATIONLISTENER_H_
40#define COMMUNICATIONLISTENER_H_
41
42#include "Message.h"
43#include "Identifiers.h"
44#include "LinkProperties.h"
45#include "DataMessage.h"
46#include "ariba/overlay/SequenceNumber.h"
47
48namespace ariba {
49
50typedef ariba::overlay::SequenceNumber SequenceNumber;
51
52// forward decl
53namespace overlay {
54        class BaseOverlay;
55        class OverlayMsg;
56}
57
58/** \addtogroup public
59 * @{
60 * Listener for communication events on links.
61 */
62class CommunicationListener {
63
64        friend class ariba::overlay::BaseOverlay;
65        friend class Node;
66
67public:
68        static CommunicationListener DEFAULT; //< default implementation
69
70protected:
71
72        /**
73         * Construct a communication listener
74         */
75        CommunicationListener();
76
77        /**
78         * Destruct a communication listener
79         */
80        virtual ~CommunicationListener();
81
82        // --- link events ---
83
84        /**
85         * Event called when a link goes up
86         * @param lnk The id of the link
87         * @param remote The remote node where the link ends
88         */
89        virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
90
91        /**
92         * Event called when a link goes down
93         * @param lnk The id of the link
94         * @param remote The remote node where the link ends
95         */
96        virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
97
98        /**
99         * Event called when a link has changed,
100         * e.g. through mobility
101         * @param lnk The id of the link
102         * @param remote The remote node where the link ends
103         */
104        virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
105
106        /**
107         * Event called when a link has failed
108         * @param lnk The id of the link
109         * @param remote The remote node where the link ends
110         */
111        virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
112
113        /**
114         * Request from remote node to open up a link
115         * @param remote The remote node that requests the new link
116         */
117        virtual bool onLinkRequest(const NodeID& remote);
118
119        // --- general receive method ---
120
121        /**
122         * @DEPRECATED
123         *
124         * Called when a message is incoming
125         * @param msg The data message that is received
126         * @param remote The remote node that sent the message
127         * @param lnk The link id of the link where the message is received
128         */
129        virtual void onMessage(const DataMessage& msg, const NodeID& remote,
130                        const LinkID& lnk = LinkID::UNSPECIFIED);
131
132
133    /**
134     * NOTE: This interface is still unstable and may change in future releases.
135     *   ---> Especially the parameter «overlay_msg» may be replaced or removed.
136     *   
137     * Called when a message is incoming
138     * @param msg A shared buffer with the (serialized) payload
139     * @param remote The remote node that sent the message
140     * @param lnk The link id of the link where the message is received
141     * @param overlay_msg A pointer to the ariba internal Overlay Message
142     */
143    virtual void onMessage(reboost::shared_buffer_t message,
144            const NodeID& remote,
145            const LinkID& lnk,
146            const SequenceNumber& seqnum,
147            const ariba::overlay::OverlayMsg* overlay_msg);
148
149        // --- dht functionality ---
150
151        /**
152         * Called when a key has been resolved in the DHT
153         * @param key The key that was requested
154         * @param value the data items the key was resolved to
155         */
156        virtual void onKeyValue( const Data& key, const vector<Data>& value );
157
158    // --- ping pong (routed) ---
159    /**
160     * Called when a ping message was received.
161     *
162     * @param remote Node which sent the ping message
163     * @return bool Allows to send a pong message (default: true)
164     */
165    virtual bool onPing(const NodeID& remote);
166
167    /**
168     * Called when a ping message is lost.
169     *
170     * NOTE: A ping message could also get lost without notice.
171     *
172     * @param remote Node to which the ping message was sent
173     */
174    virtual void onPingLost(const NodeID& remote);
175   
176    /**
177     * Called when a pong message was received.
178     *
179     * @param remote Node which sent the pong message
180     */
181    virtual void onPong(const NodeID& remote);
182};
183
184} // namespace ariba
185
186/** @} */
187
188#endif /* COMMUNICATIONLISTENER_H_ */
Note: See TracBrowser for help on using the repository browser.