diff --git a/offloading_binaries/client_send_bypassl3/client_send_bypassl3 b/offloading_binaries/client_send_bypassl3/client_send_bypassl3 index ee583f9..593dace 100755 Binary files a/offloading_binaries/client_send_bypassl3/client_send_bypassl3 and b/offloading_binaries/client_send_bypassl3/client_send_bypassl3 differ diff --git a/offloading_binaries/client_send_bypassl3/main.c b/offloading_binaries/client_send_bypassl3/main.c index 072158c..2d228e8 100644 --- a/offloading_binaries/client_send_bypassl3/main.c +++ b/offloading_binaries/client_send_bypassl3/main.c @@ -104,14 +104,10 @@ int main(int argc, char *argv[]) if ((quota % sendsize) > 0) { // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); - slotLength = (quota / sendsize + 1) * sendsize / quota * slotLength; + slotLength = (uint)((double)(quota / sendsize + 1) * sendsize / quota * slotLength); quota = (quota / sendsize + 1) * sendsize; // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); } - else - { - slotLength = (quota / sendsize) * sendsize / quota * slotLength; - } // get file size (bytes2send) if (isNumber(argv[1])) diff --git a/offloading_binaries/client_send_bypassl3/main.o b/offloading_binaries/client_send_bypassl3/main.o index 3cfa609..9c378b3 100644 Binary files a/offloading_binaries/client_send_bypassl3/main.o and b/offloading_binaries/client_send_bypassl3/main.o differ diff --git a/offloading_binaries/client_send_normaltcp/client_send_normaltcp b/offloading_binaries/client_send_normaltcp/client_send_normaltcp index 22f058e..e5fd442 100755 Binary files a/offloading_binaries/client_send_normaltcp/client_send_normaltcp and b/offloading_binaries/client_send_normaltcp/client_send_normaltcp differ diff --git a/offloading_binaries/client_send_normaltcp/main.c b/offloading_binaries/client_send_normaltcp/main.c index 3edb122..d548f44 100644 --- a/offloading_binaries/client_send_normaltcp/main.c +++ b/offloading_binaries/client_send_normaltcp/main.c @@ -80,14 +80,10 @@ int main(int argc, char *argv[]) if ((quota % sendsize) > 0) { // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); - slotLength = (quota / sendsize + 1) * sendsize / quota * slotLength; + slotLength = (uint)((double)(quota / sendsize + 1) * sendsize / quota * slotLength); quota = (quota / sendsize + 1) * sendsize; // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); } - else - { - slotLength = (quota / sendsize) * sendsize / quota * slotLength; - } // get file size (bytes2send) if (isNumber(argv[1])) diff --git a/offloading_binaries/client_send_normaltcp/main.o b/offloading_binaries/client_send_normaltcp/main.o index 0f95d9c..4e9e85d 100644 Binary files a/offloading_binaries/client_send_normaltcp/main.o and b/offloading_binaries/client_send_normaltcp/main.o differ diff --git a/offloading_binaries/client_send_normaltcp_sendfile/client_send_normaltcp_sendfile b/offloading_binaries/client_send_normaltcp_sendfile/client_send_normaltcp_sendfile index 9947bbe..e797bda 100755 Binary files a/offloading_binaries/client_send_normaltcp_sendfile/client_send_normaltcp_sendfile and b/offloading_binaries/client_send_normaltcp_sendfile/client_send_normaltcp_sendfile differ diff --git a/offloading_binaries/client_send_normaltcp_sendfile/main.c b/offloading_binaries/client_send_normaltcp_sendfile/main.c index f2e0f59..4c59149 100644 --- a/offloading_binaries/client_send_normaltcp_sendfile/main.c +++ b/offloading_binaries/client_send_normaltcp_sendfile/main.c @@ -84,14 +84,10 @@ int main(int argc, char *argv[]) if ((quota % sendsize) > 0) { // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); - slotLength = (quota / sendsize + 1) * sendsize / quota * slotLength; + slotLength = (uint)((double)(quota / sendsize + 1) * sendsize / quota * slotLength); quota = (quota / sendsize + 1) * sendsize; // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); } - else - { - slotLength = (quota / sendsize) * sendsize / quota * slotLength; - } // get file size (bytes2send) if (isNumber(argv[1])) diff --git a/offloading_binaries/client_send_normaltcp_sendfile/main.o b/offloading_binaries/client_send_normaltcp_sendfile/main.o index 7def226..4d03f51 100644 Binary files a/offloading_binaries/client_send_normaltcp_sendfile/main.o and b/offloading_binaries/client_send_normaltcp_sendfile/main.o differ diff --git a/offloading_binaries/client_send_normaltcp_splice/client_send_normaltcp_splice b/offloading_binaries/client_send_normaltcp_splice/client_send_normaltcp_splice index 7435d5c..5efad6b 100755 Binary files a/offloading_binaries/client_send_normaltcp_splice/client_send_normaltcp_splice and b/offloading_binaries/client_send_normaltcp_splice/client_send_normaltcp_splice differ diff --git a/offloading_binaries/client_send_normaltcp_splice/main.c b/offloading_binaries/client_send_normaltcp_splice/main.c index e94aa6f..54ec998 100644 --- a/offloading_binaries/client_send_normaltcp_splice/main.c +++ b/offloading_binaries/client_send_normaltcp_splice/main.c @@ -84,14 +84,10 @@ int main(int argc, char *argv[]) if ((quota % sendsize) > 0) { // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); - slotLength = (quota / sendsize + 1) * sendsize / quota * slotLength; + slotLength = (uint)((double)(quota / sendsize + 1) * sendsize / quota * slotLength); quota = (quota / sendsize + 1) * sendsize; // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); } - else - { - slotLength = (quota / sendsize) * sendsize / quota * slotLength; - } // get file size (bytes2send) if (isNumber(argv[1])) diff --git a/offloading_binaries/client_send_normaltcp_splice/main.o b/offloading_binaries/client_send_normaltcp_splice/main.o index 959d2c9..629bf5a 100644 Binary files a/offloading_binaries/client_send_normaltcp_splice/main.o and b/offloading_binaries/client_send_normaltcp_splice/main.o differ diff --git a/offloading_binaries/client_send_normaludp/client_send_normaludp b/offloading_binaries/client_send_normaludp/client_send_normaludp index 0ef5807..fd8b4de 100755 Binary files a/offloading_binaries/client_send_normaludp/client_send_normaludp and b/offloading_binaries/client_send_normaludp/client_send_normaludp differ diff --git a/offloading_binaries/client_send_normaludp/main.c b/offloading_binaries/client_send_normaludp/main.c index 80cd359..a287e26 100644 --- a/offloading_binaries/client_send_normaludp/main.c +++ b/offloading_binaries/client_send_normaludp/main.c @@ -82,14 +82,10 @@ int main(int argc, char *argv[]) if ((quota % sendsize) > 0) { // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); - slotLength = (quota / sendsize + 1) * sendsize / quota * slotLength; + slotLength = (uint)((double)(quota / sendsize + 1) * sendsize / quota * slotLength); quota = (quota / sendsize + 1) * sendsize; // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); } - else - { - slotLength = (quota / sendsize) * sendsize / quota * slotLength; - } // get file size (bytes2send) if (isNumber(argv[1])) @@ -125,13 +121,6 @@ int main(int argc, char *argv[]) servaddr.sin_addr.s_addr = inet_addr(argv[2]); servaddr.sin_port = htons(atoi(argv[3])); - // connect socket - if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) - { - fprintf(stderr, "! Unable to connect the server.\n"); - exit(1); - } - // start timing gettimeofday(&t_start, NULL); @@ -142,19 +131,33 @@ int main(int argc, char *argv[]) { quota = bytes2send - total_bytes_sent; } + // initialize ret + ret = 1; // send in slots while (sentInSlot < quota) { // printf( // "before: total_bytes_sent %d, sentInSlot %d, quota - sentInSlot %d\n", // total_bytes_sent, sentInSlot, quota - sentInSlot); - read(fd, sendbuf, (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize); + + // only read when we successfully send the msg + if (ret > 0) + read(fd, sendbuf, (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize); + ret = sendto( sockfd, sendbuf, (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize, 0, (struct sockaddr *)&servaddr, sizeof(servaddr)); + if (ret <= 0) { + if (errno == ECONNREFUSED) + { + fprintf(stderr, "! Connection refused; cannot connect to server.\n"); + close(sockfd); + close(fd); + exit(1); + } fprintf(stderr, "! Fail to send: ret:%d, err:%d; wait for 100us..\n", ret, errno); usleep(100); continue; @@ -179,6 +182,15 @@ int main(int argc, char *argv[]) ++slot; } + ret = sendto(sockfd, "=?!\n", 4, 0, (struct sockaddr *)&servaddr, sizeof(servaddr)); + if (ret <= 0) + { + fprintf(stderr, "! Unable to end data transfer. errno:%d.\n", errno); + close(sockfd); + close(fd); + exit(1); + } + // end timing gettimeofday(&t_end, NULL); elapsedTime = (t_end.tv_sec - t_start.tv_sec) + (t_end.tv_usec - t_start.tv_usec) / 1000000.0; diff --git a/offloading_binaries/client_send_normaludp/main.o b/offloading_binaries/client_send_normaludp/main.o index 9576967..5042d2a 100644 Binary files a/offloading_binaries/client_send_normaludp/main.o and b/offloading_binaries/client_send_normaludp/main.o differ diff --git a/offloading_binaries/makeall.sh b/offloading_binaries/makeall.sh index 482e091..f7a96aa 100644 --- a/offloading_binaries/makeall.sh +++ b/offloading_binaries/makeall.sh @@ -1,20 +1,20 @@ -cd client_send_normaltcp_sendfile && make clean && make +cd client_send_normaltcp_sendfile && make cd ../ -cd client_send_normaltcp_splice && make clean && make +cd client_send_normaltcp_splice && make cd ../ -cd client_send_bypassl3 && make clean && make +cd client_send_bypassl3 && make cd ../ -cd client_send_normaludp && make clean && make +cd client_send_normaludp && make cd ../ -cd client_send_normaltcp && make clean && make +cd client_send_normaltcp && make cd ../ -cd client_readfile_only && make clean && make +cd client_readfile_only && make cd ../ -cd client_recv_normaltcp && make clean && make +cd client_recv_normaltcp && make cd ../ -cd client_recv_normaludp && make clean && make +cd client_recv_normaludp && make cd ../ -cd server_recv_normaltcp && make clean && make +cd server_recv_normaltcp && make cd ../ -cd server_recv_normaludp && make clean && make +cd server_recv_normaludp && make cd ../ diff --git a/offloading_binaries/pushBinToDevice.sh b/offloading_binaries/pushBinToDevice.sh new file mode 100755 index 0000000..91c369e --- /dev/null +++ b/offloading_binaries/pushBinToDevice.sh @@ -0,0 +1,20 @@ +cd client_send_normaltcp_sendfile && adb push client_send_normaltcp_sendfile /data/local/tmp/ +cd ../ +cd client_send_normaltcp_splice && adb push client_send_normaltcp_splice /data/local/tmp/ +cd ../ +cd client_send_bypassl3 && adb push client_send_bypassl3 /data/local/tmp/ +cd ../ +cd client_send_normaludp && adb push client_send_normaludp /data/local/tmp/ +cd ../ +cd client_send_normaltcp && adb push client_send_normaltcp /data/local/tmp/ +cd ../ +cd client_readfile_only && adb push client_readfile_only /data/local/tmp/ +cd ../ +cd client_recv_normaltcp && adb push client_recv_normaltcp /data/local/tmp/ +cd ../ +cd client_recv_normaludp && adb push client_recv_normaludp /data/local/tmp/ +cd ../ +cd server_recv_normaltcp && adb push server_m_recv_normaltcp /data/local/tmp/ +cd ../ +cd server_recv_normaludp && adb push server_m_recv_normaludp /data/local/tmp/ +cd ../