How to calculate/validate captured data size on Wireshark

谁都会走 提交于 2019-12-24 09:41:33

问题


I want to monitor data size transferred into and out of my database. I'm using a Java client application & Firebird v2.5 database. Both are deployed locally on one machine.

It turns out that Firebird does not provide any monitoring variable like "Bytes_received" or "Bytes_sent" that are available in MySQL. as discussed in Is there any way to monitor the size of data transfer In/Out of database

So I set up some tools to capture the local traffic and analyse it.

  1. WireShark - to analyse the captured data
  2. RawCap - to capture traffic on the loopback address as 'Wincap' was unable to capture local traffic because of OS limitations i.e for Windows - RawCap download link

I created a test database and a sample table with two columns

CREATE TABLE test_table ( id bigint default null, test_col varchar(6) default null);

And populated the table with 1000 entries

id with0, 1, 2, 3, . . . 999 & test_col with ABCDEF

Now RawCap is running & using a simple Java Client app to retrieve all rows.

Now 8 bytes for a bigint size and 6+2=8 bytes for varchar(6) equals 16 bytes per row. And 16KB for 1000 rows. That's my estimation only rihgt, but when I open the dump file created by RawCap in wireshark, apply the display filter of 'gdsdb' as I'm only interested in the DB traffic, open the Statistics > Conversations windows. Bytes received from database server to application is almost twice the size then expected. i.e 33KB

Any idea Why I'm receiving almost double then what expected?

Java Client Source Code

public class TestClient {
    static Connection dbConnection = null;
    public static void main(String[] args) throws ClassNotFoundException {
        try {
            Class.forName("org.firebirdsql.jdbc.FBDriver");
            String dbURL = "jdbc:firebirdsql://127.0.0.1:3050/C:\\databases2\\TESTDB.FDB";
            String user = "sysdba";
            String password = "masterkey";

            dbConnection = DriverManager.getConnection(dbURL,user, password);
            dbConnection.setAutoCommit(false);
            PreparedStatement stmt = dbConnection.prepareStatement("SELECT * FROM test_table");
            ResultSet rs = stmt.executeQuery();

            int j = 0;
            int i = 0; 
            String s = "";
            while (rs.next()) {
                i++;
                j = rs.getInt("id");
                s = rs.getString("text_col");
            }
            System.out.println(String.format("Finished reading %d rows.", i));
            rs.close();
            stmt.close();
            dbConnection.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
}

来源:https://stackoverflow.com/questions/40894820/how-to-calculate-validate-captured-data-size-on-wireshark

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!