如何在Wireshark上计算/验证捕获的数据大小

时间:2016-11-30 17:40:39

标签: java monitoring firebird wireshark

我希望监控传入和传出数据库的数据大小。 我正在使用Java客户端应用程序& Firebird v2.5数据库。两者都在一台机器上本地部署。

事实证明,Firebird不提供任何监控变量,例如" Bytes_received"或" Bytes_sent"在MySQL中可用。正如Is there any way to monitor the size of data transfer In/Out of database

中所讨论的那样

所以我设置了一些工具来捕获本地流量并进行分析。

  1. WireShark - 分析捕获的数据
  2. RawCap - 将环回地址上的流量捕获为' Wincap'因操作系统限制而无法捕获本地流量,例如Windows - RawCap download link
  3. 我创建了一个测试数据库和一个包含两列的样本表

      

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

    用1000个条目填充表格

    id with0,1,2,3 ,. 。 。 999&带有ABCDEF的test_col

    现在RawCap正在运行&使用简单的Java客户端应用程序检索所有行。

    现在,bigint大小为8个字节,varchar(6)为6 + 2 = 8个字节,每行等于16个字节。 1000行16KB。这只是我的估计,但是当我在wireshark中打开RawCap创建的转储文件时,应用' gdsdb'的显示过滤器。因为我只对数据库流量感兴趣,请打开统计信息>对话窗口。从数据库服务器接收到应用程序的字节数几乎是预期的两倍。即33KB

    任何想法为什么我的收入几乎是预期的两倍?

    Statistics > Conversation Stats

    Java客户端源代码

    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();
            }
        }
    }
    

0 个答案:

没有答案
相关问题