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?