From owner-freebsd-net@FreeBSD.ORG Thu Jul 20 14:48:18 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6F1816A4E2; Thu, 20 Jul 2006 14:48:18 +0000 (UTC) (envelope-from arr@watson.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id D850A43D58; Thu, 20 Jul 2006 14:48:16 +0000 (GMT) (envelope-from arr@watson.org) Received: from fledge.watson.org (localhost.watson.org [127.0.0.1]) by fledge.watson.org (8.13.6/8.13.6) with ESMTP id k6KEmE9t095277; Thu, 20 Jul 2006 10:48:14 -0400 (EDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.13.6/8.13.6/Submit) with ESMTP id k6KEmEfC095274; Thu, 20 Jul 2006 10:48:14 -0400 (EDT) (envelope-from arr@watson.org) X-Authentication-Warning: fledge.watson.org: arr owned process doing -bs Date: Thu, 20 Jul 2006 10:48:14 -0400 (EDT) From: "Andrew R. Reiter" To: gnn@freebsd.org In-Reply-To: Message-ID: <20060720104748.R94787@fledge.watson.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-net@freebsd.org Subject: Re: Packet Construction and Protocol Testing... X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jul 2006 14:48:18 -0000 Aren't there already tools for doing this -- libnet / libdnet that both have py wrappers? On Thu, 20 Jul 2006, gnn@freebsd.org wrote: :Hi, : :Sorry for the length of this email but I figured I'd get this out :early in case there was anyone else who wanted to play with this. : :I have now gotten out version 0.1 of the Packet Construction Set. :This is a set of Python libraries which make writing protocol testing :software much easier. Of course, you have to know Python, but many :people do, and I favor it strongly over other scripting choices. The :Summer of Code student I'm working with has also been using this :library, with favorable results. : :The Source Forge page is here: : :http://sourceforge.net/projects/pcs : :and the shar files submitted to get the ports created are now on: : :http://www.freebsd.org/~gnn/pcs.port.shar :http://www.freebsd.org/~gnn/py-pypcap.shar : :The point of all this is to be able to write better protocol level :tests for our network stack. Examples are in the scripts/ and tests/ :directories of the package but a quick snippet may give a good idea of :what I'm getting at: : : def test_icmpv4_ping(self): : ip = ipv4() : ip.version = 4 : ip.hlen = 5 : ip.tos = 0 : ip.length = 84 : ip.id = 1 : ip.flags = 0 : ip.offset = 0 : ip.ttl = 33 : ip.protocol = IPPROTO_ICMP : ip.src = 2130706433 : ip.dst = 2130706433 : : icmp = icmpv4() : icmp.type = 8 : icmp.code = 0 : icmp.cksum = 0 : : echo = icmpv4echo() : echo.id = 32767 : echo.seq = 1 : : lo = localhost() : lo.type = 2 : packet = Chain([lo, ip, icmp, echo]) : : input = PcapConnector("lo0") : input.setfilter("icmp") : : output = PcapConnector("lo0") : assert (ip != None) : : out = output.write(packet.bytes, 88) : assert (out == 88) : :This code sends a quick and dirty, ICMPv4 ping packet on localhost. :The point of all this is to be able to specify packets easly (see :pcs/packets/xxx.py) and then to treat the packet as an object. : :I intend to write up a paper on this stuff as well. There is :currently a simple manual (PDF and LaTeX) in the package. : :Later, :George : :_______________________________________________ :freebsd-net@freebsd.org mailing list :http://lists.freebsd.org/mailman/listinfo/freebsd-net :To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" : : -- arr@watson.org