0

I have this situation where I need to measure the bytes sent/received during its execution. The PC will have a normal ethernet interface (eth1) to interact with others in the network. I did a little research on linux network namespace and cgroups, given that, I came to this approach to do the measures.

  • create a new network namespace.
  • create a virtual ethernet pair of interfaces veth0 and veth1.
  • assign veth1 to the previously created namespace leaving veth0 on the default namespace.
  • configure the virtual interfaces and create a bridge between veth0 and eth1.

Given that, I will execute my process on the new namespace and assume the values from veth1 as the bytes sent/received for the process. I know that I can use iproute2 and bridge-utils for the above steps, but is it correct? or there is another way to do that kind of measure?

chrk
  • 4,037
  • 2
  • 39
  • 47
fabiux
  • 11
  • 4
  • Assuming that your application is operating over a unique set of ports, you can simply create `iptables` firewall rules that match those ports and use the byte/packet counts that are maintained automatically by the kernel. – larsks Aug 26 '15 at 19:29
  • Yes, that seems promising. More specifically, I need to measure a java process with two independent NIO servers: an udp server on port 9900 and a tcp server on port 9901. How can I do the measure using iptables? – fabiux Aug 27 '15 at 03:28

0 Answers0