1 /* See the DRL-LICENSE file for this file's software license. */
8 #define MAX_FRIENDS (5)
9 #define UPDATE_THRESHOLD (3)
10 #define FRIEND_THRESHOLD (4)
11 #define SOURCE_THRESHOLD (8)
13 static const uint16_t CHECK = 3;
14 static const uint16_t CHECK_ACK = 4;
15 static const uint16_t PING = 5;
16 static const uint16_t PING_ACK = 6;
18 /** Structs needed to maintain the list of nodes to which
19 * ping messages have been sent. This list is maintained
20 * by one of the "friend" nodes
22 typedef struct ping_target {
23 // node which has been targetted
25 // node which requested the ping target
26 // so that CHECK_ACK could be sent with ALIVE / AWOL
28 // count of gossip rounds to keep timeout
30 // this has to be a list as well because we have to
31 // remember all the suspects a particular node has
32 // pinged and is waiting for a response
33 struct ping_target *next;
36 typedef struct update {
37 /*Remote limiter whose update this is*/
38 remote_limiter_t *remote;
39 /*Number of times, update has been piggy
40 *backed on a gossip message*/
45 typedef struct swim_comm {
46 /*Incarnation number of the node*/
49 /*List of updates currently held by the node*/
53 /** Keep track of the ping messages being sent and wait for timeout */
54 ping_target_t *ping_targets;
57 int swim_init(comm_t *comm, uint32_t id);
59 void swim_teardown(comm_t *comm);
61 int swim_receive(comm_t *comm, uint32_t id, int sock, remote_limiter_t *remote, message_t *msg);
63 int send_gossip_swim(comm_t *comm, uint32_t id, int sock);
65 void swim_restart(comm_t *comm, int32_t view_number);