GithubHelp home page GithubHelp logo

tempbottle / libpnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from libpnet/libpnet

0.0 1.0 0.0 1.05 MB

Cross-platform, low level networking using the Rust programming language.

License: Apache License 2.0

Makefile 0.25% C 2.05% Python 0.69% Rust 95.23% Shell 1.78%

libpnet's Introduction

libpnet

Linux ∪ OS X Build Status: Linux ∪ OS X Build Status

Windows Build Status: Windows Build Status

Discussion and support: #libpnet on freenode / #rust on irc.mozilla.org.

libpnet provides a cross-platform API for low level networking using Rust.

There are four key components:

  • The packet module, allowing safe construction and manipulation of packets
  • The pnet_packet crate, providing infrastructure for the packet module
  • The transport module, which allows implementation of transport protocols
  • The datalink module, which allows sending and receiving data link packets directly

Why?

There are lots of reasons to use low level networking, and many more to do it using Rust. A few are outlined here:

Developing Transport Protocols

There are usually two ways to go about developing a new transport layer protocol:

  • Write it in a scripting language such as Python
  • Write it using C

The former is great for trying out new ideas and rapid prototyping, however not so great as a real-world implementation. While you can usually get reasonable performance out of these implementations, they're generally significantly slower than an implementation in C, and not suitable for any "heavy lifting".

The next option is to write it in C - this will give you great performance, but comes with a number of other issues:

  • Lack of memory safety - this is a huge source of security vulnerabilities and other bugs in C-based network stacks. It is far too easy to forget a bounds check or use a pointer after it is freed.
  • Lack of thread safety - you have to be very careful to make sure the correct locks are used, and used correctly.
  • Lack of high level abstractions - part of the appeal of scripting languages such as Python is the higher level of abstraction which enables simpler APIs and ease of programming.

Using libpnet and Rust, you get the best of both worlds. The higher level abstractions, memory and thread safety, alongside the performance of C.

Network Utilities

Many networking utilities such as ping and traceroute rely on being able to manipulate network and transport headers, which isn't possible with standard networking stacks such as those provided by std::io::net.

Data Link Layer

It can be useful to work directly at the data link layer, to see packets as they are "on the wire". There are lots of uses for this, including network diagnostics, packet capture and traffic shaping.

Documentation

API documentation for the lastest build can be found here: http://octarineparrot.com/assets/libpnet/doc/pnet/.

Usage

To use libpnet in your project, add the following to your Cargo.toml:

[dependencies.pnet]
git = "https://github.com/libpnet/libpnet.git"

When developing, use the provided Makefile, which does weird things to make the tests work properly. Note that root/administrator access is usually required for libpnet.

You must use the nightly channel of Rust to use libpnet.

libpnet's People

Contributors

abonander avatar bcg avatar construidor avatar darxriggs avatar ebfe avatar homu avatar jshrake avatar lukeasrodgers avatar moonpolysoft avatar mrmonday avatar mwylde avatar vmx avatar

Watchers

 avatar

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.