Browse Source

buggy asf, but it runs. and i am super done with this shit

tarfeef101 6 years ago
parent
commit
8e20b53d22
2 changed files with 23 additions and 2 deletions
  1. 18 0
      a3/README.md
  2. 5 2
      a3/router.py

+ 18 - 0
a3/README.md

@@ -0,0 +1,18 @@
+
+# CS 456 A3 - Router
+
+This assignment consists of 1 python application abstracted through a shell script: router (no file extension, as per the assignment spec). This is an interface for the python script router.py. There is also a packets.py file which has my packet unpacking function, and classes for the packet types. There is also the emulator file in the folder as well.
+
+## Build Information
+ - This was tested on linux.student.cs.uwaterloo.ca, so the ubuntu1604 servers maintained by the CS faculty at uWaterloo.
+ - Testing was done all on 008, with 5 routers and the emulator all running locally.
+ - The python version used was 3.5.2
+
+## Deployment
+
+To run either the router simply type "./router" followed by all the arguments that need to be provided. Of course, the emulator should be run as well, in accordance with the provided spec. The arguments for the router are listed below for convenience:
+
+- router_id (unique int), nse_host (string/hostname), nse_port (int), router_port (int)
+## Authors
+
+* **Tareef Dedhar** - *All work*

+ 5 - 2
a3/router.py

@@ -127,12 +127,14 @@ class graph:
         
         
     def lookup(this, dest):
     def lookup(this, dest):
         return this.sssp[dest - 1]
         return this.sssp[dest - 1]
-        
+    
+    # logs RIB to log file
     def show(this):
     def show(this):
         log.write("RIB: " + '\n')
         log.write("RIB: " + '\n')
         for i in range(0, 5):
         for i in range(0, 5):
             log.write("R" + str(rid) + " -> R"+ str(i + 1) + " = " + str(this.sssp[i][0]) + " using node " + str(this.sssp[i][1] + 1) + '\n')
             log.write("R" + str(rid) + " -> R"+ str(i + 1) + " = " + str(this.sssp[i][0]) + " using node " + str(this.sssp[i][1] + 1) + '\n')
-        
+    
+    # insert the weight of the connection to the graph for src to dest and vice versa
     def insert(this, connection):
     def insert(this, connection):
         src = connection.src
         src = connection.src
         dest = connection.dest
         dest = connection.dest
@@ -161,6 +163,7 @@ class graph:
                 # visited already
                 # visited already
                 if (unvisited[i] == 0):
                 if (unvisited[i] == 0):
                     continue
                     continue
+                # only update if going through curnode is faster
                 result = min((this.sssp[curnode][0] + this.alist[curnode][i]), this.sssp[i][0])
                 result = min((this.sssp[curnode][0] + this.alist[curnode][i]), this.sssp[i][0])
                 if (result != this.sssp[i][0]):
                 if (result != this.sssp[i][0]):
                     this.sssp[i] = (result, this.sssp[curnode][1])
                     this.sssp[i] = (result, this.sssp[curnode][1])