- Tutorials
- API Examples
- User Guide
- Ch 1 - The Basics
- Ch 2 - libpcap
- 2.1 - The Main libpcap API Overview
- 2.2 - Getting a List of Interfaces
- 2.3 - Opening a Network Interface for Capture
- 2.4 - Opening offline capture
- 2.5 - Setting a packet filter
- 2.6 - Reading one packet at a time
- 2.7 - Reading multiple packets with dispatch loops
- 2.8 - Dumping captured packet to an offline file
- 2.9 - Transmitting packets
- 2.10 - Close Pcap and PcapDumper handles
- Ch 3 - Packet Decoding
- Ch 4 - Internals
- Ch 5 - Protocols
- Ch 6 - Native API
This is the meat of our application and the main loop for us. All the packets come here. We pick out the ip4 packets and we process each one of them.
public class IpReassemblyExample implements PcapPacketHandler
We process each Ip4 packet a little differently depending if the the Ip4.FLAG_MORE_FRAGEMNTS is set. If it is not set that means it is the last fragment, otherwise we received a packet inside fragment. If a packet is not fragmented at all, it only contains a single fragment and is always the last fragment and we treat it as a last segment.
We use to methods, bufferFragment() and bufferLastFragment() to record the fragments in the reassembly buffer. The bufferLastFragment() is a little bit special in that it records the length of the entire ip datagram we are reassembling and if all the fragments arrived in sequence it also means we're done with this buffer.
At the end of this loop, we check the time out queue to see if there is anything ready to be timed out. A better approach would be put this check in a sub thread, but for our purpose this a simple check every time a packet arrives is sufficient.
»
Printer-friendly- Login or register to post comments
Send via Email
PDF Convert
Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. I like your work and would love to send this page to my friends so they can read more about ccna security questions with my friend. i like to see more post form you on the same way as you have done in past and love to visit you again with hosting reseller. keep working like this.... Have a wonderful time.