Designing a network in Python

V

varun7rs

Hello Friends

I would like to design a network given the topology and the source I use is
http://sndlib.zib.de/home.action

I have managed to read most of the important data in the xml onto lists. Now, I have two lists, Source and Destination and I'd like to create bi-directional links between them. My code is as below. And moreover, I'd like to assign some kind of a bandwidth capacity to the links and similarly, storageand processing capacity to the nodes. So, I generated some random integersfor them. I don't know how to proceed further to design the topology. I'd prefer to do the topology design in another .py file probably. I'd be glad if you guys could lend me a helping hand.

import sys
import xml.dom.minidom as dom
import string
#from xml.dom.minidom import getDOMimplementation
from xml.dom import minidom
from xml.dom.minidom import parse
import os
import random



class PHY_NODES:
def __init__(self, nodeID, x, y, capacity_proc, capacity_stor, capacity_switch):
self.nodeID = nodeID
self.x = x
self.y = y
self.linklist = []
self.capacity_proc = capacity_proc
self.capacity_stor = capacity_stor
self.capacity_switch = capacity_switch

class PHY_LINKS:
def __init__(self, linkID, source, destination, capacity_bdw):
self.linkID = linkID
self.source = source
self.destination = destination
self.capacity_bdw = capacity_bdw

# Reading Nodes

Read_Data = minidom.parse("germany50.xml")
nodelist = Read_Data.getElementsByTagName("node")
corenodes = []
for node in nodelist :
corenodes.append(node.getAttribute("id"))
nodeid = node.getAttribute("id")
xCoordinates = node.getElementsByTagName("x") [0]
yCoordinates = node.getElementsByTagName("y") [0]
proc = random.randint(20, 40)
stor = random.randint(40, 80)
switch = random.randint(60, 90)
nodeobj = PHY_NODES(nodeid, xCoordinates, yCoordinates, proc, stor, switch)



# Reading Links

linklist = Read_Data.getElementsByTagName("link")

links = []
sources = []
destinations = []
capacity_link = []
for link in linklist :
linkid = link.getAttribute("id")
Source = link.getElementsByTagName("source") [0]
Destination = link.getElementsByTagName("target") [0]
Capacity = link.getElementsByTagName("capacity") [0]
linkobj = PHY_LINKS(linkid, Source, Destination, Capacity)
sources.append(Source.firstChild.data)
destinations.append(Destination.firstChild.data)
capacity_link.append(Capacity.firstChild.data)
 
J

Joseph L. Casale

I have managed to read most of the important data in the xml onto lists.
Now, I have two lists, Source and Destination and I'd like to create bi-directional
links between them.
And moreover, I'd like to assign some kind of a bandwidth capacity to thelinks and
similarly, storage and processing capacity to the nodes.

I don't know anything about your use case or data really, but from the above I
already know I would shove this all into a database, adding tables with relations
and mining data based on relations becomes trivial. More importantly, it also then
becomes easily extensible without refactoring as your requirements change.

Just my opinion,
jlc
 
V

varun7rs

I don't know how to do that stuff in python. Basically, I'm trying to pull certain data from the xml file like the node-name, source, destination and the capacity. Since, I am done with that part, I now want to have a link between source and destination and assign capacity to it.

eg., [a,b,c,d,e] [l,m,n,o,p] [5,2,3,4,5]

I need something like a - l: 5, b - m: 2,....I don't know how to describe this exactly but I hope this would give you a rough idea. After this, I put the stuff back into an xml but this time only there are more parameters andlooks more detailed....

Like nodeID = Aachen...stor_capacity = 100, proc_capacity = 200, switch_capacity = 190...etc
 
J

Joseph L. Casale

I don't know how to do that stuff in python. Basically, I'm trying to pull certain data from the
xml file like the node-name, source, destination and the capacity. Since,I am done with that
part, I now want to have a link between source and destination and assigncapacity to it.

I dont mind writing you an SQLite schema and accessor class, can you defineyour data in a tabular
format and mail it to me offline, we add relationships etc as we go.

Hopefully it inspires you to adopt this approach in the future as it often proves powerful.

jlc
 
V

varun7rs

I dont mind writing you an SQLite schema and accessor class, can you define your data in a tabular
format and mail it to me offline, we add relationships etc as we go.

Hopefully it inspires you to adopt this approach in the future as it often proves powerful.

jlc

Thanks a lot for your help. But, how do I mail you? I can't find your mail id here
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top