This commit is contained in:
HappyZ 2016-09-27 11:08:09 -07:00
parent f10f497f6e
commit e86f6d56c2
17 changed files with 59 additions and 43 deletions

View File

@ -104,14 +104,10 @@ int main(int argc, char *argv[])
if ((quota % sendsize) > 0) if ((quota % sendsize) > 0)
{ {
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // 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; quota = (quota / sendsize + 1) * sendsize;
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength);
} }
else
{
slotLength = (quota / sendsize) * sendsize / quota * slotLength;
}
// get file size (bytes2send) // get file size (bytes2send)
if (isNumber(argv[1])) if (isNumber(argv[1]))

View File

@ -80,14 +80,10 @@ int main(int argc, char *argv[])
if ((quota % sendsize) > 0) if ((quota % sendsize) > 0)
{ {
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // 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; quota = (quota / sendsize + 1) * sendsize;
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength);
} }
else
{
slotLength = (quota / sendsize) * sendsize / quota * slotLength;
}
// get file size (bytes2send) // get file size (bytes2send)
if (isNumber(argv[1])) if (isNumber(argv[1]))

View File

@ -84,14 +84,10 @@ int main(int argc, char *argv[])
if ((quota % sendsize) > 0) if ((quota % sendsize) > 0)
{ {
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // 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; quota = (quota / sendsize + 1) * sendsize;
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength);
} }
else
{
slotLength = (quota / sendsize) * sendsize / quota * slotLength;
}
// get file size (bytes2send) // get file size (bytes2send)
if (isNumber(argv[1])) if (isNumber(argv[1]))

View File

@ -84,14 +84,10 @@ int main(int argc, char *argv[])
if ((quota % sendsize) > 0) if ((quota % sendsize) > 0)
{ {
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // 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; quota = (quota / sendsize + 1) * sendsize;
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength);
} }
else
{
slotLength = (quota / sendsize) * sendsize / quota * slotLength;
}
// get file size (bytes2send) // get file size (bytes2send)
if (isNumber(argv[1])) if (isNumber(argv[1]))

View File

@ -82,14 +82,10 @@ int main(int argc, char *argv[])
if ((quota % sendsize) > 0) if ((quota % sendsize) > 0)
{ {
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // 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; quota = (quota / sendsize + 1) * sendsize;
// printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength); // printf("quota:%d,sendsize:%d,slotLength:%d\n", quota, sendsize, slotLength);
} }
else
{
slotLength = (quota / sendsize) * sendsize / quota * slotLength;
}
// get file size (bytes2send) // get file size (bytes2send)
if (isNumber(argv[1])) 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_addr.s_addr = inet_addr(argv[2]);
servaddr.sin_port = htons(atoi(argv[3])); 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 // start timing
gettimeofday(&t_start, NULL); gettimeofday(&t_start, NULL);
@ -142,19 +131,33 @@ int main(int argc, char *argv[])
{ {
quota = bytes2send - total_bytes_sent; quota = bytes2send - total_bytes_sent;
} }
// initialize ret
ret = 1;
// send in slots // send in slots
while (sentInSlot < quota) while (sentInSlot < quota)
{ {
// printf( // printf(
// "before: total_bytes_sent %d, sentInSlot %d, quota - sentInSlot %d\n", // "before: total_bytes_sent %d, sentInSlot %d, quota - sentInSlot %d\n",
// total_bytes_sent, sentInSlot, quota - sentInSlot); // total_bytes_sent, sentInSlot, quota - sentInSlot);
// only read when we successfully send the msg
if (ret > 0)
read(fd, sendbuf, (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize); read(fd, sendbuf, (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize);
ret = sendto( ret = sendto(
sockfd, sendbuf, sockfd, sendbuf,
(quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize, (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize,
0, (struct sockaddr *)&servaddr, sizeof(servaddr)); 0, (struct sockaddr *)&servaddr, sizeof(servaddr));
if (ret <= 0) 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); fprintf(stderr, "! Fail to send: ret:%d, err:%d; wait for 100us..\n", ret, errno);
usleep(100); usleep(100);
continue; continue;
@ -179,6 +182,15 @@ int main(int argc, char *argv[])
++slot; ++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 // end timing
gettimeofday(&t_end, NULL); gettimeofday(&t_end, NULL);
elapsedTime = (t_end.tv_sec - t_start.tv_sec) + (t_end.tv_usec - t_start.tv_usec) / 1000000.0; elapsedTime = (t_end.tv_sec - t_start.tv_sec) + (t_end.tv_usec - t_start.tv_usec) / 1000000.0;

View File

@ -1,20 +1,20 @@
cd client_send_normaltcp_sendfile && make clean && make cd client_send_normaltcp_sendfile && make
cd ../ cd ../
cd client_send_normaltcp_splice && make clean && make cd client_send_normaltcp_splice && make
cd ../ cd ../
cd client_send_bypassl3 && make clean && make cd client_send_bypassl3 && make
cd ../ cd ../
cd client_send_normaludp && make clean && make cd client_send_normaludp && make
cd ../ cd ../
cd client_send_normaltcp && make clean && make cd client_send_normaltcp && make
cd ../ cd ../
cd client_readfile_only && make clean && make cd client_readfile_only && make
cd ../ cd ../
cd client_recv_normaltcp && make clean && make cd client_recv_normaltcp && make
cd ../ cd ../
cd client_recv_normaludp && make clean && make cd client_recv_normaludp && make
cd ../ cd ../
cd server_recv_normaltcp && make clean && make cd server_recv_normaltcp && make
cd ../ cd ../
cd server_recv_normaludp && make clean && make cd server_recv_normaludp && make
cd ../ cd ../

View File

@ -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 ../