Code Monkey home page Code Monkey logo

packetcapture's Introduction

Build Status

packetcapture

A simple program to compare traffic capture technologies:

  • libpcap
  • pfring
  • afpacket

Overview

All those technologies work in a similar method:

  • This tool initializes one or more (if the method supports fanout) sockets. Each socket is assigned one buffer in the kernel. If BPF is set, it is compiled and attached to the socket.
  • A packet comes from the NIC to the relevant driver, which wraps the information in a generic Linux structure (sk_buff) and puts it in a queue for CPU processing.
  • The CPU looks at the first packet in the queue. Instead of calling all the processes of the IP Stack (spreading and removing each header, calling netfilter hooks, etc.), it looks for the relevant socket object.
  • If BPF is attached to the socket, CPU checks if the packet passes it. If not, packet is thrown away.
  • The packet is copied to our kernel buffer and then removed from the queue.
  • From here this tool can copy the information to the user space or work on it while it is still in the buffer (called "zero copy" in gopacket).

Usage

You can use this tool to sniff a network device in one of the methods. You can set the kernel buffers number, whether to use zero copy, and BPF. The tool will print pps and packet loss every second. Keep in mind that the tool does nothing with the packets it receives, so the numbers you see represent the maximum traffic that can be handled according to the settings.

packetcapture's People

Contributors

danielsegalmdx avatar dlemel8 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xuacker stachdude

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.