title: Network interface simulation in Python?
body: <p>I'm making a simulator for a digital radio using Python.  The radio relays over RF one each of an RS-232 port and an Ethernet port, with a pair of radios making seamless pipes.  Thus, the simulator will be used in pairs, with pipes between them simulating the RF link, permitting users to connect to each end using physical interfaces, virtual interfaces, or tunnels.</p>
  
  <p>For the RF serial port, I'm using PySerial and virtual serial ports to make the simulator as versatile as possible: I can connect the simulator to either a physical serial port, to a network socket, or to another local program.  Aside from the tools used to create the virtual serial ports on each different OS, this approach is completely cross-platform.</p>
  
  <p>I'd like the simulator to be able to network with a local program via a virtual interface, with a remote program via a shared network interface, and with a remote program via a local physical interface that would be dedicated to the simulator.  But so far, I haven't found a straightforward way to do this.  I've been looking at SLIP/PPP, TAP/DUN, pcap/SOCK_RAW, and other possibilities, and I see no obvious or general solution.</p>
  
  <p>The key difficulty seems to be that this involves an entire Ethernet interface, below the IP level, at the level of the Ethernet protocol itself: If it were only a few ports, the solution would be relatively simple.  Or am I missing something blindingly obvious?</p>
  
  <p>How do I use Python to create and use an RF Ethernet interface in a way that is as versatile as the RF Serial interface solution?</p>