Basic support for TCP and UDP statistics

Some work for issue #2.