Newbie.......Python and Networking

X

xeron

Hi ya fellas

I am planning to learn Python, and because i have a networking
background so would like to direct my learning in a way that is
beneficial to my tasks in the mentioned field, please suggest a couple
of projects which i can implement so as to accelerate the learning
process................(Python projects in Networking domain, let it be
big...3 months....2 hrs per day)

Really appreciate any help
 
P

phil

xeron said:
> Hi ya fellas
>
> I am planning to learn Python, and because i have a networking
> background so would like to direct my learning in a way that is
> beneficial to my tasks in the mentioned field, please suggest a couple
> of projects which i can implement so as to accelerate the learning
> process................(Python projects in Networking domain, let it be
> big...3 months....2 hrs per day)
>
> Really appreciate any help
>
>

I let my students learn on a VERY simple chat program,
UDP only. I think it was less than 50 lines of Python.

I cut my teeth on a message handler, POS application posts
its requests to MySQL via a Python message handler.

Want BIG?
spread.org is very powerful and somewhat complicated.
A python message server, guaranteed orderly delivery
over 1 UDP port, which is a little easier to understand
than spread, would be cool.

Even BIGGER?
Every linux distro has its own set of complex and
nearly unreadable networking scripts and none of them
handle routing and firewalls well.
Be the hero who rights a universal, well documented
python networking script. Easy to read config file:

ethmodule=
IPADDR=192.168.1.12/24
DEFGATEWAY=192.168.1.1
DNSSERV1=208.208.1.1

or even a GUI with help.
 
X

xeron

Thanks phil, I think I'll start off with your chat prog (UDP-- 50 lines
code ) and then try for routing and firewall scripts for linux, yepp
that would be really tough but why not give it a try, i am going to
have my vacations for like 13 days so will be preparing for my CCNA and
also learning python in that duration.

You have been most helpful through ur well thought and scaled reply

xeron
 
P

phil

xeron said:
Thanks phil, I think I'll start off with your chat prog (UDP-- 50 lines
code ) and then try for routing and firewall scripts for linux, yepp
that would be really tough but why not give it a try, i am going to
have my vacations for like 13 days so will be preparing for my CCNA and
also learning python in that duration.

You have been most helpful through ur well thought and scaled reply

xeron
I could send you the chat program they wrote if it would help.

It has 2 threads, listener and sender.
Might spoil your fun.
However it is very primitive and asynchronous and needs work.

Oh heck, here it is.
DO NOT PEEK BEYOND THIS POINT IF YOU WISH TO SOLVE YOURSELF.



# chat1.py
# remote unknown, firewall allow UDP 12101

import os
from threading import *
from socket import *

HOST = ''
BUFSIZE = 1024
ListenPort = 12101
ListenAddr = (HOST,ListenPort)

listenersocket = socket(AF_INET,SOCK_DGRAM)
listenersocket.bind(ListenAddr)
sendsocket = socket(AF_INET,SOCK_DGRAM)

sendsocket = socket(AF_INET,SOCK_DGRAM)

def listener():
while 1:
msg,addr = listenersocket.recvfrom(BUFSIZE)
print '<',msg
if msg == 'die-now': break

def sender():
print; print
print 'Type away. When you are thru with your'
print ' message, hit enter an extra time'
print ' to let the other guy know its his turn.'
print 'To exit, enter exit'
print; print

while 1:
msg = raw_input()
if msg == 'exit':
sendsocket.sendto( 'die-now', ('localhost',ListenPort) )
break
sendsocket.sendto( msg, (sendtoip,ListenPort) )

# Main program start here
print
sendtoip = raw_input('Enter IP address of other computer: ')
sendtoip = sendtoip.strip()

# Define and start 2 threads
listnr = Thread(target=listener)
sendr = Thread(target=sender)
listnr.start()
sendr.start()
listnr.join()
sendr.join()
 
X

xeron

Thanks again, and i didn't peek.......planning to do it later have my
exams for next 14 days then I'll zero in on Python.......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,238
Messages
2,571,193
Members
47,830
Latest member
ZacharySap

Latest Threads

Top