Переглянути джерело

adding debug prints of topology/routing table

tarfeef101 6 роки тому
батько
коміт
6591bce42f
1 змінених файлів з 6 додано та 1 видалено
  1. 6 1
      a3/router.py

+ 6 - 1
a3/router.py

@@ -92,16 +92,18 @@ class db:
         for i in this.entries[src - 1]:
             # dupe entry
             if (connection.link == i.link):
-                print("this should be a log")
+                log.write("This was a duplicate packet. Ignoring.")
                 return False
         # not a dupe, insert
         this.entries[src - 1].append(connection)
+        print("Link-State DB: ", this.entries, sep='\n')
         # update entries and connection to contain
         got_dest = connection.infer(this)
         # insert into graph if we have the endpoints for this edge
         if (got_dest):
             graph.insert(connection)
             graph.rebuild()
+            graph.show()
         # notify neighbours
         notify(connection)
         return True
@@ -117,6 +119,9 @@ class graph:
     def lookup(this, dest):
         return this.sssp[dest - 1]
         
+    def show(this):
+        print("SSSP: ", this.sssp)
+        
     def insert(this, connection):
         src = connection.src
         dest = connection.dest