|
@@ -64,6 +64,9 @@ class connection:
|
|
|
this.link = link
|
|
|
this.cost = cost
|
|
|
|
|
|
+ def show(this):
|
|
|
+ print("Link: " + str(this.sender) + " " + str(this.src) + " " + str(this.link) + " " + str(this.cost))
|
|
|
+
|
|
|
# infers what this connection's (link's) destination is
|
|
|
def infer(this, db):
|
|
|
# search all known paths for one with this link
|
|
@@ -85,6 +88,10 @@ class db:
|
|
|
def __init__(this, routers):
|
|
|
this.entries = [ [] for i in range(routers) ]
|
|
|
|
|
|
+ def show(this):
|
|
|
+ for i in this.entries:
|
|
|
+ show(i)
|
|
|
+
|
|
|
def insert(this, connection):
|
|
|
src = connection.src
|
|
|
# check each entry in the source's list within entries
|
|
@@ -96,7 +103,7 @@ class db:
|
|
|
return False
|
|
|
# not a dupe, insert
|
|
|
this.entries[src - 1].append(connection)
|
|
|
- print("Link-State DB: ", this.entries, sep='\n')
|
|
|
+ this.show()
|
|
|
# update entries and connection to contain
|
|
|
got_dest = connection.infer(this)
|
|
|
# insert into graph if we have the endpoints for this edge
|
|
@@ -120,7 +127,9 @@ class graph:
|
|
|
return this.sssp[dest - 1]
|
|
|
|
|
|
def show(this):
|
|
|
- print("SSSP: ", this.sssp)
|
|
|
+ print("RIB: ")
|
|
|
+ for i in range(0, 5):
|
|
|
+ print("R" + str(rid) + " -> R"+ str(i) + " = " + str(this.sssp[i]))
|
|
|
|
|
|
def insert(this, connection):
|
|
|
src = connection.src
|
|
@@ -168,8 +177,7 @@ class graph:
|
|
|
# no change, we are disconnected. breka
|
|
|
if (mindexsofar == curnode):
|
|
|
break
|
|
|
-
|
|
|
- print("SSSP: this.sssp")
|
|
|
+
|
|
|
|
|
|
|
|
|
|