diff options
Diffstat (limited to 'testing/Lossless_UDP_testserver.c')
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index a8097048..4b437f0e 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -45,12 +45,12 @@ | |||
45 | 45 | ||
46 | #define PORT 33445 | 46 | #define PORT 33445 |
47 | 47 | ||
48 | void printpacket(uint8_t * data, uint32_t length, IP_Port ip_port) | 48 | void printpacket(uint8_t *data, uint32_t length, IP_Port ip_port) |
49 | { | 49 | { |
50 | uint32_t i; | 50 | uint32_t i; |
51 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); | 51 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); |
52 | printf("--------------------BEGIN-----------------------------\n"); | 52 | printf("--------------------BEGIN-----------------------------\n"); |
53 | for(i = 0; i < length; i++) { | 53 | for (i = 0; i < length; i++) { |
54 | if(data[i] < 16) | 54 | if(data[i] < 16) |
55 | printf("0"); | 55 | printf("0"); |
56 | printf("%hhX",data[i]); | 56 | printf("%hhX",data[i]); |
@@ -120,10 +120,10 @@ void Lossless_UDP() | |||
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); |
@@ -147,7 +147,8 @@ int main(int argc, char *argv[]) | |||
147 | int read; | 147 | int read; |
148 | 148 | ||
149 | FILE *file = fopen(argv[1], "wb"); | 149 | FILE *file = fopen(argv[1], "wb"); |
150 | if ( file==NULL ){return 1;} | 150 | if (file == NULL) |
151 | return 1; | ||
151 | 152 | ||
152 | 153 | ||
153 | //initialize networking | 154 | //initialize networking |
@@ -161,7 +162,7 @@ int main(int argc, char *argv[]) | |||
161 | uint64_t timer = current_time(); | 162 | uint64_t timer = current_time(); |
162 | 163 | ||
163 | 164 | ||
164 | while(1) { | 165 | while (1) { |
165 | Lossless_UDP(); | 166 | Lossless_UDP(); |
166 | connection = incoming_connection(); | 167 | connection = incoming_connection(); |
167 | if(connection != -1) { | 168 | if(connection != -1) { |
@@ -176,17 +177,16 @@ int main(int argc, char *argv[]) | |||
176 | 177 | ||
177 | timer = current_time(); | 178 | timer = current_time(); |
178 | 179 | ||
179 | while(1) { | 180 | while (1) { |
180 | //printconnection(0); | 181 | //printconnection(0); |
181 | Lossless_UDP(); | 182 | Lossless_UDP(); |
182 | if(is_connected(connection) >= 2) { | 183 | if (is_connected(connection) >= 2) { |
183 | kill_connection_in(connection, 3000000); | 184 | kill_connection_in(connection, 3000000); |
184 | read = read_packet(connection, buffer); | 185 | read = read_packet(connection, buffer); |
185 | if(read != 0) { | 186 | if (read != 0) { |
186 | // printf("Recieved data.\n"); | 187 | // printf("Recieved data.\n"); |
187 | if(!fwrite(buffer, read, 1, file)) { | 188 | if (!fwrite(buffer, read, 1, file)) |
188 | printf("file write error\n"); | 189 | printf("file write error\n"); |
189 | } | ||
190 | } | 190 | } |
191 | } | 191 | } |
192 | if(is_connected(connection) == 4) { | 192 | if(is_connected(connection) == 4) { |