From 770a08b747233942fb19da529763f61987a804d6 Mon Sep 17 00:00:00 2001 From: David Doan Date: Thu, 5 Oct 2023 23:32:06 -0400 Subject: file importing --- cmd/vrouter/main.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cmd/vrouter') diff --git a/cmd/vrouter/main.go b/cmd/vrouter/main.go index 82b8195..158016a 100644 --- a/cmd/vrouter/main.go +++ b/cmd/vrouter/main.go @@ -4,9 +4,37 @@ import ( "bufio" "fmt" "os" + "time" ) +func SendUpdates() { + for _, iface := range myInterfaces { + // send RIP updates to all neighbors + for _, neighbor := range myNeighbors { + iface.udp.Write(neighbor, data) + // wait for response for 12 seconds + response := make([]byte, 512) + iface.udp.Read(response) + time.Sleep(12 * time.Second) + if len(response) == 0 { + RemoveNeighbor(neighbor) + } + } + } + time.Sleep(5 * time.Second) +} + func main() { + if len(os.Args) != 2 { + fmt.Printf("Usage: %s \n", os.Args[0]) + os.Exit(1) + } + + fileName := os.Args[1] + + initialize(fileName) + go SendUpdates() + scanner := bufio.NewScanner(os.Stdin) -- cgit v1.2.3-70-g09d2