Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parseing pcap file which has tcp/IP flow info using java #634

Closed
avi-techno opened this issue Oct 15, 2019 · 3 comments
Closed

Parseing pcap file which has tcp/IP flow info using java #634

avi-techno opened this issue Oct 15, 2019 · 3 comments
Labels

Comments

@avi-techno
Copy link

Sir I am new to Kaitai, I want to parse pcap file which has tcp/IP flow info, I am using java for programming . I have seen your video in Youtube regarding media parsing, kindly let me know how to parse pcap file

Originally posted by @avi-techno in kaitai-io/kaitai_struct_formats#147 (comment)

@avi-techno avi-techno changed the title Sir I am new to Kaitai, I want to parse **pcap** file which has tcp/IP flow info, I am java for programming . I have seen your video in Youtube regarding media parsing, kindly let me know how to parse pcap file I am new to Kaitai, I want to parse **pcap** file which has tcp/IP flow info, I am java for programming . I have seen your video in Youtube regarding media parsing, kindly let me know how to parse pcap file Oct 15, 2019
@GreyCat GreyCat transferred this issue from kaitai-io/kaitai_struct_formats Oct 15, 2019
@GreyCat
Copy link
Member

GreyCat commented Oct 15, 2019

There is an example at http://formats.kaitai.io/pcap/java.html — if you run into any specific problems, please elaborate what is your goal, what have you tried already and why do you think it's not working.

@GreyCat GreyCat changed the title I am new to Kaitai, I want to parse **pcap** file which has tcp/IP flow info, I am java for programming . I have seen your video in Youtube regarding media parsing, kindly let me know how to parse pcap file Parseing pcap file which has tcp/IP flow info using java Oct 15, 2019
@avi-techno
Copy link
Author

There is an example at http://formats.kaitai.io/pcap/java.html — if you run into any specific problems, please elaborate what is your goal, what have you tried already and why do you think it's not working.

Sir , I am using this code in java to extract pcap file kept in my e drive. How could I implemet this in Kaitai .. the code is :
package jnt;

import java.io.File;
import org.jnetpcap.Pcap;
import org.jnetpcap.packet.JPacket;
import org.jnetpcap.packet.JPacketHandler;

public class PacketCounters {

static String folderpath 
	= "E:\\pcap"; 

static double count = 0; 
static double globalcount = 0; 

	public static void main(String[] args) 
{ 

			File file = new File(folderpath); 

	
	File[] files = file.listFiles(); 

	
	for (File f : files) { 

		
		String FILENAME 
			= folderpath + f.getName(); 

					StringBuilder errbuf = new StringBuilder(); 

		 
		Pcap pcap = Pcap.openOffline(FILENAME, errbuf); 

		
		pcap.loop(-1, new JPacketHandler() 
		{ 
			 public void nextPacket(JPacket packet, StringBuilder errbuf) 
			{ 
				count++; 
			} 
		}, errbuf); 

		System.out.println("File : " + f.getName() 
						+ " Number of Packets : "
						+ count); 

		globalcount = globalcount + count; 

		count = 0; 
	} 

	System.out.println("Total Packets in folder : "
					+ globalcount); 
} 

}

@GreyCat
Copy link
Member

GreyCat commented Oct 15, 2019

@avi-techno, this is a free/open source project that I do in my spare time, and I don't have the capacity to rewrite a sizeable chunk of code written using some sort of library which I've never had the experience with. You're welcome to ask specific questions about KS, but please don't expect people to do work for you for free, especially when you haven't even bothered to try basic examples.

@GreyCat GreyCat closed this as completed Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants