Question 2: Consider the following network configuration 172.10.1.0/24 R1 R2 R3
ID: 3799095 • Letter: Q
Question
Question 2: Consider the following network configuration 172.10.1.0/24 R1 R2 R3 172 10-so/24 RS) The routers are configured through static route command, and the route entries of different routes are as follows: @RS: IP route 0.0.0.0 0.0.0.0 10.1.2.2 @R1: IP route 0.0.0.0 0.0.0.0 192.168.1.2. IP route 10.1.1.0 255.255.255.0 10.1.2. 1 @R2: IP route 10.1.0.0 255.255.254.0 192.168, 2.1 IP route 172.10.3.0 255.255.255.0 192.168.2.1 IP route 0.0.0.0 0.0.0.0 172.10.2.2 @R4: IP route 0.0.0.0 0.0.0.0 172.10.3.1 IP route 192.168.2.0 255.255.255.0 172, 10.3.1 @R3: IP route 10.1.2.0 255.255.255.128 10.1.1.1 IP route 172.10.2.0 255.255.255.0 172.10.3.2 IP route 0.0.0.0 0.0.0.0 191.168.2.2Explanation / Answer
# below program is coded in python
#put all the routes paths into file named host.txt , which would be called in the program
import os
import sys
import Queue
import platform
import subprocess
import threading
def path_finder(ArgsPing, remaining, completed):
try:
while True:
address = remaining.get_nowait() # to obtain the next address to be pinged.
ping = subprocess.Popen(ping_args + [address],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE
)
out, error = ping.communicate()
completed.put((out, error)) # to send the result to 'completed' queue.
except Queue.Empty: # end of address.
pass
finally:
completed.put(None) # to inform main thread is to be completed
NUM_SYSTEM = 4 # number of address.
plat = platform.system()
scriptDir = sys.path[0]
hosts = os.path.join(scriptDir, 'hosts.txt') #puut the network path in host.txt file and give it as input
if plat == "Windows": # The arguments for the 'ping', excluding the address.
ArgsPing = ["ping", "-n", "1", "-l", "1", "-w", "100"]
elif plat == "Linux":
ArgsPing = ["ping", "-c", "1", "-l", "1", "-s", "1", "-W", "1"]
else:
raise ValueError("Unknown platform")
remaining = Queue.Queue() # to queue the addresses to ping.
completed = Queue.Queue() # to queue the results.
systems = [] # Create as all the different systems.
for _ in range(NUM_SYSTEMS):
systems.append(threading.Thread(target=path_finder, args=(ArgsPing, remaining, completed)))
# Put all the addresses into the 'remaining' queue.
with open(hosts, "r") as hostsFile:
for line in hostsFile:
remaining.put(line.strip())
for s in systems: # Start all the systems.
s.daemon = True
s.start()
numTerminated = 0 # Print out the results as they arrive.
while numTerminated < NUM_SYSTEMS:
result = completed.get()
if result is None:
numTerminated += 1 # A systems is about to terminate.
else:
print result[0] # out
print result[1] # error
for s in systems: # Waiting for all systems to terminate.
s.join()
if you are not intrested in program the paths can also be traced using different tools such as PathPing or PathInfo for details of using these tools chechk out the related websites.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.