diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-16 10:22:32 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-16 10:22:32 -0400 |
commit | d62b91f3ac220f7832aa73e20e632c8f34fd1177 (patch) | |
tree | 660ca210156fad369604edcba405581e3c6c4cf5 /testing | |
parent | 619ecb0bb35f62d39afdc91b87f5c267f905ec0c (diff) |
Lossless UDP tests fixed.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/Lossless_UDP_testclient.c | 20 | ||||
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 17 |
2 files changed, 19 insertions, 18 deletions
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index cc12206b..0c21867d 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | #define PORT 33446 | 28 | #define PORT 33446 |
29 | 29 | ||
30 | void printpacket(char * data, uint32_t length, IP_Port ip_port) | 30 | void printpacket(uint8_t * data, uint32_t length, IP_Port ip_port) |
31 | { | 31 | { |
32 | uint32_t i; | 32 | uint32_t i; |
33 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); | 33 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); |
@@ -104,13 +104,13 @@ void printconnection(int connection_id) | |||
104 | void Lossless_UDP() | 104 | void Lossless_UDP() |
105 | { | 105 | { |
106 | IP_Port ip_port; | 106 | IP_Port ip_port; |
107 | char data[MAX_UDP_PACKET_SIZE]; | 107 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
108 | uint32_t length; | 108 | uint32_t length; |
109 | while(receivepacket(&ip_port, data, &length) != -1) | 109 | while(receivepacket(&ip_port, data, &length) != -1) |
110 | { | 110 | { |
111 | printf("packet with length: %u\n", length); | 111 | printf("packet with length: %u\n", length); |
112 | if(rand() % 3 != 1)//add packet loss | 112 | //if(rand() % 3 != 1)//add packet loss |
113 | { | 113 | // { |
114 | if(LosslessUDP_handlepacket(data, length, ip_port)) | 114 | if(LosslessUDP_handlepacket(data, length, ip_port)) |
115 | { | 115 | { |
116 | printpacket(data, length, ip_port); | 116 | printpacket(data, length, ip_port); |
@@ -118,9 +118,9 @@ void Lossless_UDP() | |||
118 | else | 118 | else |
119 | { | 119 | { |
120 | //printconnection(0); | 120 | //printconnection(0); |
121 | printf("Received handled packet with length: %u\n", length); | 121 | printf("Received handled packet with length: %u\n", length); |
122 | } | 122 | } |
123 | } | 123 | // } |
124 | } | 124 | } |
125 | 125 | ||
126 | doLossless_UDP(); | 126 | doLossless_UDP(); |
@@ -136,7 +136,7 @@ int main(int argc, char *argv[]) | |||
136 | exit(0); | 136 | exit(0); |
137 | } | 137 | } |
138 | 138 | ||
139 | char buffer[128]; | 139 | uint8_t buffer[512]; |
140 | int read; | 140 | int read; |
141 | 141 | ||
142 | FILE *file = fopen(argv[3], "rb"); | 142 | FILE *file = fopen(argv[3], "rb"); |
@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) | |||
175 | 175 | ||
176 | 176 | ||
177 | //read first part of file | 177 | //read first part of file |
178 | read = fread(buffer, 1, 128, file); | 178 | read = fread(buffer, 1, 512, file); |
179 | 179 | ||
180 | while(1) | 180 | while(1) |
181 | { | 181 | { |
@@ -187,7 +187,7 @@ int main(int argc, char *argv[]) | |||
187 | if(write_packet(connection, buffer, read)) | 187 | if(write_packet(connection, buffer, read)) |
188 | { | 188 | { |
189 | //printf("Wrote data.\n"); | 189 | //printf("Wrote data.\n"); |
190 | read = fread(buffer, 1, 128, file); | 190 | read = fread(buffer, 1, 512, file); |
191 | 191 | ||
192 | } | 192 | } |
193 | //printf("%u\n", sendqueue(connection)); | 193 | //printf("%u\n", sendqueue(connection)); |
@@ -205,7 +205,7 @@ int main(int argc, char *argv[]) | |||
205 | printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); | 205 | printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); |
206 | return 0; | 206 | return 0; |
207 | } | 207 | } |
208 | c_sleep(1); | 208 | //c_sleep(1); |
209 | } | 209 | } |
210 | 210 | ||
211 | return 0; | 211 | return 0; |
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index 2e369b30..8043be25 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #define PORT 33445 | 29 | #define PORT 33445 |
30 | 30 | ||
31 | void printpacket(char * data, uint32_t length, IP_Port ip_port) | 31 | void printpacket(uint8_t * data, uint32_t length, IP_Port ip_port) |
32 | { | 32 | { |
33 | uint32_t i; | 33 | uint32_t i; |
34 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); | 34 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); |
@@ -100,12 +100,12 @@ void printconnection(int connection_id) | |||
100 | void Lossless_UDP() | 100 | void Lossless_UDP() |
101 | { | 101 | { |
102 | IP_Port ip_port; | 102 | IP_Port ip_port; |
103 | char data[MAX_UDP_PACKET_SIZE]; | 103 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
104 | uint32_t length; | 104 | uint32_t length; |
105 | while(receivepacket(&ip_port, data, &length) != -1) | 105 | while(receivepacket(&ip_port, data, &length) != -1) |
106 | { | 106 | { |
107 | if(rand() % 3 != 1)//add packet loss | 107 | //if(rand() % 3 != 1)//add packet loss |
108 | { | 108 | //{ |
109 | if(LosslessUDP_handlepacket(data, length, ip_port)) | 109 | if(LosslessUDP_handlepacket(data, length, ip_port)) |
110 | { | 110 | { |
111 | printpacket(data, length, ip_port); | 111 | printpacket(data, length, ip_port); |
@@ -113,9 +113,9 @@ void Lossless_UDP() | |||
113 | else | 113 | else |
114 | { | 114 | { |
115 | //printconnection(0); | 115 | //printconnection(0); |
116 | // printf("Received handled packet with length: %u\n", length); | 116 | printf("Received handled packet with length: %u\n", length); |
117 | } | 117 | } |
118 | } | 118 | //} |
119 | } | 119 | } |
120 | 120 | ||
121 | doLossless_UDP(); | 121 | doLossless_UDP(); |
@@ -131,7 +131,7 @@ int main(int argc, char *argv[]) | |||
131 | exit(0); | 131 | exit(0); |
132 | } | 132 | } |
133 | 133 | ||
134 | char buffer[128]; | 134 | uint8_t buffer[512]; |
135 | int read; | 135 | int read; |
136 | 136 | ||
137 | FILE *file = fopen(argv[1], "wb"); | 137 | FILE *file = fopen(argv[1], "wb"); |
@@ -173,6 +173,7 @@ int main(int argc, char *argv[]) | |||
173 | Lossless_UDP(); | 173 | Lossless_UDP(); |
174 | if(is_connected(connection) >= 2) | 174 | if(is_connected(connection) >= 2) |
175 | { | 175 | { |
176 | kill_connection_in(connection, 3000000); | ||
176 | read = read_packet(connection, buffer); | 177 | read = read_packet(connection, buffer); |
177 | if(read != 0) | 178 | if(read != 0) |
178 | { | 179 | { |
@@ -183,7 +184,7 @@ int main(int argc, char *argv[]) | |||
183 | } | 184 | } |
184 | } | 185 | } |
185 | } | 186 | } |
186 | else | 187 | if(is_connected(connection) == 4) |
187 | { | 188 | { |
188 | printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); | 189 | printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); |
189 | fclose(file); | 190 | fclose(file); |