An Overlay-based
Virtual Network Substrate
SpoVNet

source: source/ariba/overlay/LinkDescriptor.h

Last change on this file was 12060, checked in by hock@…, 11 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.8 KB
Line 
1#ifndef __LINK_DESCRIPTOR_H
2#define __LINK_DESCRIPTOR_H
3
4#include <iostream>
5#include <sstream>
6#include <ctime>
7#include <deque>
8#include <boost/foreach.hpp>
9
10#include "ariba/utility/messages.h"
11#include "ariba/utility/types.h"
12#include "ariba/communication/EndpointDescriptor.h"
13#include "ariba/CommunicationListener.h"
14
15// reboost messages
16#include "ariba/utility/transport/messages/message.hpp"
17#include <ariba/utility/misc/sha1.h>
18
19#include "ariba/overlay/SequenceNumber.h"
20
21
22namespace ariba {
23        class CommunicationListener;
24}
25
26using std::deque;
27using ariba::utility::Message;
28using ariba::utility::NodeID;
29using ariba::utility::SpoVNetID;
30using ariba::utility::ServiceID;
31using ariba::utility::LinkID;
32using ariba::CommunicationListener;
33using ariba::communication::EndpointDescriptor;
34
35namespace ariba {
36namespace overlay {
37
38class LinkDescriptor;
39
40std::ostream& operator<<(std::ostream& s, const LinkDescriptor* ld );
41std::ostream& operator<<(std::ostream& s, const LinkDescriptor& ld );
42
43/// LinkDescriptor
44class LinkDescriptor {
45public:
46    struct message_queue_entry
47    {
48        reboost::message_t message;
49        uint8_t priority;
50    };
51   
52        // ctor
53        LinkDescriptor() {
54            time_t now = time(NULL);
55           
56                // default values
57                this->up = false;
58//         this->closing = false;
59        this->failed = false;
60                this->fromRemote = false;
61                this->remoteNode = NodeID::UNSPECIFIED;
62                this->overlayId  = LinkID::create();
63                this->communicationUp = false;
64                this->communicationId = LinkID::UNSPECIFIED;
65                this->keepAliveReceived = now;
66                this->keepAliveSent = now;
67                this->relaying     = false;
68                this->timeRelaying = now;
69                this->dropAfterRelaying = false;
70                this->service  = ServiceID::UNSPECIFIED;
71                this->listener = &CommunicationListener::DEFAULT;
72                this->relayed = false;
73                this->remoteLink = LinkID::UNSPECIFIED;
74                this->autolink = false;
75                this->lastuse = now;
76                this->retryCounter = 0;
77                this->hops = -1;
78       
79        this->transmit_seqnums = false; // XXX
80        }
81
82        // dtor
83        ~LinkDescriptor() {
84                flushQueue();
85        }
86
87        // general information about the link --------------------------------------
88        bool up;           ///< flag whether this link is up and running
89//      bool closing;      ///< flag, whether this link is in the regular process of closing
90        bool failed;       ///< flag, whether communication is (assumed to be) not/no longer possible on this link
91        bool fromRemote;   ///< flag, whether this link was requested from remote
92        NodeID remoteNode; ///< remote end-point node
93
94
95        // link identifiers --------------------------------------------------------
96        LinkID overlayId;       ///< the base overlay link id
97        LinkID communicationId; ///< the communication id
98        bool   communicationUp;   ///< flag, whether the communication is up
99
100        // sequence numbers --------------------------------------------------------
101        SequenceNumber last_sent_seqnum;
102    bool transmit_seqnums;
103   
104        // direct link retries -----------------------------------------------------
105        EndpointDescriptor endpoint;
106        int retryCounter;
107
108        // link alive information --------------------------------------------------
109        time_t keepAliveReceived; ///< the last time a keep-alive message was received
110        time_t keepAliveSent;  ///< the number of missed keep-alive messages
111        void setAlive() {
112//              keepAliveSent = time(NULL);
113                keepAliveReceived = time(NULL);
114        }
115
116        // relay information -------------------------------------------------------
117        bool   relayed;    ///< flag whether this link is a relayed link
118        LinkID remoteLink; ///< the remote link id
119        vector<NodeID> routeRecord;
120        int hops;
121
122        // relay state -------------------------------------------------------------
123        bool   relaying;     ///< flag, wheter this link has been used as relay
124        bool   dropAfterRelaying;
125        time_t timeRelaying; ///< last time the link has been used as relay
126        void setRelaying() {
127                relaying = true;
128                timeRelaying = time(NULL);
129        }
130
131        // owner -------------------------------------------------------------------
132        ServiceID service; ///< service using this link
133        CommunicationListener* listener; ///< the listener using this node
134
135        // auto links --------------------------------------------------------------
136        bool autolink;  ///< flag, whether this link is a auto-link
137        time_t lastuse; ///< time, when the link was last used XXX AUTO_LINK-ONLY
138        deque<message_queue_entry> messageQueue; ///< waiting messages to be delivered
139        void setAutoUsed() {
140                if (autolink) lastuse = time(NULL);
141        }
142        /// drops waiting auto-link messages
143        void flushQueue() {
144//              BOOST_FOREACH( Message* msg, messageQueue )     delete msg;  // XXX MARIO: shouldn't be necessary anymore, since we're using shared pointers
145                messageQueue.clear();
146        }
147
148        // string representation ---------------------------------------------------
149        std::string to_string() const {
150            time_t now = time(NULL);
151           
152                std::ostringstream s;
153        if ( relayed )
154            s << "[RELAYED-";
155        else
156            s << "[DIRECT-";
157        s << "LINK] ";
158        s << "id=" << overlayId.toString().substr(0,4) << " ";
159        s << "serv=" << service.toString() << " ";
160                s << "up=" << up << " ";
161                s << "init=" << !fromRemote << " ";
162                s << "node=" << remoteNode.toString().substr(0,4) << " ";
163                s << "relaying=" << relaying << " ";
164                s << "last_received=" << now - keepAliveReceived << "s ";
165                s << "auto=" << autolink << " ";
166                s << "hops=" << hops << " ";
167                if ( relayed ) {
168                        s << "| Relayed: ";
169                        s << "remote link=" << remoteLink.toString().substr(0,4) << " ";
170                        if (routeRecord.size()>0) {
171                                s << "route record=";
172                                for (size_t i=0; i<routeRecord.size(); i++)
173                                        s << routeRecord[i].toString().substr(0,4) << " ";
174                        }
175                } else {
176                        s << "| Direct: ";
177                        s << "using [COMMUNICATION-LINK] id=" << communicationId.toString().substr(0,4) << " ";
178                        s << "(up=" << communicationUp << ") ";
179                }
180                return s.str();
181        }
182};
183
184}} // namespace ariba, overlay
185
186#endif // __LINK_DESCRIPTOR_H
187
Note: See TracBrowser for help on using the repository browser.