style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-7505528228218001"
data-ad-slot="1225241371">

Is jNetPcap depended on winpcap?

2 replies [Last post]
Amrin
Offline
Joined: 12/02/2015

HI Team, I am creating a packet content filter in jNetPcap as a part of my college project. As of now my doubt is if jNetPcap can directly capture an IP Packet or does it completely depend on winpcap.

Please try and answer at the earliest.

Thank you

DavidJones
Offline
Joined: 06/08/2015
Interesting idea. Many would

Interesting idea. Many would be interested to learn on how to do it. - Bobby Price

kobe
Offline
Joined: 02/02/2016
Here is my code
it seems the setbytearray() method brings an error with arp. Below is the code and the sample packet, with the setbytearray() array commented byte[] sourceAddr= {(byte) 172,(byte) 16,(byte) 0,(byte) 250}; byte[] targetAddr = {(byte) 172,(byte) 16,(byte) 1,(byte) 215}; byte[] targetMac= ConvertMacToByte(destinationMac); int hardwareType = 1; int protocolType = 2048; int hardwareLength = 6; int protocolLength = 4; int opCode = 1; System.out.println(getMac().length); JPacket packet = new JMemoryPacket(60); packet.order(ByteOrder.BIG_ENDIAN); packet.setUShort(12, 0x0806); packet.scan(JProtocol.ETHERNET_ID); Ethernet ethernet = packet.getHeader(new Ethernet()); ethernet.destination(targetMac); ethernet.type(0x806); ethernet.source(getMac()); packet.setUByte(14, 0x40 | 0x05); packet.scan(JProtocol.ETHERNET_ID); Arp arp = packet.getHeader(new Arp()); arp.setUShort(0, hardwareType ); arp.setUShort(2, protocolType); arp.setUByte(4, hardwareLength); arp.setUByte(5, protocolLength); arp.setUShort(6, 1); // arp.setByteArray(8, getMac());// error starts here.any bytes array wing bring an bufferUnderflow exception //arp.setByteArray(14, sourceAddr); ///arp.setByteArray(18, ConvertMacToByte(destinationMac)); //arp.setByteArray(24,targetMac); packet.scan(JProtocol.ETHERNET_ID); packet.scan(Ethernet.ID); pcp.sendPacket(packet); return packet; }

kobe

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.