0

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;

FileWriter fstream2= new FileWriter("E:\write2.txt",true);

BufferedWriter fbw2= new BufferedWriter(fstream2);

System.out.println("RTSP:"); JpcapCaptor captor2=JpcapCaptor.openFile("E:\rtsp_with_data_over_tcp.pcap");

while(true){

Packet packet2=captor2.getPacket();

if(packet2==null || packet2==Packet.EOF) break;

rtsp=rtsp+1; String PacketData2=new String(packet2.data);

fbw2.write(PacketData2);

fbw2.newLine();
}

fbw2.close();

captor2.close();

System.out.println("RTSP:"+rtsp);

EVEN this last print statement is also not working.

can any one guide me? !

blackfyre
  • 2,549
  • 5
  • 39
  • 58
  • If you put `System.out.println(packet2);` in the while loop, does the loop print each packet? – ecle Feb 12 '12 at 15:36

1 Answers1

1

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/

qrtt1
  • 7,746
  • 8
  • 42
  • 62
  • I just changed the pcap file and now this code is working. And I want to ask one thing, what is meant by "see port 554"? does rtsp traffic goes to 8554 or it use to see if 554 is avaiable? – blackfyre Feb 12 '12 at 16:49
  • @user1204089 What port used for RTSP service is usually defined in the RTSP port setting of a RTSP server. The port 554 and 8554 are only used for compliance with IANA recommendation. If the port 554 has been used, IANA suggests to use 8554. But, it is up to the RTSP system integrator to set to any free port in a given IP network. So, port 554 and 8554 don't always mean they are being used for RTSP. So, you need to check the packets/datagrams coming from such port to confirm they are using RTSP. – ee. Feb 13 '12 at 02:30
  • @ee Thanks! And is this also true for other protocols for example MSMMS's default port is 1755, so is this possible that we will get some other packets at this port, and msmms can go to some other port? – blackfyre Feb 13 '12 at 11:12
  • 1
    @user1204089 It is true for other ports as long as you know what you want to do in a given network. Let say, I can set port 9000 on a web server and ask the user to refer to `http://x.y.z:9000`, as long as port 9000 is not used by other application in my network. Otherwise, it will be a port conflict and we need to solve it. – ee. Feb 14 '12 at 00:59