Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I would like to be able to directly access the buffer where packets are stored when they're received. After some googling, I think perhaps libpcap with mmap would be ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    22

    Directly access received packets in buffer


    Hi,

    I would like to be able to directly access the buffer where packets are stored when they're received. After some googling, I think perhaps libpcap with mmap would be the solution. Does libpcap 1.0 and above support mmap?

    From my understanding, mmap would allow me to directly access the buffer without having to explicitly copy the packet to another buffer for me to do processing. I would also appreciate it if someone can let me know where I can find examples of such applications, as many examples of mmap I've found involves mapping a buffer for file operations, rather than integrating it with pcap functions like pcap_loop, pcap_next_ex etc.

    Thank you.

    Regards,
    Rayne

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,655
    You have a lot of studying to do before you go down this path... Network packets are kept (usually) in a circular buffer (linked list). Just using mmap() to map a physical address is not a lot of use here. This is where the pcap functions come in, as they let you navigate that list without much bother.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •