[Tutor] Figuring out a protocol for fun and education

Scot W. Stevenson scot at possum.in-berlin.de
Fri Jan 23 16:07:29 EST 2004


Hello there, 

SuSE Linux includes a little program called "smpppd" (SuSE Meta PPP Daemon) 
that controls several internet connections: You have one machine (with 
smpppd) that actually can start the connection for your network, and a bunch 
of other machines on your little local net that can tell this machine to do 
so (called cinternet for the command line or kinternet for KDE). In KDE, for 
example, you just click a little plug icon in the lower left corner, and 
stuff happens.

For obvious reasons there are no versions of this program for Windows, and I 
still have one Windows machine on my network (soon to be replaced with a 
Mac, but the problem will be the same). Doing "telnet" everytime is a 
bummer, and so I want to write my own version of cinternet, and of course I 
want to do it in Python. All of these programs are GPL and I have the source 
sitting around here, so in theory all I have do is sit down and wade through 
the C and C++ code and rewrite the result in Python.

But then I started wondering if it wouldn't be more fun to try to figure out 
the protocol the hard way, by playing around with the setup and analyzing 
the responses the server is giving. I was wondering if anybody here could 
give me some suggestions on how to do this best, as I know absolutely zip 
about what to expect in a protocol such as this one.

So far, I have been testing the server (smpppd) by trying to send it codes to 
get a response with this little snippet:
==================================
import socket

socket.setdefaulttimeout(30)

HOST = '192.168.1.20'
SOCKET = 3185

sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockobj.connect((HOST, SOCKET))

while True:
    message = raw_input('Message: ')
    if message == 'quit':
        break
    sockobj.send(message)
    data = sockobj.recv(1024)
    print 'Got ', data

sockobj.close()
===================================
(Note this is Python 2.3). The first time I send something -- anything -- I 
get "SuSE Meta pppd (smpppd), Version 1.00" as a response, which proves that 
I'm reaching the right socket etc. However, anything after that is met with 
silence until the time out is reached.

Since this is getting frustrating, I'm wondering about creating a transparent 
proxy instead, that I would do nothing more than pass along the stuff it 
receives from cinternet to smpppd and vice versa while printing out a log of 
what it is doing. Haven't gotten around to coding it yet, though.

This can't be a new problem, and I wonder if there is a standard way of 
approaching it that I am simply not aware of and somebody could point me to 
before I get too frustrated and just read the code. Again, this is not a 
cracking attempt of any sort -- the original author of smpppd is given as 
Arvin Schnell <arvin at suse.de>, if anybody wants to check with him -- but an 
exercise in problem solving. 

And yes, I spend way too much time reading Poe's "The Goldbug" when I was 
younger...

Thank you for any pointers,
Y, Scot

-- 
                Scot W. Stevenson - Panketal, Germany




More information about the Tutor mailing list