diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-08 09:23:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-08 09:23:47 +0000 |
commit | 539be627c009c2f13da19d6ae847168c1f5d496e (patch) | |
tree | 78814fdb491c52349f793af5898858a56e32117a /src/fs/fs_download.c | |
parent | 941c7ee262792114da1811cf4404b04550e071b1 (diff) | |
download | gnunet-539be627c009c2f13da19d6ae847168c1f5d496e.tar.gz gnunet-539be627c009c2f13da19d6ae847168c1f5d496e.zip |
-LRN: my experimental block download time measurer. The results
can be found there - [1].
[1] http://lrn.no-ip.info/other/gnunet_download_tie.log
Diffstat (limited to 'src/fs/fs_download.c')
-rw-r--r-- | src/fs/fs_download.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index cc36cba1f..85ae3ae34 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -118,6 +118,7 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
118 | pi->value.download.uri = dc->uri; | 118 | pi->value.download.uri = dc->uri; |
119 | pi->value.download.filename = dc->filename; | 119 | pi->value.download.filename = dc->filename; |
120 | pi->value.download.size = dc->length; | 120 | pi->value.download.size = dc->length; |
121 | /* FIXME: Fix duration calculation to account for pauses */ | ||
121 | pi->value.download.duration = | 122 | pi->value.download.duration = |
122 | GNUNET_TIME_absolute_get_duration (dc->start_time); | 123 | GNUNET_TIME_absolute_get_duration (dc->start_time); |
123 | pi->value.download.completed = dc->completed; | 124 | pi->value.download.completed = dc->completed; |
@@ -183,6 +184,8 @@ struct ProcessResultClosure | |||
183 | */ | 184 | */ |
184 | int do_store; | 185 | int do_store; |
185 | 186 | ||
187 | struct GNUNET_TIME_Absolute last_transmission; | ||
188 | |||
186 | }; | 189 | }; |
187 | 190 | ||
188 | 191 | ||
@@ -251,6 +254,7 @@ encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc, | |||
251 | dr->depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK; | 254 | dr->depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK; |
252 | prc.query = chk->query; | 255 | prc.query = chk->query; |
253 | prc.do_store = do_store; | 256 | prc.do_store = do_store; |
257 | prc.last_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
254 | process_result_with_request (&prc, &chk->key, dr); | 258 | process_result_with_request (&prc, &chk->key, dr); |
255 | return GNUNET_OK; | 259 | return GNUNET_OK; |
256 | } | 260 | } |
@@ -1072,6 +1076,12 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key, | |||
1072 | pi.value.download.specifics.progress.data_len = prc->size; | 1076 | pi.value.download.specifics.progress.data_len = prc->size; |
1073 | pi.value.download.specifics.progress.depth = dr->depth; | 1077 | pi.value.download.specifics.progress.depth = dr->depth; |
1074 | pi.value.download.specifics.progress.trust_offered = 0; | 1078 | pi.value.download.specifics.progress.trust_offered = 0; |
1079 | if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) | ||
1080 | pi.value.download.specifics.progress.block_download_duration = | ||
1081 | GNUNET_TIME_absolute_get_duration (prc->last_transmission); | ||
1082 | else | ||
1083 | pi.value.download.specifics.progress.block_download_duration.rel_value = | ||
1084 | GNUNET_TIME_UNIT_FOREVER_REL.rel_value; | ||
1075 | GNUNET_FS_download_make_status_ (&pi, dc); | 1085 | GNUNET_FS_download_make_status_ (&pi, dc); |
1076 | GNUNET_assert (dc->completed <= dc->length); | 1086 | GNUNET_assert (dc->completed <= dc->length); |
1077 | if (dr->depth == 0) | 1087 | if (dr->depth == 0) |
@@ -1182,12 +1192,15 @@ signal_error: | |||
1182 | * | 1192 | * |
1183 | * @param dc our download context | 1193 | * @param dc our download context |
1184 | * @param type type of the result | 1194 | * @param type type of the result |
1195 | * @param last_transmission when was this block requested the last time? (FOREVER if unknown/not applicable) | ||
1185 | * @param data the (encrypted) response | 1196 | * @param data the (encrypted) response |
1186 | * @param size size of data | 1197 | * @param size size of data |
1187 | */ | 1198 | */ |
1188 | static void | 1199 | static void |
1189 | process_result (struct GNUNET_FS_DownloadContext *dc, | 1200 | process_result (struct GNUNET_FS_DownloadContext *dc, |
1190 | enum GNUNET_BLOCK_Type type, const void *data, size_t size) | 1201 | enum GNUNET_BLOCK_Type type, |
1202 | struct GNUNET_TIME_Absolute last_transmission, | ||
1203 | const void *data, size_t size) | ||
1191 | { | 1204 | { |
1192 | struct ProcessResultClosure prc; | 1205 | struct ProcessResultClosure prc; |
1193 | 1206 | ||
@@ -1196,6 +1209,7 @@ process_result (struct GNUNET_FS_DownloadContext *dc, | |||
1196 | prc.size = size; | 1209 | prc.size = size; |
1197 | prc.type = type; | 1210 | prc.type = type; |
1198 | prc.do_store = GNUNET_YES; | 1211 | prc.do_store = GNUNET_YES; |
1212 | prc.last_transmission = last_transmission; | ||
1199 | GNUNET_CRYPTO_hash (data, size, &prc.query); | 1213 | GNUNET_CRYPTO_hash (data, size, &prc.query); |
1200 | #if DEBUG_DOWNLOAD | 1214 | #if DEBUG_DOWNLOAD |
1201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1219,20 +1233,21 @@ static void | |||
1219 | receive_results (void *cls, const struct GNUNET_MessageHeader *msg) | 1233 | receive_results (void *cls, const struct GNUNET_MessageHeader *msg) |
1220 | { | 1234 | { |
1221 | struct GNUNET_FS_DownloadContext *dc = cls; | 1235 | struct GNUNET_FS_DownloadContext *dc = cls; |
1222 | const struct PutMessage *cm; | 1236 | const struct ClientPutMessage *cm; |
1223 | uint16_t msize; | 1237 | uint16_t msize; |
1224 | 1238 | ||
1225 | if ((NULL == msg) || (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || | 1239 | if ((NULL == msg) || (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || |
1226 | (sizeof (struct PutMessage) > ntohs (msg->size))) | 1240 | (sizeof (struct ClientPutMessage) > ntohs (msg->size))) |
1227 | { | 1241 | { |
1228 | GNUNET_break (msg == NULL); | 1242 | GNUNET_break (msg == NULL); |
1229 | try_reconnect (dc); | 1243 | try_reconnect (dc); |
1230 | return; | 1244 | return; |
1231 | } | 1245 | } |
1232 | msize = ntohs (msg->size); | 1246 | msize = ntohs (msg->size); |
1233 | cm = (const struct PutMessage *) msg; | 1247 | cm = (const struct ClientPutMessage *) msg; |
1234 | process_result (dc, ntohl (cm->type), &cm[1], | 1248 | process_result (dc, ntohl (cm->type), |
1235 | msize - sizeof (struct PutMessage)); | 1249 | GNUNET_TIME_absolute_ntoh (cm->last_transmission), &cm[1], |
1250 | msize - sizeof (struct ClientPutMessage)); | ||
1236 | if (dc->client == NULL) | 1251 | if (dc->client == NULL) |
1237 | return; /* fatal error */ | 1252 | return; /* fatal error */ |
1238 | /* continue receiving */ | 1253 | /* continue receiving */ |