From: Maximiliano Geier Date: Wed, 24 Oct 2012 12:55:53 +0000 (+0200) Subject: BitTorrent changes: X-Git-Tag: v3_8~15^2~8 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a056c753e9e4cfb9147a8184e4db442ff3b99b43 BitTorrent changes: Fix message sizes (used MB instead of bytes) Fix tesh again to match this change Define new message type MESSAGE_CANCEL (not implemented yet) --- diff --git a/examples/msg/bittorrent/bittorrent.tesh b/examples/msg/bittorrent/bittorrent.tesh index a94ad650c3..669e486395 100644 --- a/examples/msg/bittorrent/bittorrent.tesh +++ b/examples/msg/bittorrent/bittorrent.tesh @@ -15,9 +15,9 @@ $ $SG_TEST_EXENV ${bindir:=.}/bittorrent ${srcdir:=.}/../msg_platform.xml ${srcd > [ 0.000000] (8:peer@McGee) Hi, I'm joining the network with id 8 > [ 3000.000000] (1:tracker@Jacquelin) Tracker is leaving > [ 5000.005340] (5:peer@Geoff) Here is my current status: 1111111111 -> [ 5000.012389] (7:peer@iRMX) Here is my current status: 1111111111 +> [ 5000.013261] (7:peer@iRMX) Here is my current status: 1111111111 > [ 5000.048881] (2:peer@Boivin) Here is my current status: 1111111111 -> [ 5000.827195] (8:peer@McGee) Here is my current status: 1111111111 -> [ 5000.832370] (3:peer@Jean_Yves) Here is my current status: 1111111111 -> [ 5000.897047] (4:peer@TeX) Here is my current status: 1111111111 -> [ 5000.897047] (6:peer@Disney) Here is my current status: 1111111111 +> [ 5000.827966] (8:peer@McGee) Here is my current status: 1111111111 +> [ 5000.833962] (3:peer@Jean_Yves) Here is my current status: 1111111111 +> [ 5000.897269] (4:peer@TeX) Here is my current status: 1111111111 +> [ 5000.897269] (6:peer@Disney) Here is my current status: 1111111111 diff --git a/examples/msg/bittorrent/messages.c b/examples/msg/bittorrent/messages.c index 8eac54f451..cf4759dbed 100644 --- a/examples/msg/bittorrent/messages.c +++ b/examples/msg/bittorrent/messages.c @@ -8,7 +8,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_messages, "Messages specific for the message factory"); -#define BYTES_TO_MB(x) ((long double)x/1048576.0) #define BITS_TO_BYTES(x) ((x / 8) + (x % 8) ? 1 : 0) /** @@ -22,14 +21,13 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_messages, "Messages specific for the message fa msg_task_t task_message_new(e_message_type type, const char *issuer_host_name, const char *mailbox, int peer_id, int size) { - long double size_mb = BYTES_TO_MB(size); message_t message = xbt_new(s_message_t, 1); message->issuer_host_name = issuer_host_name; message->peer_id = peer_id; message->mailbox = mailbox; message->type = type; - msg_task_t task = MSG_task_create(NULL, 0, size_mb, message); - XBT_DEBUG("type: %d size: %.20Lg (%d)", type, size_mb, size); + msg_task_t task = MSG_task_create(NULL, 0, size, message); + XBT_DEBUG("type: %d size: %.20Lg (%d)", type, size, size); return task; } @@ -110,6 +108,7 @@ int task_message_size(e_message_type type) case MESSAGE_BITFIELD: size = MESSAGE_BITFIELD_SIZE; break; case MESSAGE_REQUEST: size = MESSAGE_REQUEST_SIZE; break; case MESSAGE_PIECE: size = MESSAGE_PIECE_SIZE; break; + case MESSAGE_CANCEL: size = MESSAGE_CANCEL_SIZE; break; } return size; } diff --git a/examples/msg/bittorrent/messages.h b/examples/msg/bittorrent/messages.h index 2a87b7c624..a8e98c3d4f 100644 --- a/examples/msg/bittorrent/messages.h +++ b/examples/msg/bittorrent/messages.h @@ -34,7 +34,8 @@ typedef enum { MESSAGE_HAVE, MESSAGE_BITFIELD, MESSAGE_REQUEST, - MESSAGE_PIECE + MESSAGE_PIECE, + MESSAGE_CANCEL } e_message_type; /** diff --git a/examples/msg/bittorrent/peer.c b/examples/msg/bittorrent/peer.c index baa8bc1672..f770a85b32 100644 --- a/examples/msg/bittorrent/peer.c +++ b/examples/msg/bittorrent/peer.c @@ -428,6 +428,8 @@ void handle_message(peer_t peer, msg_task_t task) } } break; + case MESSAGE_CANCEL: + break; } //Update the peer speed. if (remote_peer) {