如何从 pcap 文件中过滤 rtsp 数据包 [英] how to filter rtsp packets from a pcap file
问题描述
我正在编写一个程序来打开一个 pcap 文件,然后过滤一些数据包,然后将数据包数据作为字符串写入文件,但我不知道为什么这个程序在打开 pcap 文件后什么也不做.
i'm writing a program to open a pcap file and then filter some packets and then write packet data as string in a file but i do nott know why this progrme is doing nothing after opening the pcap file.
int rtsp=0;
int rtsp=0;
FileWriter fstream2= new FileWriter("E:\write2.txt",true);
FileWriter fstream2= new FileWriter("E:\write2.txt",true);
BufferedWriter fbw2= new BufferedWriter(fstream2);
BufferedWriter fbw2= new BufferedWriter(fstream2);
System.out.println("RTSP:");JpcapCaptor captor2=JpcapCaptor.openFile("E:\rtsp_with_data_over_tcp.pcap");
System.out.println("RTSP:"); JpcapCaptor captor2=JpcapCaptor.openFile("E:\rtsp_with_data_over_tcp.pcap");
while(true){
while(true){
Packet packet2=captor2.getPacket();
Packet packet2=captor2.getPacket();
if(packet2==null || packet2==Packet.EOF) 中断;
if(packet2==null || packet2==Packet.EOF) break;
rtsp=rtsp+1;String PacketData2=new String(packet2.data);
rtsp=rtsp+1; String PacketData2=new String(packet2.data);
fbw2.write(PacketData2);
fbw2.write(PacketData2);
fbw2.newLine();
}
fbw2.newLine();
}
fbw2.close();
fbw2.close();
captor2.close();
captor2.close();
System.out.println("RTSP:"+rtsp);
System.out.println("RTSP:"+rtsp);
即使是最后一个打印语句也不起作用.
EVEN this last print statement is also not working.
有人可以指导我吗?!
推荐答案
根据rtsp使用的默认端口,可以过滤
According to the default ports used by rtsp, you can filter the
rtsp 554/tcp Real Time Stream Control Protocol
rtsp 554/udp Real Time Stream Control Protocol
rtsp-alt 8554/tcp RTSP Alternate (see port 554)
rtsp-alt 8554/udp RTSP Alternate (see port 554)
http://www.cs.columbia.edu/~hgs/rtsp/
这篇关于如何从 pcap 文件中过滤 rtsp 数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!