-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmp1.h
50 lines (33 loc) · 1.29 KB
/
mp1.h
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
#ifndef __MP1_H_
#define __MP1_H_
#include <pthread.h>
/*** unicast interface ***/
/* Should be called by multicast_init at start of program */
void unicast_init(void);
/* Send a message to destination */
void usend(int destination, const char *message, int len);
/* Called *by* unicast interface when an incoming unicast message arrives from source */
void receive(int source, const char *message, int len);
/*** multicast interface ***/
/* Call at start of program. */
void multicast_init(void);
/* Multicast message (NUL terminated) to multicast group (implicit) */
void multicast(const char *message);
/* Called *by* multicast protocol when an incoming multicast message is ready to be delivered */
void deliver(int source, const char *message);
/* Called when a new member is added to the group
*/
void mcast_join(int member);
/*** group maintenance ***/
extern int *mcast_members;
extern int mcast_num_members;
extern int my_id;
extern pthread_mutex_t member_lock;
/*** internals ***/
/* File where the list of current group members is stored */
#define GROUP_FILE "GROUPLIST"
/* Minimum and maximum delay values, in microseconds */
#define MINDELAY 50 /* 500ms */
#define MAXDELAY 10 /* 10s */
#define P_DROP 0.0 /* probability that a packet is dropped */
#endif