diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-10-23 11:12:49 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-10-23 11:12:49 -0400 |
commit | cb605f4bd1868c443799f4764e9400ada2c08eb8 (patch) | |
tree | 2cc3ed66855374c80952934ce08ce93889539bf6 | |
parent | 097e6330ec777698cbaf87e008df9295e9978782 (diff) |
send triggered updates when any! entry in the table is created, updated, or deleted
-rw-r--r-- | pkg/ipstack/ipstack.go | 11 | ||||
-rwxr-xr-x | vhost | bin | 3104664 -> 3105056 bytes | |||
-rwxr-xr-x | vrouter | bin | 3104672 -> 3105056 bytes |
3 files changed, 11 insertions, 0 deletions
diff --git a/pkg/ipstack/ipstack.go b/pkg/ipstack/ipstack.go index c8a4fe8..4556f0f 100644 --- a/pkg/ipstack/ipstack.go +++ b/pkg/ipstack/ipstack.go @@ -843,6 +843,7 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I destination := entry.prefix.Masked() // fmt.Println(prefix.String()) + triggeredEntries := make([]RIPEntry, 0) // check if the entry is already in the routing table and update if need be if hop, ok := routingTable[destination]; ok { // if the hop is the same as the incoming neighbor, @@ -853,8 +854,10 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I if entry.cost == INFINITY { // if we receive infinity from the same neighbor, then delete the route delete(routingTable, destination) + triggeredEntries = append(triggeredEntries, RIPEntry{destination, INFINITY}) } else { routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost + 1}) } } @@ -863,8 +866,10 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I if entry.cost < hop.Cost { if entry.cost == INFINITY { routingTable[destination] = Hop{entry.cost, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost}) } else { routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost + 1}) } } @@ -883,7 +888,13 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I // routingTable[destination] = Hop{0, "R", src, hdr.Src} //} else { routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost + 1}) // } + + // send out triggered updates + if len(triggeredEntries) > 0 { + sendTriggeredUpdates(triggeredEntries) + } } } |