summaryrefslogtreecommitdiff
path: root/protocols/ace/TMCast/Protocol.hpp
blob: d5ae6a50cd67c4c822d60c3638eaea3fcbf6ffb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// file      : TMCast/Protocol.hpp
// author    : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id    : $Id$

#ifndef TMCAST_PROTOCOL_HPP
#define TMCAST_PROTOCOL_HPP

namespace TMCast
{
  namespace Protocol
  {
    //
    //
    //
    unsigned long const MEMBER_ID_LENGTH = 38;

    struct MemberId
    {
      char id[MEMBER_ID_LENGTH];
      /*
        unsigned long  ip;
        unsigned short port;
      */
    };

    //
    //
    //
    typedef unsigned short TransactionId;



    typedef unsigned char  TransactionStatus;

    TransactionStatus const TS_BEGIN    = 1;
    TransactionStatus const TS_COMMIT   = 2;
    TransactionStatus const TS_ABORT    = 3;
    TransactionStatus const TS_COMMITED = 4;
    TransactionStatus const TS_ABORTED  = 5;

    struct Transaction
    {
      TransactionId id;
      TransactionStatus status;
    };

    // Transaction List (TL)

    // unsigned long const TL_LENGTH = 1;

    // typedef Transaction TransactionList[TL_LENGTH];


    //
    //
    //
    struct MessageHeader
    {
      unsigned long length;

      unsigned long check_sum;

      MemberId member_id;

      Transaction current;

      //TransactionList transaction_list;
    };


    //
    //
    //

    unsigned long const MAX_MESSAGE_SIZE = 768;

    unsigned long const
    MAX_PAYLOAD_SIZE = MAX_MESSAGE_SIZE - sizeof (MessageHeader);

    // Protocol timing
    //
    //

    unsigned long const SYNC_PERIOD = 30000;    // in mks

    unsigned short const VOTING_FRAME = 4;      // in SYNC_PERIOD's
    unsigned short const SEPARATION_FRAME = 5;  // in SYNC_PERIOD's

    // FATAL_SILENCE_FRAME in SYNC_PERIOD's
    // Generally it's a good idea to set it to < VOTING_FRAME + SEPARATION_FRAME
    //

    short const FATAL_SILENCE_FRAME = VOTING_FRAME + SEPARATION_FRAME - 2;

    // short const FATAL_SILENCE_FRAME = 10000;

    // Helpers

    // std::string
    // tslabel (Protocol::TransactionStatus s);

    // std::ostream&
    // operator << (std::ostream& o, Transaction const& t);
  }
}

#endif // TMCAST_PROTOCOL_HPP