An implementation of the Chord peer-to-peer lookup service in C.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Makefile
README.md
chord_sigcomm.pdf
inet.c
inet.h
main.c
triad.c
triad.h

README.md

triad

An implementation of the Chord peer-to-peer lookup service in C.

API overview

node_t *triad_init(const char *ip)

Initializes a new node structure for the given IP address that is used for subsequent API calls.

int triad_join(node_t *n, const char *ip)

Joins the node n to the Chord ring that the node at ip is already connected to. If ip is n's IP address, then a new Chord ring is started at ip, with n as its sole member.

char *triad_lookup(node_t *n, unsigned int id)

Looks up the IP address of the node that id is located on, in the Chord ring that n has joined to.

int triad_leave(node_t *n)

Leaves the Chord ring that n is a member of. This is necessary for correctly updating the state of the other nodes in the ring.

int triad_deinit(node_t *n)

Releases any allocated resources and joins any threads used by n.

Example usage

char local[15] = "192.168.1.7";   // this node's IP address
char remote[15] = "192.168.1.8";  // the IP address of a node that has already joined a Chord ring
int start_new = 0;  // whether to start a new Chord ring or join an existing one
node_t *n = triad_init(local);
if (start_new)
    triad_join(n, local);
else
    triad_join(n, remote);
printf("12345678 => %s\n", triad_lookup(n, 12345678));
triad_leave(n);
triad_deinit(n);