long dropto;
double dropin;
double dropout;
+long total_out;
+long total_in;
+
void debug(const char *format, ...) {
struct timeval now;
if(outpktno < dropto && outpktno >= dropfrom && drand48() < dropout)
return len;
+ total_out += len;
ssize_t result = send(s, data, len, MSG_DONTWAIT);
if(result <= 0)
debug("Error sending UDP packet: %s\n", strerror(errno));
if(fds[0].revents) {
fds[0].revents = 0;
- debug("stdin");
+ debug("stdin\n");
ssize_t len = read(0, buf, max);
if(len <= 0) {
fds[0].fd = -1;
if(!connect(s, (struct sockaddr *)&ss, sl))
connected = true;
inpktno++;
- if(inpktno >= dropto || inpktno < dropfrom || drand48() >= dropin)
+ if(inpktno >= dropto || inpktno < dropfrom || drand48() >= dropin) {
+ total_in += len;
utcp_recv(u, buf, len);
+ }
}
timeout = utcp_timeout(u);
utcp_close(c);
utcp_exit(u);
+ debug("Total bytes in: %ld, out: %ld\n", total_in, total_out);
+
return 0;
}