|
@@ -21,15 +21,17 @@ sock.bind(('', rport))
|
|
|
# send init packet to the emulator
|
|
|
init = ipacket(rid)
|
|
|
sock.sendto(init.package(), (haddr, hport))
|
|
|
+log.write("sent init packet" + "\n")
|
|
|
|
|
|
# receive circuitDB packet from emulator
|
|
|
pack, addr = sock.recvfrom(4096)
|
|
|
circuit = unpacket(pack)[1]
|
|
|
+log.write("received circuit packet" + "\n")
|
|
|
|
|
|
# send shit out to emulator
|
|
|
for i in circuit.getlink():
|
|
|
sock.sendto(hpacket(rid, i.getlid()).package(), (haddr, hport))
|
|
|
-
|
|
|
+ log.write("sent hello packet to link" + str(i.getlid()) + "\n")
|
|
|
|
|
|
|
|
|
# CLASS AND FUNCTION DEFINITIONS
|
|
@@ -38,6 +40,7 @@ def send_links(link):
|
|
|
for i in circuit.getlink():
|
|
|
# make lspdu with link info, router as
|
|
|
sock.sendto(lpacket(rid, rid, i.getlid(), i.getcost(), link).package(), (haddr, hport))
|
|
|
+ log.write("sent lspdu packet: " + str(rid) + " " + str(rid) + " " + str(i.getlid()) + " " + str(i.getcost()) + " " + str(link) + "\n")
|
|
|
|
|
|
# notify neighbours of this new lspdu entry
|
|
|
def notify(connection):
|
|
@@ -50,6 +53,7 @@ def notify(connection):
|
|
|
#dlink = graph.lookup(i[0])
|
|
|
# send to neighbour using dlink
|
|
|
sock.sendto(lpacket(rid, connection.src, connection.link, connection.cost, i[0]).package(), (haddr, hport))
|
|
|
+ log.write("sent lspdu packet: " + str(rid) + " " + str(connection.src) + " " + str(connection.link) + " " + str(connection.cost) + " " + str(i[0]) + "\n")
|
|
|
|
|
|
|
|
|
class connection:
|
|
@@ -176,6 +180,7 @@ while (1):
|
|
|
|
|
|
# hello packet
|
|
|
if (ptype == 1):
|
|
|
+ log.write("received hello packet from: " + str(pack.rid) + " with link: " + str(pack.lid) + "\n")
|
|
|
# save hello in hellodb
|
|
|
neighbours.append((pack.rid, pack.lid))
|
|
|
# reply with the links from circuit sent individually as lspdus
|
|
@@ -183,6 +188,7 @@ while (1):
|
|
|
continue
|
|
|
# lspdu packet
|
|
|
elif (ptype == 2):
|
|
|
+ log.write("received lspdu packet: " + str(pack.sid) + " " + str(pack.rid) + " " + str(pack.lid) + " " + str(pack.cost) + " " + str(pack.slid) + "\n")
|
|
|
# add router ID (link source), linkid, cost to db (only if not a dupe)
|
|
|
conn = connection(pack.sid, pack.rid, None, pack.lid, pack.cost)
|
|
|
database.insert(conn)
|