close Warning: Can't use blame annotator:
No changeset 12039 in the repository

source: source/ariba/overlay/SequenceNumber.h@ 12459

Last change on this file since 12459 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: 2.0 KB
RevLine 
1
2#ifndef SEQUENCENUMBER_H
3#define SEQUENCENUMBER_H
4
5#include <stdint.h>
6#include <iostream>
7
8// random
9#include <boost/random/mersenne_twister.hpp>
10#include <boost/random/uniform_int.hpp>
11
12namespace ariba {
13namespace overlay {
14
15#define MIN_SEQ_NUM 100
16#define SEQ_NUM_DISABLED 0
17
18class SequenceNumber
19{
20public:
21 static const SequenceNumber DISABLED;
22
23 /// constructors
24 SequenceNumber();
25 SequenceNumber(uint32_t seqnum);
26 SequenceNumber(uint64_t seqnum);
27
28 /// factories
29 static SequenceNumber createRandomSeqNum_Short();
30 static SequenceNumber createRandomSeqNum_Long();
31
32
33 /// get type information
34 bool isShortSeqNum() const;
35 bool isLongSeqNum() const;
36 bool isDisabled() const;
37 bool isValid() const;
38
39
40 /// operators
41 void increment();
42
43 /// NOTE: this is also »true« if the long seq_num matches the short seq_num
44 bool operator== (const SequenceNumber& rhs) const;
45
46 /// NOTE: return value is only meaningful if »isValid() == true« for both values
47 bool operator< (const SequenceNumber& rhs) const;
48
49 bool isSuccessor(const SequenceNumber& rhs);
50 bool isPredecessor(const SequenceNumber& rhs);
51
52
53 /// getter
54 uint32_t getShortSeqNum() const;
55 uint64_t getLongSeqNum() const;
56
57
58 /// to string
59 friend std::ostream& operator<< (std::ostream& stream, const SequenceNumber& rhs);
60
61private:
62 uint32_t seqnum_32;
63 uint64_t seqnum_64;
64
65 /// static random_number_generator
66 static boost::mt19937 rng_32bit;
67 static boost::uniform_int<uint32_t> seqnum_distribution_32bit;
68
69 // XXX NOTE: on later boost versions these are:
70 // boost::random::mt19937
71 // boost::random::uniform_int_distribution<>
72
73 // NOTE: since the mt19937_64 is not available in this boost version, we
74 // need an addition distribution
75 static boost::uniform_int<uint32_t> distribution_full32bit;
76};
77
78
79}} // [namespace ariba::overlay]
80
81#endif // SEQUENCENUMBER_H
Note: See TracBrowser for help on using the repository browser.