2010-04-15 39 views

回答

4

您必須將Packet對象轉換爲我認爲正確的Packet類型。

因此,像:

TCPPacket p = (TCPPacket)packet; 

// Get the tcp src and dest ports 
int destPort = p.dst_port; 
int srcPort = p.src_port; 

// Get the src and dest IP addresses from the IP layer 
InetAddress destIp = p.dst_ip; 
InetAddress srcIp = p.src_ip; 
+0

感謝訪問的數據包信息的好example!你救了我這麼多醜陋的解析 – 2010-04-15 05:26:46

1

下面是關於使用JPCAP包