cl_init(char* filename) |
<I3ServerDetails UsePing="false" UseTCP="false" ServerListURL="rose.cs.berkeley.edu:8080/i3_status.txt" > <I3Server IPAddress="169.229.50.10" PortNum="5612" I3Id="7b97e83bd6d7c5aeb60169237476742fa49aa248" > </I3ServerDetails> |
cl_get_rtt_id(ID *id, uint64_t *rtt) |
cl_get_top_k_ids(int *k, ID best_id[], uint64_t best_rtt[]); |
cl_create_trigger_id(id, prefix_len, id_target, flags) |
CL_TRIGGER_CFLAG_R_CONSTRAINT
- Trigger is
right-constrained.
CL_TRIGGER_CFLAG_L_CONSTRAINT
- Trigger is
left-constrained.
CL_TRIGGER_CFLAG_PUBLIC
- Trigger is public. If
this is flag is not used, the trigger is private by default.
Since a public trigger must be left-constrained,
CL_TRIGGER_CFLAG_R_CONSTRAINT
and
CL_TRIGGER_CFLAG_PUBLIC
may not be used together.
cl_create_trigger_stack(id, prefix_len, stack, stack_len, flags) |
cl_insert_trigger(ctr, flags) |
cl_remove_trigger(ctr) |
cl_register_callback(uint16_t cbk_type, void (*fun)(), void *data) cl_register_trigger_callback(i3_trigger *t, uint16_t cbk_type, void (*fun)(), void *data) |
CL_CBK_TRIGGER_INSERTED
: This callback is invoked
when the client receives the first ack as a result of a trigger
insertion. The callback function has the template: fun(i3_trigger
*t, void *data) where t represents the inserted trigger,
and data represents the client's data CL_CBK_TRIGGER_REFRESH_FAILED
: This callback is
invoked when a trigger refresh fails. Refresh failure occurs when
none of the client's refresh messages is ACKed during a refresh
period which has a duration of TRIGGER_REFRESH_PERIOD sec. The
client refreshes a trigger by sending a refresh message
MAX_NUM_RETRIES*ACK_TIMEOUT sec before the refreshing period
expires. If the first refresh message is not acked, the client
resends the refresh message approximately every ACK_TIMEOUT sec.
The callback function has the following template: fun(i3_trigger
*t, void *data). A typical response of the client to this callback
is to reinsert the trigger using the cl_reinsert_trigger function.
CL_CBK_TRIGGER_NOT_FOUND
: This callback is
invoked when the client sends packets to an ID id, and there is no
trigger in the network matching this "id". The callback function
has the following template: fun(ID *id, void *data). CL_CBK_RECEIVE_PACKET
: This callback is invoked
upon receiving an i3 packet. The callback function has
the following template: fun(i3_trigger *t, i3_header *hdr, cl_buf
*b, void *data), where "t" represents the trigger matching
the the packet's ID, "hdr" represents the packet's header, "b"
contains the packet's payload, and "data" represents the client's
callback data. CL_CBK_RECEIVE_PAYLOAD
: This callback is invoked
upon receiving a data packet. This callback is suppressed by the
CL_CBK_RECEIVE_PACKET callback. The callback function has the
following template: fun(i3_trigger *t, cl_buf *b, void *data) CL_CBK_SERVER_DOWN
: This callback is invoked
when the client concludes than an i3 server is down.
This happens when the client either receives no ACKs (in the form
of i3 _OPT_CACHE_ADDR replies) to sending packets to that
server during a refresh period of ID_REFRESH_PERIOD sec, or when
the client receives no acks for three consecutive i3
_OPT_REQUEST_FOR_CACHE queries. The callback function has the
following template: fun(struct in_addr ip_addr, uint16_t port,
void *data), where "ip_addr" and "port" identify the reported
server. int cl_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *cl_to) |
forever do { t_ref <- time left to refresh next trigger if (cl_to is NULL) /* Client has specified inf timeout */ timeout = t_ref else timeout = min(cl_to, t_ref) select(..., timeout) if (packet received on i3 socket) invoke appropriate callback function if (current_time >= time to refresh next trigger) call refresh_triggers /* Warning: This assumes that t_ref >> callback processing time * If this is not true, make trivial change to * account for the correct time elapsed */ cl_to <- cl_to - t_ref; if (packet was received OR cl_to has gone down to zero) adjust cl_to and add time left in "timeout" return /* Warning: Note that this function returns when a * packet was received on i3 socket also. This is * because client semantics might require action upon * receipt of any packet */ } |
cl_exit() |