diff options
| -rw-r--r-- | assignments/2/README.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/assignments/2/README.md b/assignments/2/README.md index b51499e..9fab554 100644 --- a/assignments/2/README.md +++ b/assignments/2/README.md @@ -332,6 +332,26 @@ b. 135.46.53.16 -> no /22 match -> forward using Default -> Router 3. c. 192.53.40.6 -> matches 192.53.40.0/23 -> forward to Router 2. d. 192.53.56.7 -> no /23 match -> forward using Default -> Router 3. +```ruby +require 'ipaddr' + +routes = [ + IPAddr.new('135.46.56.0/22'), + IPAddr.new('135.46.60.0/22'), + IPAddr.new('192.53.40.0/23'), +] + +a = IPAddr.new("135.46.61.10") +b = IPAddr.new("135.46.53.16") +c = IPAddr.new("192.53.40.6") +d = IPAddr.new("192.53.56.7") + +puts routes.find { |route| route.include?(a) } || "Default" +puts routes.find { |route| route.include?(b) } || "Default" +puts routes.find { |route| route.include?(c) } || "Default" +puts routes.find { |route| route.include?(d) } || "Default" +``` + ## 2.4 TCP Congestion Control (20%) > (20%) Consider that only a single TCP connection uses a 1 Gbps link, |
