ChaosNET in Python

This Python code serves as a cross-platform replacement for Brad Parker's chaosd process, which supports the basic illusion of a ChaosNET ether implemented either over WinSock/TCP stream sockets on the localhost or UNIX-domain stream sockets. Further code provides generic interfaces for creating clients attached to these virtual ethers with increasing complexity.

One of those clients is a simple masquerading gateway, which echoes one client's packets to and from the Internet encapsulated in UDP. This allows for remote machines following Bjorn Victor's CHUDP protocol to be transparently linked to a virtual Chaos network on the local machine.

The eventual goal would be to implement a FILE protocol server completely asynchronously, either based on the asyncore framework shown here, or perhaps by migrating to Twisted.
Component files The basic definitions needed for the Chaos protocol and packets. Classes derived from the asyncore base supporting sending and receive Chaos packets encapsulated in a stream, and for creating "ether servers" which echo packets from one client to all clients on a Chaos subnet. An example script for a simple ChaosNET server process, using objects to emulate two ChaosNET subnets over localhost TCP stream sockets. Classes derived from asyncore supporting Chaos packets encapsulated in UDP, including a simply stream-to-UDP masquerading router. A simple script implementing a chaos_udp masquerading router between a Windows and a UNIX host. Classes to implement simple ChaosNET clients using stream sockets. A simple example using classes to provide a "listen" client, echoing all packets on a particular subnet. The beginnings of a simple "responder", which acts like a host obeying the minimal protocol, including simple ANS responses to RFC packets, and recording RUT packets to maintain an internal routing table.

Example files A simple script creating a server for a local subnet and a UDP masquerade with a hard-coded route to a UNIX machine on the network.


This code is perhaps not very idiomatic Python. I have not settled on a framework for formal unit tests, and am not sure the best way to do so for such interactive programs. It does not provide much error-checking at all in the encoding and decoding of the underlying packets. Asyncore seems to be the red-headed stepchild of asynchronous Python network frameworks, so I will probably go with the crowd and port this to Twisted at some point.

Original location: