summaryrefslogtreecommitdiff
path: root/testing/Lossless_UDP_testclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/Lossless_UDP_testclient.c')
-rw-r--r--testing/Lossless_UDP_testclient.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c
index 3c52c6d6..52c48a97 100644
--- a/testing/Lossless_UDP_testclient.c
+++ b/testing/Lossless_UDP_testclient.c
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
164 exit(0); 164 exit(0);
165 } 165 }
166 166
167 uint8_t buffer[512]; 167 uint8_t buffer[MAX_DATA_SIZE];
168 int read; 168 int read;
169 169
170 FILE *file = fopen(argv[argvoffset + 3], "rb"); 170 FILE *file = fopen(argv[argvoffset + 3], "rb");
@@ -216,10 +216,10 @@ int main(int argc, char *argv[])
216 } 216 }
217 217
218 timer = current_time(); 218 timer = current_time();
219 219 unsigned long long bytes_sent = 0;
220 220
221 /*read first part of file */ 221 /*read first part of file */
222 read = fread(buffer, 1, 512, file); 222 read = fread(buffer, 1, MAX_DATA_SIZE, file);
223 223
224 while (1) { 224 while (1) {
225 /* printconnection(connection); */ 225 /* printconnection(connection); */
@@ -228,26 +228,32 @@ int main(int argc, char *argv[])
228 228
229 if (is_connected(ludp, connection) == 3) { 229 if (is_connected(ludp, connection) == 3) {
230 230
231 if (write_packet(ludp, connection, buffer, read)) { 231 while (write_packet(ludp, connection, buffer, read)) {
232 bytes_sent += read;
232 /* printf("Wrote data.\n"); */ 233 /* printf("Wrote data.\n"); */
233 read = fread(buffer, 1, 512, file); 234 read = fread(buffer, 1, MAX_DATA_SIZE, file);
234 235
235 } 236 }
236 237
237 /* printf("%u\n", sendqueue(connection)); */ 238 /* printf("%u\n", sendqueue(connection)); */
238 if (sendqueue(ludp, connection) == 0) { 239 if (sendqueue(ludp, connection) == 0) {
239 if (read == 0) { 240 if (read == 0) {
240 printf("Sent file successfully in: %llu us\n", (unsigned long long)(current_time() - timer)); 241 unsigned long long us = (unsigned long long)(current_time() - timer);
242 printf("Sent file successfully in: %llu us = %llu seconds. Average speed: %llu KB/s\n", us, us / 1000000UL,
243 bytes_sent / (us / 1024UL));
244 //printf("Total bytes sent: %llu B, Total data sent: %llu B, overhead: %llu B\n", total_bytes_sent, bytes_sent, total_bytes_sent-bytes_sent);
241 break; 245 break;
242 } 246 }
243 } 247 }
244 } else { 248 } else {
245 printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); 249 printf("%u Client Connecting Lost after: %llu us\n", is_connected(ludp, connection),
250 (unsigned long long)(current_time() - timer));
246 return 0; 251 return 0;
247 } 252 }
248 253
249 /* c_sleep(1); */
250 } 254 }
251 255
256 c_sleep(25);
257
252 return 0; 258 return 0;
253} 259}