diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-20 19:20:42 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-20 19:20:42 -0400 |
commit | c7aafcfb4cff44a60fa54fa55cd9e3519b30e720 (patch) | |
tree | 1ddc1b08d219aedacc7af4045e112d4496eb8d4a /testing | |
parent | 86b11394b106b89b91c34e0321ef108a65617fbb (diff) |
Lossless UDP tests fixed.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/Lossless_UDP_testclient.c | 32 | ||||
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 32 |
2 files changed, 32 insertions, 32 deletions
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index 575be2bd..0218de4f 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c | |||
@@ -122,8 +122,8 @@ void printconnection(int connection_id) | |||
122 | 122 | ||
123 | /*( receive packets and send them to the packethandler */ | 123 | /*( receive packets and send them to the packethandler */ |
124 | /*run doLossless_UDP(); */ | 124 | /*run doLossless_UDP(); */ |
125 | void Lossless_UDP() | 125 | //void Lossless_UDP() |
126 | { | 126 | //{ |
127 | /* IP_Port ip_port; | 127 | /* IP_Port ip_port; |
128 | uint8_t data[MAX_UDP_PACKET_SIZE]; | 128 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
129 | uint32_t length; | 129 | uint32_t length; |
@@ -140,11 +140,11 @@ void Lossless_UDP() | |||
140 | /* } */ | 140 | /* } */ |
141 | /* }*/ | 141 | /* }*/ |
142 | 142 | ||
143 | networking_poll(); | 143 | //networking_poll(); |
144 | 144 | ||
145 | doLossless_UDP(); | 145 | //doLossless_UDP(); |
146 | 146 | ||
147 | } | 147 | //} |
148 | 148 | ||
149 | int main(int argc, char *argv[]) | 149 | int main(int argc, char *argv[]) |
150 | { | 150 | { |
@@ -166,25 +166,26 @@ int main(int argc, char *argv[]) | |||
166 | /* bind to ip 0.0.0.0:PORT */ | 166 | /* bind to ip 0.0.0.0:PORT */ |
167 | IP ip; | 167 | IP ip; |
168 | ip.i = 0; | 168 | ip.i = 0; |
169 | init_networking(ip, PORT); | 169 | Lossless_UDP * ludp = new_lossless_udp(new_networking(ip, PORT)); |
170 | perror("Initialization"); | 170 | perror("Initialization"); |
171 | IP_Port serverip; | 171 | IP_Port serverip; |
172 | serverip.ip.i = inet_addr(argv[1]); | 172 | serverip.ip.i = inet_addr(argv[1]); |
173 | serverip.port = htons(atoi(argv[2])); | 173 | serverip.port = htons(atoi(argv[2])); |
174 | printip(serverip); | 174 | printip(serverip); |
175 | int connection = new_connection(serverip); | 175 | int connection = new_connection(ludp, serverip); |
176 | uint64_t timer = current_time(); | 176 | uint64_t timer = current_time(); |
177 | 177 | ||
178 | while (1) { | 178 | while (1) { |
179 | /* printconnection(connection); */ | 179 | /* printconnection(connection); */ |
180 | Lossless_UDP(); | 180 | networking_poll(ludp->net); |
181 | do_lossless_udp(ludp); | ||
181 | 182 | ||
182 | if (is_connected(connection) == 3) { | 183 | if (is_connected(ludp, connection) == 3) { |
183 | printf("Connecting took: %llu us\n", (unsigned long long)(current_time() - timer)); | 184 | printf("Connecting took: %llu us\n", (unsigned long long)(current_time() - timer)); |
184 | break; | 185 | break; |
185 | } | 186 | } |
186 | 187 | ||
187 | if (is_connected(connection) == 0) { | 188 | if (is_connected(ludp, connection) == 0) { |
188 | printf("Connection timeout after: %llu us\n", (unsigned long long)(current_time() - timer)); | 189 | printf("Connection timeout after: %llu us\n", (unsigned long long)(current_time() - timer)); |
189 | return 1; | 190 | return 1; |
190 | } | 191 | } |
@@ -194,25 +195,24 @@ int main(int argc, char *argv[]) | |||
194 | 195 | ||
195 | timer = current_time(); | 196 | timer = current_time(); |
196 | 197 | ||
197 | LosslessUDP_init(); | ||
198 | 198 | ||
199 | /*read first part of file */ | 199 | /*read first part of file */ |
200 | read = fread(buffer, 1, 512, file); | 200 | read = fread(buffer, 1, 512, file); |
201 | 201 | ||
202 | while (1) { | 202 | while (1) { |
203 | /* printconnection(connection); */ | 203 | /* printconnection(connection); */ |
204 | Lossless_UDP(); | 204 | networking_poll(ludp->net); |
205 | 205 | do_lossless_udp(ludp); | |
206 | if (is_connected(connection) == 3) { | 206 | if (is_connected(ludp, connection) == 3) { |
207 | 207 | ||
208 | if (write_packet(connection, buffer, read)) { | 208 | if (write_packet(ludp, connection, buffer, read)) { |
209 | /* printf("Wrote data.\n"); */ | 209 | /* printf("Wrote data.\n"); */ |
210 | read = fread(buffer, 1, 512, file); | 210 | read = fread(buffer, 1, 512, file); |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | /* printf("%u\n", sendqueue(connection)); */ | 214 | /* printf("%u\n", sendqueue(connection)); */ |
215 | if (sendqueue(connection) == 0) { | 215 | if (sendqueue(ludp, connection) == 0) { |
216 | if (read == 0) { | 216 | if (read == 0) { |
217 | printf("Sent file successfully in: %llu us\n", (unsigned long long)(current_time() - timer)); | 217 | printf("Sent file successfully in: %llu us\n", (unsigned long long)(current_time() - timer)); |
218 | break; | 218 | break; |
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index dec50d7f..c3212888 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -118,8 +118,8 @@ void printconnection(int connection_id) | |||
118 | 118 | ||
119 | /* receive packets and send them to the packethandler | 119 | /* receive packets and send them to the packethandler |
120 | * run doLossless_UDP(); */ | 120 | * run doLossless_UDP(); */ |
121 | void Lossless_UDP() | 121 | //void Lossless_UDP() |
122 | { | 122 | //{ |
123 | // IP_Port ip_port; | 123 | // IP_Port ip_port; |
124 | // uint8_t data[MAX_UDP_PACKET_SIZE]; | 124 | // uint8_t data[MAX_UDP_PACKET_SIZE]; |
125 | // uint32_t length; | 125 | // uint32_t length; |
@@ -135,10 +135,10 @@ void Lossless_UDP() | |||
135 | //} | 135 | //} |
136 | // } | 136 | // } |
137 | 137 | ||
138 | networking_poll(); | 138 | // networking_poll(); |
139 | 139 | ||
140 | doLossless_UDP(); | 140 | //doLossless_UDP(); |
141 | } | 141 | //} |
142 | 142 | ||
143 | 143 | ||
144 | int main(int argc, char *argv[]) | 144 | int main(int argc, char *argv[]) |
@@ -161,20 +161,19 @@ int main(int argc, char *argv[]) | |||
161 | //bind to ip 0.0.0.0:PORT | 161 | //bind to ip 0.0.0.0:PORT |
162 | IP ip; | 162 | IP ip; |
163 | ip.i = 0; | 163 | ip.i = 0; |
164 | init_networking(ip, PORT); | 164 | Lossless_UDP * ludp = new_lossless_udp(new_networking(ip, PORT)); |
165 | perror("Initialization"); | 165 | perror("Initialization"); |
166 | 166 | ||
167 | int connection; | 167 | int connection; |
168 | uint64_t timer = current_time(); | 168 | uint64_t timer = current_time(); |
169 | 169 | ||
170 | LosslessUDP_init(); | ||
171 | |||
172 | while (1) { | 170 | while (1) { |
173 | Lossless_UDP(); | 171 | networking_poll(ludp->net); |
174 | connection = incoming_connection(); | 172 | do_lossless_udp(ludp); |
173 | connection = incoming_connection(ludp); | ||
175 | 174 | ||
176 | if (connection != -1) { | 175 | if (connection != -1) { |
177 | if (is_connected(connection) == 2) { | 176 | if (is_connected(ludp, connection) == 2) { |
178 | printf("Received the connection.\n"); | 177 | printf("Received the connection.\n"); |
179 | 178 | ||
180 | } | 179 | } |
@@ -189,11 +188,12 @@ int main(int argc, char *argv[]) | |||
189 | 188 | ||
190 | while (1) { | 189 | while (1) { |
191 | //printconnection(0); | 190 | //printconnection(0); |
192 | Lossless_UDP(); | 191 | networking_poll(ludp->net); |
192 | do_lossless_udp(ludp); | ||
193 | 193 | ||
194 | if (is_connected(connection) >= 2) { | 194 | if (is_connected(ludp, connection) >= 2) { |
195 | kill_connection_in(connection, 3000000); | 195 | kill_connection_in(ludp, connection, 3000000); |
196 | read = read_packet(connection, buffer); | 196 | read = read_packet(ludp, connection, buffer); |
197 | 197 | ||
198 | if (read != 0) { | 198 | if (read != 0) { |
199 | // printf("Received data.\n"); | 199 | // printf("Received data.\n"); |
@@ -202,7 +202,7 @@ int main(int argc, char *argv[]) | |||
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | if (is_connected(connection) == 4) { | 205 | if (is_connected(ludp, connection) == 4) { |
206 | printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); | 206 | printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); |
207 | fclose(file); | 207 | fclose(file); |
208 | return 1; | 208 | return 1; |