diff --git a/emulate.c b/emulate.c index 15e2a05..c54c4fc 100644 --- a/emulate.c +++ b/emulate.c @@ -103,6 +103,8 @@ int emulate(int argc, char *argv[]) struct rtnl_tc *qdisc_netem = NULL; struct rtnl_tc *cls_fw = NULL; + struct tc_statistics stats_netem; + /* Create connection to netlink */ sock = nl_socket_alloc(); nl_connect(sock, NETLINK_ROUTE); @@ -152,7 +154,9 @@ int emulate(int argc, char *argv[]) nl_object_dump((struct nl_object *) qdisc_prio, &dp_param); nl_object_dump((struct nl_object *) cls_fw, &dp_param); #endif + tc_print_netem(qdisc_netem); + tc_print_stats(&stats_netem); next_line: len = getline(&line, &linelen, stdin); if (len < 0 && errno == ENOENT) @@ -180,4 +184,4 @@ next_line: len = getline(&line, &linelen, stdin); nl_socket_free(sock); return 0; -} \ No newline at end of file +} diff --git a/tc.c b/tc.c index 76f58a9..edf2bf3 100644 --- a/tc.c +++ b/tc.c @@ -125,9 +125,9 @@ int tc_get_stats(struct nl_sock *sock, struct rtnl_tc *tc, struct tc_stats *stat return 0; } -int tc_print_stats(struct tc_stats *stats) +int tc_print_stats(struct tc_statistics *stats) { - return 0; + printf("packets %u bytes %u\n", stats->packets, stats->bytes); } int tc_print_netem(struct rtnl_tc *tc) diff --git a/tc.h b/tc.h index 7a698b5..e8c0fe0 100644 --- a/tc.h +++ b/tc.h @@ -12,7 +12,7 @@ #include #include -/*struct tc_stats { +struct tc_statistics { uint64_t packets; // Number of packets seen. uint64_t bytes; // Total bytes seen. uint64_t rate_bps; // Current bits/s (rate estimator) @@ -22,7 +22,7 @@ uint64_t drops; // Total number of packets dropped. uint64_t requeues; // Total number of requeues. uint64_t overlimits; // Total number of overlimits. -};*/ +}; struct rtnl_link * tc_get_link(struct nl_sock *sock, const char *dev); @@ -36,8 +36,8 @@ int tc_reset(struct nl_sock *sock, struct rtnl_link *link); int tc_get_stats(struct nl_sock *sock, struct rtnl_tc *tc, struct tc_stats *stats); -int tc_print_stats(struct tc_stats *stats); +int tc_print_stats(struct tc_statistics *stats); int tc_print_netem(struct rtnl_tc *tc); -#endif \ No newline at end of file +#endif