1 /* Copyright (c) 2016. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "simgrid/msg.h"
10 #include "simgrid/modelchecker.h"
11 #include <xbt/RngStream.h>
12 #include "src/mc/mc_replay.h" // FIXME: this is an internal header
16 #define MAILBOX_NAME_SIZE 10
19 typedef struct s_finger {
21 char mailbox[MAILBOX_NAME_SIZE]; // string representation of the id
26 typedef struct s_node {
28 char mailbox[MAILBOX_NAME_SIZE]; // my mailbox name (string representation of the id)
29 s_finger_t *fingers; // finger table, of size nb_bits (fingers[0] is my successor)
30 int pred_id; // predecessor id
31 char pred_mailbox[MAILBOX_NAME_SIZE]; // predecessor's mailbox name
32 int next_finger_to_fix; // index of the next finger to fix in fix_fingers()
33 msg_comm_t comm_receive; // current communication to receive
34 double last_change_date; // last time I changed a finger or my predecessor
35 RngStream stream; //RngStream for
37 typedef s_node_t *node_t;
39 /* Types of tasks exchanged between nodes. */
42 TASK_FIND_SUCCESSOR_ANSWER,
44 TASK_GET_PREDECESSOR_ANSWER,
46 TASK_SUCCESSOR_LEAVING,
47 TASK_PREDECESSOR_LEAVING,
48 TASK_PREDECESSOR_ALIVE,
49 TASK_PREDECESSOR_ALIVE_ANSWER
52 /* Data attached with the tasks sent and received */
53 typedef struct s_task_data {
54 e_task_type_t type; // type of task
55 int request_id; // id paramater (used by some types of tasks)
56 int request_finger; // finger parameter (used by some types of tasks)
57 int answer_id; // answer (used by some types of tasks)
58 char answer_to[MAILBOX_NAME_SIZE]; // mailbox to send an answer to (if any)
59 const char* issuer_host_name; // used for logging
61 typedef s_task_data_t *task_data_t;
63 void create(node_t node);
64 int join(node_t node, int known_id);
65 void leave(node_t node);
66 int find_successor(node_t node, int id);
67 int remote_find_successor(node_t node, int ask_to_id, int id);
68 int remote_get_predecessor(node_t node, int ask_to_id);
69 int closest_preceding_node(node_t node, int id);
70 void stabilize(node_t node);
71 void notify(node_t node, int predecessor_candidate_id);
72 void remote_notify(int notify_to, int predecessor_candidate_id);
73 void fix_fingers(node_t node);
74 void check_predecessor(node_t node);
75 void random_lookup(node_t node);
76 void quit_notify(node_t node);