Giter Club home page Giter Club logo

netmap-ipfw-mirror's Introduction

# README FILE FOR IPFW-USER ON TOP OF NETMAP

This directory contains a version of ipfw and dummynet that can
run in userland, using NETMAP as the backend for packet I/O.
This permits a throughput about 10 times higher than the
corresponding in-kernel version. I have measured about 6.5 Mpps
for plain filtering, and 2.2 Mpps going through a pipe.
Some optimizations are possible when running on netmap pipes,
or other netmap ports that support zero copy.

To build the code simply run
	make NETMAP_INC=/some/where/with/netmap-release/sys

pointing to the netmap 'sys' directory
(the makefile uses gmake underneath)

The base version comes from FreeBSD-HEAD -r '{2012-08-03}'
(and subsequently updated in late 2013)
with small modifications listed below

	netinet/ipfw
	    ip_dn_io.c
		support for on-stack mbufs
	    ip_fw2.c
		some conditional compilation for functions not
		available in userspace
	    ip_fw_log.c
		revise snprintf, SNPARGS (MAC)


sbin/ipfw and the kernel counterpart communicate throuugh a
TCP socket (localhost:5555) carrying the raw data that would
normally be carried on seg/getsockopt.

For testing purposes, opening a telnet session to port 5556 and
typing some bytes will start a fake 'infinite source' so you can
check how fast your ruleset works.

	gmake
	dummynet/ipfw & # preferably in another window
	telnet localhost 5556 # type some bytes to start 'traffic'

	sh -c "while true; do ipfw/ipfw show; ipfw/ipfw zero; sleep 1; done"

(on an i7-3400 I get about 15 Mpps)

Real packet I/O is possible using netmap info.iet.unipi.it/~luigi/netmap/
You can use a couple of VALE switches (part of netmap) to connect
a source and sink to the userspace firewall, as follows

                s       f               f       d    
   [pkt-gen]-->--[valeA]-->--[kipfw]-->--[valeB]-->--[pkt-gen]

The commands to run (in separate windows) are

	# preliminarly, load the netmap module
	sudo kldload netmap.ko

	# connect the firewall to two vale switches
	./kipfw valeA:f valeB:f &

	# configure ipfw/dummynet
	ipfw/ipfw show	# or other

	# start the sink
	pkt-gen -i valeB:d -f rx

	# start an infinite source
	pkt-gen -i valeA:s -f tx

	# plain again with the firewall and enjoy
	ipfw/ipfw show  # or other

On my i7-3400 I get about 6.5 Mpps with a single rule, and about 2.2 Mpps
when going through a dummynet pipe. This is for a single process handling
the traffic.

netmap-ipfw-mirror's People

Contributors

luigirizzo avatar

Watchers

James Cloos 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.