This repository has been archived by the owner on Oct 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathINSTALL
57 lines (45 loc) · 1.96 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
BUILDING SJPCAP
To build sjpcap, type ant from the directory containing this INSTALL file. ant
will compile sjpcap's source files and create sjpcap.jar.
HISTORY
R 0.2 - Parsing robustness enhancements, packet timestamps.
R 0.1 - Initial release.
USING SJPCAP
The following example class provides an overview of how to use sjpcap to
obtain object representations of packets in libpcap-created files.
import edu.gatech.sjpcap.*;
public class PcapPrint{
public static void main(String[] args){
PcapParser pcapParser = new PcapParser();
if(pcapParser.openFile(args[0]) < 0){
System.err.println("Failed to open " + args[0] + ", exiting.");
return;
}
Packet packet = pcapParser.getPacket();
while(packet != Packet.EOF){
if(!(packet instanceof IPPacket)){
packet = pcapParser.getPacket();
continue;
}
System.out.println("--PACKET--");
IPPacket ipPacket = (IPPacket) packet;
System.out.println("TIME " + ipPacket.timestamp / 1000);
System.out.println("SRC " + ipPacket.src_ip.getHostAddress());
System.out.println("DST " + ipPacket.dst_ip.getHostAddress());
if(ipPacket instanceof UDPPacket){
UDPPacket udpPacket = (UDPPacket) ipPacket;
System.out.println("SRC PORT " + udpPacket.src_port);
System.out.println("DST PORT " + udpPacket.dst_port);
System.out.println("PAYLOAD LEN " + udpPacket.data.length);
}
if(ipPacket instanceof TCPPacket){
TCPPacket tcpPacket = (TCPPacket) ipPacket;
System.out.println("SRC PORT " + tcpPacket.src_port);
System.out.println("DST PORT " + tcpPacket.dst_port);
System.out.println("PAYLOAD LEN " + tcpPacket.data.length);
}
packet = pcapParser.getPacket();
}
pcapParser.closeFile();
}
}