Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70770

Designing a network in Python

Newsgroups comp.lang.python
Date 2014-04-30 02:30 -0700
Message-ID <8ab783e8-a36e-49e5-a329-2c4d98df8537@googlegroups.com> (permalink)
Subject Designing a network in Python
From varun7rs@gmail.com

Show all headers | View raw


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, storage and processing capacity to the nodes. So, I generated some random integers for 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)

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Designing a network in Python varun7rs@gmail.com - 2014-04-30 02:30 -0700
  RE: Designing a network in Python "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-04-30 12:28 +0000
    Re: Designing a network in Python varun7rs@gmail.com - 2014-04-30 07:57 -0700
      Re: Designing a network in Python Mark H Harris <harrismh777@gmail.com> - 2014-04-30 10:03 -0500
      RE: Designing a network in Python "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-04-30 18:38 +0000
        Re: Designing a network in Python varun7rs@gmail.com - 2014-05-02 02:33 -0700

csiph-web