How to automate measuring of bandwidth usage between two hosts

戏子无情 提交于 2019-12-02 04:37:23

Bro is an appropriate tool to measure connection-oriented statistics. You can either record a trace of your application communication or analyze it in realtime:

bro -r <trace>
bro -i <interface>

Thereafter, have a look at the connection log (conn.log) in the same directory for the amount of bytes sent and received by the application. Specifically, you're interested in the TCP payload size, which conn.log exposes via the columns orig_bytes and resp_bytes. Here is an example:

bro-cut id.orig_h id.resp_h conn_state orig_bytes resp_bytes < conn.log | head 

which yields the following output:

192.168.1.102   192.168.1.1     SF      301     300
192.168.1.103   192.168.1.255   S0      350     0
192.168.1.102   192.168.1.255   S0      350     0
192.168.1.103   192.168.1.255   S0      560     0
192.168.1.102   192.168.1.255   S0      348     0
192.168.1.104   192.168.1.255   S0      350     0
192.168.1.104   192.168.1.255   S0      549     0
192.168.1.103   192.168.1.1     SF      303     300
192.168.1.102   192.168.1.255   S0      -       -
192.168.1.104   192.168.1.1     SF      311     300

Each row represents a single connection, transport-layer ports omitted. The last two columns represent the bytes sent by the originator (first column) and responder (second column). The column conn_state represents the connection status. Please refer to the documentation for all possible field values. Some important values are:

  • S0: Connection attempt seen, no reply.
  • S1: Connection established, not terminated.
  • SF: Normal establishment and termination. Note that this is the same symbol as for state S1. You can tell the two apart because for S1 there will not be any byte counts in the summary, while for SF there will be.
  • REJ: Connection attempt rejected.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!