Network Simulations using Python

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Network Simulations using Python

David MacQuigg
I'm putting together some problems for students in ECE 578, Computer Networks.  The simulator being used in the class is truly awful, one of these expensive commercial programs, dumbed down for academic use, but still loaded with the non-essential complexity typical of programs written for full-time professionals.

It occurs to me that Python would be a much better tool for what we are doing.  The objects in a network are easily modeled as Python objects, and students gain a much better understanding when they see what is inside the objects, rather than just picking them off a menu, and using them as black boxes.

Take a look at http://ece.arizona.edu/~edatools/ece578/Ethernet/   The Python program is still in its early stages.  Next step is to "refactor" it, making the main program a Network object, so we can run it in a loop.

Comments and suggestions are welcome, especially for more clarity in the Python code.  Python is still not used in any class at U of A, and this could be one of our shining examples to get it started.


_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Network Simulations using Python

André Roberge
On Wed, Sep 10, 2008 at 12:43 PM, David MacQuigg
<[hidden email]> wrote:
> I'm putting together some problems for students in ECE 578, Computer Networks.  The simulator being used in the class is truly awful, one of these expensive commercial programs, dumbed down for academic use, but still loaded with the non-essential complexity typical of programs written for full-time professionals.
>
> It occurs to me that Python would be a much better tool for what we are doing.  The objects in a network are easily modeled as Python objects, and students gain a much better understanding when they see what is inside the objects, rather than just picking them off a menu, and using them as black boxes.
>
> Take a look at http://ece.arizona.edu/~edatools/ece578/Ethernet/   The Python program is still in its early stages.  Next step is to "refactor" it, making the main program a Network object, so we can run it in a loop.
>
> Comments and suggestions are welcome, especially for more clarity in the Python code.  Python is still not used in any class at U of A, and this could be one of our shining examples to get it started.
>

Sorry no comment about the code (yet...).  Perhaps it would also be
suitable to send this to the python tutor list.  They tend to provide
a lot more feedback of the type you're asking than one typically gets
here.

And I don't mean this in a negative way about discussions on this
list; just pointing out the different focus...

André

>
> _______________________________________________
> Edu-sig mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/edu-sig
>
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Network Simulations using Python

Michael H. Goldwasser
In reply to this post by David MacQuigg

On Wednesday September 10, 2008, David MacQuigg wrote:

>    It occurs to me that Python would be a much better tool for what we are doing.  The objects in a network are easily modeled as Python objects, and students gain a much better understanding when they see what is inside the objects, rather than just picking them off a menu, and using them as black boxes.

Dave brings up this great idea about using Python to develop network
simulators.  A related issue is that it is possible to use Python in a
networks course for manipulating the actual network components
(e.g. sockets, pipes, clients, servers).   It certainly is easier to
do that type of programming with Python's libraries when compared to
the traditional approach done in C.

At first glance I see a couple of nice tutorials to this end in
academia targeting upper-level networks courses:

    http://ilab.cs.byu.edu/python
    http://heather.cs.ucdavis.edu/~matloff/Python/PyNet.pdf

In fact network programming in Python is so easy we've done units on
it at the CS1 level. A discussion of our approach appeared at ITICSE
2007 in a paper titled "Introducing Network Programming into a CS1
Course."

That paper can be downloaded at  http://cs.slu.edu/~goldwasser/publications
and more complete teaching materials from that unit appear in Chapter 14
of our text.

With regard,
Michael



       +-----------------------------------------------
       | Michael Goldwasser
       | Associate Professor
       | Dept. Mathematics and Computer Science
       | Saint Louis University
       | 220 North Grand Blvd.
       | St. Louis, MO 63103-2007
       |
       | Office: Ritter Hall 6
       | Email:  [hidden email]
       | URL:    http://cs.slu.edu/~goldwasser
       | Phone:  (314) 977-7039
       | Fax:    (314) 977-1452

_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Network Simulations using Python

David MacQuigg
In reply to this post by David MacQuigg
At 11:14 AM 9/10/2008 -0500, Andrew Harrington wrote:

>Doing this in Python sounds good.  keep us posted on the updates.

I'll keep my updates at http://ece.arizona.edu/~edatools/ece578/Ethernet/

>I am most interested in a module to use with Cs0 or CS1 types to
>illustrate network issues, not something a *user* would need more
>than a few weeks of Python for.

I can do some fairly sophisticated models with simple Python programs.  Class definitions are essential, however, so it may take a little more Python than is covered in the first few weeks of CS1.  Maybe there is some synergy here.  The network models can help students learn Python by motivating the need to define your own classes.

At 11:05 AM 9/10/2008 -0500, Michael Goldwasser wrote:

> Thats a great start and I agree that it might be easier to develop
> your own Python simulation versus using the existing simulators.  I
> don't teach our upper level networks course but have tried to do some
> very simple networks materials as part of a "cs 0" breadth course and
> again I run into the same problem in that I want a very basic network
> simulation that demonstrates the basic idea of packet switching
> without overwhelming beginning students.

We're using Computer Networks by Peterson and Davie, and packet switching is Chapter 3, starting a week from now.  Suggestions for simulation problems are welcome.  I appreciate the earlier suggestion to do some network programming (using a network rather than simulating it), and I know Python is very good at this.  There is not much in this text on programming.

For CS0 you might want animations, rather than simulations.  See http://net-seal.net  They have one on packet switching.

I've gone the next step with my Ethernet simulation (sim1.py), and encapsulated all the functionality into a few classes.  This adds some complexity (sim2.py), but now you can easily change the variable to be swept, even re-use the objects in a different network configuration.

One difficulty that I am running into is that many of our students haven't even heard of Python.  They have had plenty of Java, however, so I've written an annotated version of sim1.py to explain the differences from Java (sim1PythonNotes.py).  Michael's Appendix B is excellent on comparing Java and Python.

I thought about just doing the whole thing in Java, but then we lose the most important advantage of Python as a network simulation toolkit - interactive development of the models.

-- Dave


>On Wed, Sep 10, 2008 at 10:43 AM, David MacQuigg <<mailto:[hidden email]>[hidden email]> wrote:
>>I'm putting together some problems for students in ECE 578, Computer Networks.  The simulator being used in the class is truly awful, one of these expensive commercial programs, dumbed down for academic use, but still loaded with the non-essential complexity typical of programs written for full-time professionals.
>>
>>It occurs to me that Python would be a much better tool for what we are doing.  The objects in a network are easily modeled as Python objects, and students gain a much better understanding when they see what is inside the objects, rather than just picking them off a menu, and using them as black boxes.
>>
>>Take a look at <http://ece.arizona.edu/%7Eedatools/ece578/Ethernet/>http://ece.arizona.edu/~edatools/ece578/Ethernet/   The Python program is still in its early stages.  Next step is to "refactor" it, making the main program a Network object, so we can run it in a loop.
>>
>>Comments and suggestions are welcome, especially for more clarity in the Python code.  Python is still not used in any class at U of A, and this could be one of our shining examples to get it started.


_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Network Simulations using Python

kirby urner-4
Someone should say something about Twisted in this "networking through
Python" thread, but I'm not sure what.

I come at Twisted through Medusa in Zope and readings about asyncore,
think of Twisted somewhat in those terms.

Later I jumped from Zope into Plone, hung out with Alan and those guys
for a sprint in Canada.

At this last OSCON, I hung out with Steve Holden (holdenweb.com) and
Duncan McGreggor (a Twisted guy) most of the time.

Kirby
4dsolutions.net

http://twistedmatrix.com/trac/wiki

http://www.nightmare.com/medusa/

http://docs.python.org/lib/module-asyncore.html

http://plone.org/
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Network Simulations using Python

Gregor Lingl-2


kirby urner schrieb:
> Someone should say something about Twisted in this "networking through
> Python" thread, but I'm not sure what.
>  
I'd just like to point you to Shandy Brown's "Writing Games Tutorial", which
uses Twisted in it's network section:

http://ezide.com/games/writing-games.html

BTW this tutorial also deservers attention because of its explanations on
how to use the MVC pattern with pygame.

Regards,
Gregor


> I come at Twisted through Medusa in Zope and readings about asyncore,
> think of Twisted somewhat in those terms.
>
> Later I jumped from Zope into Plone, hung out with Alan and those guys
> for a sprint in Canada.
>
> At this last OSCON, I hung out with Steve Holden (holdenweb.com) and
> Duncan McGreggor (a Twisted guy) most of the time.
>
> Kirby
> 4dsolutions.net
>
> http://twistedmatrix.com/trac/wiki
>
> http://www.nightmare.com/medusa/
>
> http://docs.python.org/lib/module-asyncore.html
>
> http://plone.org/
> _______________________________________________
> Edu-sig mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/edu-sig
>
>
>  
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig