diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/DHT_test.c | 11 | ||||
-rw-r--r-- | testing/Lossless_UDP_testclient.c | 12 | ||||
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 23 |
3 files changed, 31 insertions, 15 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index c8feaf4b..350093fd 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -156,14 +156,20 @@ int main(int argc, char *argv[]) | |||
156 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); | 156 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); |
157 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); | 157 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); |
158 | 158 | ||
159 | /* | ||
159 | IP_Port ip_port; | 160 | IP_Port ip_port; |
160 | uint8_t data[MAX_UDP_PACKET_SIZE]; | 161 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
161 | uint32_t length; | 162 | uint32_t length; |
163 | */ | ||
164 | |||
165 | DHT_init(); | ||
166 | friendreq_init(); | ||
162 | 167 | ||
163 | while(1) { | 168 | while(1) { |
164 | 169 | ||
165 | doDHT(); | 170 | doDHT(); |
166 | 171 | ||
172 | /* slvrTODO: | ||
167 | while(receivepacket(&ip_port, data, &length) != -1) { | 173 | while(receivepacket(&ip_port, data, &length) != -1) { |
168 | if(DHT_handlepacket(data, length, ip_port) && friendreq_handlepacket(data, length, ip_port)) { | 174 | if(DHT_handlepacket(data, length, ip_port) && friendreq_handlepacket(data, length, ip_port)) { |
169 | //unhandled packet | 175 | //unhandled packet |
@@ -172,11 +178,14 @@ int main(int argc, char *argv[]) | |||
172 | printf("Received handled packet with length: %u\n", length); | 178 | printf("Received handled packet with length: %u\n", length); |
173 | } | 179 | } |
174 | } | 180 | } |
181 | */ | ||
182 | networking_poll(); | ||
183 | |||
175 | print_clientlist(); | 184 | print_clientlist(); |
176 | print_friendlist(); | 185 | print_friendlist(); |
177 | c_sleep(300); | 186 | c_sleep(300); |
178 | } | 187 | } |
179 | 188 | ||
180 | shutdown_networking(); | 189 | shutdown_networking(); |
181 | return 0; | 190 | return 0; |
182 | } | 191 | } |
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index 78aff1a3..7efafa4f 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c | |||
@@ -120,20 +120,23 @@ void printconnection(int connection_id) | |||
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; |
126 | while (receivepacket(&ip_port, data, &length) != -1) { | 126 | while (receivepacket(&ip_port, data, &length) != -1) { |
127 | printf("packet with length: %u\n", length); | 127 | printf("packet with length: %u\n", length); */ |
128 | /* if(rand() % 3 != 1)//add packet loss | 128 | /* if(rand() % 3 != 1)//add packet loss |
129 | { */ | 129 | { */ |
130 | /* | ||
130 | if (LosslessUDP_handlepacket(data, length, ip_port)) | 131 | if (LosslessUDP_handlepacket(data, length, ip_port)) |
131 | printpacket(data, length, ip_port); | 132 | printpacket(data, length, ip_port); |
132 | else | 133 | else |
133 | printf("Received handled packet with length: %u\n", length); //printconnection(0); | 134 | printf("Received handled packet with length: %u\n", length); //printconnection(0); */ |
134 | 135 | ||
135 | /* } */ | 136 | /* } */ |
136 | } | 137 | /* }*/ |
138 | |||
139 | networking_poll(); | ||
137 | 140 | ||
138 | doLossless_UDP(); | 141 | doLossless_UDP(); |
139 | 142 | ||
@@ -181,6 +184,7 @@ int main(int argc, char *argv[]) | |||
181 | } | 184 | } |
182 | timer = current_time(); | 185 | timer = current_time(); |
183 | 186 | ||
187 | LosslessUDP_init(); | ||
184 | 188 | ||
185 | /*read first part of file */ | 189 | /*read first part of file */ |
186 | read = fread(buffer, 1, 512, file); | 190 | read = fread(buffer, 1, 512, file); |
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index f4b144b4..bc4fed7a 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -117,20 +117,22 @@ void printconnection(int connection_id) | |||
117 | * run doLossless_UDP(); */ | 117 | * run doLossless_UDP(); */ |
118 | void Lossless_UDP() | 118 | void Lossless_UDP() |
119 | { | 119 | { |
120 | IP_Port ip_port; | 120 | // IP_Port ip_port; |
121 | uint8_t data[MAX_UDP_PACKET_SIZE]; | 121 | // uint8_t data[MAX_UDP_PACKET_SIZE]; |
122 | uint32_t length; | 122 | // uint32_t length; |
123 | while (receivepacket(&ip_port, data, &length) != -1) { | 123 | // while (receivepacket(&ip_port, data, &length) != -1) { |
124 | //if(rand() % 3 != 1)//add packet loss | 124 | //if(rand() % 3 != 1)//add packet loss |
125 | //{ | 125 | //{ |
126 | if (LosslessUDP_handlepacket(data, length, ip_port)) { | 126 | // if (LosslessUDP_handlepacket(data, length, ip_port)) { |
127 | printpacket(data, length, ip_port); | 127 | // printpacket(data, length, ip_port); |
128 | } else { | 128 | // } else { |
129 | //printconnection(0); | 129 | //printconnection(0); |
130 | printf("Received handled packet with length: %u\n", length); | 130 | // printf("Received handled packet with length: %u\n", length); |
131 | } | 131 | // } |
132 | //} | 132 | //} |
133 | } | 133 | // } |
134 | |||
135 | networking_poll(); | ||
134 | 136 | ||
135 | doLossless_UDP(); | 137 | doLossless_UDP(); |
136 | } | 138 | } |
@@ -161,6 +163,7 @@ int main(int argc, char *argv[]) | |||
161 | int connection; | 163 | int connection; |
162 | uint64_t timer = current_time(); | 164 | uint64_t timer = current_time(); |
163 | 165 | ||
166 | LosslessUDP_init(); | ||
164 | 167 | ||
165 | while (1) { | 168 | while (1) { |
166 | Lossless_UDP(); | 169 | Lossless_UDP(); |