Coder Social home page Coder Social logo

outscale / packetgraph Goto Github PK

View Code? Open in Web Editor NEW
83.0 16.0 28.0 3.01 MB

Packetgraph library is a collection of network bricks you can connect to form a network graph.

License: Other

C 85.43% Shell 0.99% Makefile 1.76% Perl 10.14% C++ 1.69%
brick packets dpdk npf vxlan vtex ipv6 vhost-user vhost tap

packetgraph's Introduction

Project Incubating

Packetgraph ?

Packetgraph is a library aiming to give the user a tool to build networks graph easily, It's built upon the fast DPDK library.

Build Status packetgraph documentation

The goal of this library is to provide a really EASY interface to build you own DPDK based application using Network Function Virtualization Everyone is free to use this library to build up their own network application.

Once you have created and connected all bricks in you network graph, some bricks will be able to poll a burst of packets (max 64 packets) and let the burst propagate in you graph.

Connections between bricks don't store any packets and each burst will propagate in the graph without any copy.

Each graph run on one core but you can connect different graph using Queue bricks (which are thread safe). For example, a graph can be split on demand to be run on different core or even merged.

If you want a graphical representation of a graph, you can generate a dot output.

Packetgraph features

Available bricks (ipv4/ipv6):

  • switch: a layer 2 switch
  • rxtx: setup your own callbacks to get and sent packets
  • tap: classic kernel virtual interface
  • vhost: allow to connect a vhost NIC to a virtual machine (virtio based)
  • firewall: allow traffic filtering passing through it (based on NPF)
  • diode: only let packets pass in one direction
  • accumulator: batch bursted packets to increase poll and burst speed
  • hub: act as a hub device, passing packets to all connected bricks
  • nic: allow passing packets to a NIC of the system (accelerated by DPDK)
  • print: a basic print brick to show packets flowing through it
  • antispoof: a basic mac checking, arp anti-spoofing and ipv6 neighbor discovery anti-spoofing
  • vtep: VXLAN Virtual Terminal End Point switching packets on virtual LANs, can encapsulate packets over ipv4 or ipv6
  • queue: temporally store packets between graph
  • pmtud(ipv4 only): Path MTU Discovery is an implementation of RFC 1191
  • user-dipole: setup your own callback in a dipole brick, to filter or implement your own protocol

A lot of other bricks can be created, check our wall ;)

How should I use Packetgraph ?

Code Documentation: doxygen link

Packetgraph usage flow

Examples

To build and run examples, you may first check how to build Packetgraph below and adjust your configure command before make:

$ ./configure --with-examples
$ make

To run a specific example, check run scripts in tests directories:

$ ./examples/switch/run_vhost.sh
$ ./examples/switch/run.sh
$ ./examples/firewall/run.sh
$ ./examples/rxtx/run.sh
$ ./examples/dperf/run.sh
...

Building

You will need to build DPDK before building Packetgraph.

Install needed tools

You may adapt this depending on your Linux distribution:

Ubuntu

$ sudo apt-get install libpcap-dev libglib2.0-dev libjemalloc-dev libnuma-dev openssl

CentOS

$ sudo yum install -y glibc-devel glib2-devel libpcap-devel git wget numactl numactl-devel openssl-devel clang
$ wget http://cbs.centos.org/kojifiles/packages/jemalloc/3.6.0/8.el7.centos/x86_64/jemalloc-devel-3.6.0-8.el7.centos.x86_64.rpm
$ wget http://cbs.centos.org/kojifiles/packages/jemalloc/3.6.0/8.el7.centos/x86_64/jemalloc-3.6.0-8.el7.centos.x86_64.rpm
$ sudo rpm -i jemalloc-devel-3.6.0-8.el7.centos.x86_64.rpm jemalloc-3.6.0-8.el7.centos.x86_64.rpm

Build DPDK

$ git clone http://dpdk.org/git/dpdk
$ cd dpdk
$ git checkout -b v19.02 v19.02
$ make config T=x86_64-native-linuxapp-gcc

Note: use T=x86_64-native-linuxapp-clang to build with clang

Edit build/.config and be sure to set the following parameters to 'y':

  • CONFIG_RTE_LIBRTE_PMD_PCAP

If you don't want to use some special PMD in DPDK requiring kernel headers, you will have to set the following parameters to 'n':

  • CONFIG_RTE_EAL_IGB_UIO
  • CONFIG_RTE_KNI_KMOD

Once your .config file is ready, you can now build dpdk as follows:

$ make EXTRA_CFLAGS='-fPIC'

Finally, set RTE_SDK environment variable:

$ export RTE_SDK=$(pwd)

Build packetgraph

$ git clone https://github.com/outscale/packetgraph.git
$ cd packetgraph
$ git submodule update --init
$ ./configure
$ make
$ make install

Note: to build with clang, you can use ./configure CC=clang

Note 2: You need a compiler that support C11 (gcc 4.9 or superior, or clang 3.4 or superior).

Configure Huge Pages

Packetgraph uses some huge pages (adjust to your needs):

  • Edit your /etc/sysctl.conf and add some huge pages:
vm.nr_hugepages=2000
  • Reload your sysctl configuration:
$ sudo sysctl -p /etc/sysctl.conf
  • Check that your huge pages are available:
$ cat /proc/meminfo | grep Huge
  • Mount your huge pages:
$ sudo mkdir -p /mnt/huge
$ sudo mount -t hugetlbfs nodev /mnt/huge
  • (optional) Add this mount in your /etc/fstab:
hugetlbfs       /mnt/huge  hugetlbfs       rw,mode=0777        0 0

Compille Time Optimisation:

-DPG_BRICK_NO_ATOMIC_COUNT: do not use atomic variable to count packets, if you do so, you must call pg_brick_pkts_count_get in the same thread you use to poll packets -DPG_VHOST_FASTER_YET_BROKEN_POLL: change the way vhost lock the queue so it spend less time locking/unlocking the queue, but can easily deadlock if badly use.

Compille Time Option

-DTAP_IGNORE_ERROR: when packetgrapg can't burst or poll a tap, it return 0 instead of returning an error -DPG_QEMU_MEM_SIZE=SIZE: allow to specify qemy ram size in test, parameter must be a string in qemu format, examples: -DPG_QEMU_MEM_SIZE="1G", -DPG_QEMU_MEM_SIZE="512M"

Licence

Packetgraph project is published under GNU GPLv3. For more information, check LICENSE file.

Contribute

New to packetgraph ? Want to contribute and/or create a new brick ? Some developer guidelines are available.

Question ? Contact us !

Packetgraph is an open-source project, feel free to chat with us on IRC

server: irc.freenode.org

chan: #betterfly

packetgraph's People

Contributors

benoit-canet avatar jerome-jutteau avatar lunaticp avatar outscale-avu avatar outscale-fne avatar outscale-gle avatar outscale-hmi avatar outscale-mgo avatar outscale-nts avatar outscale-toa avatar outscale-wnd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packetgraph's Issues

wall: queue brick to ease multithreading

This new brick permits to buffer packets in a queue until they are polled.
This brick should have the "poll" flag enabled so it can be shared in several graphic structure (see #18 )

vtep: manage maximal MTU size

We sould be able to configure the max MTU managed by vtep once packets are encapsulated.
vtep should drop packets if it cannot encapsulate them and respect the MTU

vtep: segment array for vtep

A vtep have an array of sides where each edge correspond to a VNI.

A VNI is nothing more than a short int.

So we could have a faster way address our packets to the good VNI if we had a segmented array
use to made 1-1 mapping between VNI and brick's edge instead of looping on each edge and see if the packets we are transmitting are corresponding to the edge we are looping on.

core: create a graph stucture to contain a whole graph

The idea to put all your linked bricks inside a graph.
Once populated on this structure, the user could call a poll() function to poll all pollables bricks of the graph.
To know if a brick is pollable or not, we could add a flag in each brick.
Each time the poll function of the graph is called, an integer "counter" is incremented.

Then, when looking for bricks during the poll:

  • 0: the brick is not pollable
  • 1: the brick will be pulled each time
  • 2: the brick will be pulled when counter % 2 = 0
  • 3: the brick will be pulled when counter % 3 = 0
  • ...

Deduplicate pg_packets_prepare_hash_keys in bricks

vtep call pg_packets_prepare_hash_keys.
switch call pg_packets_prepare_hash_keys.
antispoof can be faster if the packets was prepare by pg_packets_prepare_hash_keys.

We should call pg_packets_prepare_hash_keys after the nic brick, of create a brick to call pg_packets_prepare_hash_keys and made an option to stop doing that in switch.
After that we can optimize the antispoof, and all other brick which check the ether_addr.

vhost: replace the brick by pmd

It's a reminder: a pmd wrapping vhost is beeing reviewed on dpdk.

When this pmd will be ready, there would be no more reason to maintain a vhost brick instead of using the nic brick.
The main work to do once this feature ready would be to dynamically create nic devices in nic brick

print: use layers to parse protocols

Instead of looking at all possible protocols of layer n+1 in layer n, we should use a common function for each layers.
If n+1 fails to parse, we can try to look at layer n and so on (useful for lower encapsulated layers)

nic: copy stats field by field

We use a copy of nic stats, to avoid braking future version during copy we should copy field by field them.
Another option is to expose the original stat structure

vhost: get stats about packet

This will be usefull to have some stats about traffic passing through the vhost brick.
An other solution would be to have a separate statistic brick.

core: some bricks should not be allowed nor able to forward to more than one brick

Today, we can classify our brick in 2 categories: the social brick which are dealing with lot of neighbors(hub, switch vtep) and the associable one(diode, firewall, nic, vhost...), which are not make to deal with more that 2 brick(one on each side) and actually if we try to link an associable brick with a lot of neighbor, I'm not really sure about what will happen, and this can cause bugs.

We need to forbid associable bricks to deal with more than 1 neighbor on each side, and so we will be able to optimize the forwarding of the associable bricks.

Check all headers

Just a reminder to check all IFNDEF headers and check that they respect naming conventions

Returns logic

We have to check return logic: some functions returns 1 if ok, 0 otherwise and some have the opposite behavior.

free hugepage

When an application launch and stops VMs who connect to packetgraph using vhost we can see that Hugepages are never freed. I wrote a test to reproduce this behavior in a separate branch.

wall: linux container brick

The idea is to create a new brick permitting to communicate with a linux container.
This feature is currently under specification (see this thread).

Somes brick don't check if config is NULL and somes orther may overchek it

the clasical way to create a brick look like this:

mybrick_new(args)
{
  config = mybrick_config_new(args)
  if (!config)
     return NULL;
  ret = brick_new("mybrick", config, errp);
  brick_config_free(config);
  return ret;
}

Exept that some brick didn't check if config is null,
and some other check if config is NULL inside "mybrick_init"
which is useless because if config is NULL, you'll get a SEGV before reaching
mybrick_init.
We need to homogenize this code.

Cache before calling map.

Lookup in a map is slow.
Add an element to a map, include a lookup inside the map, it's slow.

So we should add a cache system, using a little circular static array, which will allow us to
to skip calling the map functions.

firewall spawn limitation

In tests (integration), spawning firewall instances are limited and stops around 62.
We need to investigate this.

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.