From: Paul J R Date: Sat, 23 Aug 2014 07:48:30 +0000 (+1000) Subject: lots of stuff X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=f0136533a0fdc35d95c7371d04cd9ed25063c7b0;p=random_node_code.git lots of stuff --- diff --git a/bgpfake/bf2.js b/bgpfake/bf2.js index 267ed34..8823a36 100644 --- a/bgpfake/bf2.js +++ b/bgpfake/bf2.js @@ -22,6 +22,10 @@ var timerIntervalObject; var currentCon = 0; var sequentialIPs = true; var usePrivateRanges = false; +var randomNextHop = false; +var timeBetweenUpdates = 1000; +var routesPerUpdate = 100; +var updatesPerInterval = 20; // ---- vars @@ -100,6 +104,9 @@ function startCLI() { case "t": toggleIPChoice(); break; + case "m": + toggleRandomNextHop(); + break; case "s": printStatus(); break; @@ -123,6 +130,21 @@ function startCLI() { }); } + +function printStatus() { + console.log("---- Status ----"); + console.log("Currently "+cState); + console.log("Private ranges: "+usePrivateRanges); + console.log("Sequential publication: "+sequentialIPs); + console.log("Random NextHop: "+randomNextHop); + console.log("Number of connected peers: " + nCons); + console.log("Number of routes published: " + nSent); + console.log("My IP address: " + myIP); + console.log("My ASN: " + myAS); + console.log("Current IP (for sequential publications): " + currentIPa + "." + currentIPb + "." + currentIPc + "0/24"); + console.log("AS path table size: "+asPaths.length); +} + function togglePrivateRange() { if(usePrivateRanges) { console.log("Switching off private range publication"); @@ -141,7 +163,17 @@ function toggleIPChoice() { console.log("Switching to sequential IP addresses"); sequentialIPs = true; } - +} + + +function toggleRandomNextHop() { + if(randomNextHop) { + randomNextHop = false; + console.log("Switching form random next-hop to next-hop-self"); + } else { + randomNextHop = true; + console.log("Switching form next-hop-self to random next-hop"); + } } @@ -157,6 +189,7 @@ function printCLIUsage() { console.log("\tu - start sending route updates to connected peers"); console.log("\tp - pause sending route updates to connected peers"); console.log("\ta - toggle use of private ranges"); + console.log("\tm - toggle between random next hop and my ip as next hop (randomise last octet - assumes /24 on the ip address of this node)"); console.log("\ts - status"); console.log("\tt - toggles between random and sequential addressing"); console.log("\tr - reset IP range back to beginning"); @@ -247,7 +280,7 @@ function startUpdates() { // here goes nothing console.log("LOG: starting update sending"); updateState("sending"); - timerIntervalObject = setInterval(sendUpdate, 5); + timerIntervalObject = setInterval(sendUpdate, timeBetweenUpdates); //console.log("LOG: stopped sending updates"); } @@ -259,8 +292,8 @@ function sendUpdate() clearInterval(timerIntervalObject); updateState("ready"); } else { - for(var i=0; i<10; i++) { - var msg = constructUpdateMessage(100); + for(var i=0; i