X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0868c23f9325ad81241a6e1df80e804d7f4067b7..d55f9548c659a1e31267748bde0f8bc9846cd1d4:/examples/msg/bittorrent/peer.h diff --git a/examples/msg/bittorrent/peer.h b/examples/msg/bittorrent/peer.h index 8fd1997601..0e7b34002c 100644 --- a/examples/msg/bittorrent/peer.h +++ b/examples/msg/bittorrent/peer.h @@ -16,32 +16,33 @@ * Peer data */ typedef struct s_peer { - int id; //peer id + int id; //peer id - int pieces; //number of pieces the peer has. - char *bitfield; //list of pieces the peer has. - char *bitfield_blocks; //list of blocks the peer has. - short *pieces_count; //number of peers that have each piece. + int pieces; //number of pieces the peer has. + char *bitfield; //list of pieces the peer has. + char *bitfield_blocks; //list of blocks the peer has. + short *pieces_count; //number of peers that have each piece. - xbt_dynar_t current_pieces; //current pieces the peer is downloading - int current_piece; //current pieces - int pieces_requested; //number of pieces the peer has requested + xbt_dynar_t current_pieces; //current pieces the peer is downloading - xbt_dict_t peers; //peers list - xbt_dict_t active_peers; //active peers list + xbt_dict_t peers; //peers list + xbt_dict_t active_peers; //active peers list + int round; //current round for the chocking algortihm. - char mailbox[MAILBOX_SIZE]; //peer mailbox. - char mailbox_tracker[MAILBOX_SIZE]; //pair mailbox while communicating with the tracker. - const char *hostname; //peer hostname - msg_task_t task_received; //current task being received - msg_comm_t comm_received; //current comm + char mailbox[MAILBOX_SIZE]; //peer mailbox. + char mailbox_tracker[MAILBOX_SIZE]; //pair mailbox while communicating with the tracker. + const char *hostname; //peer hostname - int round; //current round for the chocking algortihm. + msg_task_t task_received; //current task being received + msg_comm_t comm_received; //current comm - RngStream stream; //RngStream for - double begin_receive_time; //time when the receiving communication has begun, useful for calculating host speed. + RngStream stream; //RngStream for + + double begin_receive_time; //time when the receiving communication has begun, useful for calculating host speed. + + xbt_dynar_t pending_sends; // list of sends being delivered } s_peer_t, *peer_t; /** @@ -58,6 +59,7 @@ void peer_free(peer_t peer); int has_finished(char *bitfield); +void handle_pending_sends(peer_t peer); void handle_message(peer_t peer, msg_task_t task); void wait_for_pieces(peer_t peer, double deadline); @@ -69,7 +71,7 @@ void update_choked_peers(peer_t peer); void update_interested_after_receive(peer_t peer); void update_bitfield_blocks(peer_t peer, int index, int block_index, - int block_length); + int block_length); int piece_complete(peer_t peer, int index); int get_first_block(peer_t peer, int piece); @@ -88,10 +90,10 @@ void send_choked(peer_t peer, const char *mailbox); void send_unchoked(peer_t peer, const char *mailbox); void send_have(peer_t peer, int piece); -void send_request(peer_t peer, const char *mailbox, int piece, int block_index, - int block_length); +void send_request(peer_t peer, const char *mailbox, int piece, + int block_index, int block_length); void send_piece(peer_t peer, const char *mailbox, int piece, int stalled, - int block_index, int block_length); + int block_index, int block_length); int in_current_pieces(peer_t peer, int piece); -#endif /* BITTORRENT_PEER_H */ +#endif /* BITTORRENT_PEER_H */