Task 2: Scan The Network Project Description: Developing a Hop-Counting Application in Python or Java Objective: The goal of this project is to develop a network application in Python or Java that measures and displays the number of hops a packet traverses as it travels from the source to a destination over the internet. This application will help users understand the path their data takes and the number of intermediate devices (routers) it passes through. Key Features: 1. Hop Count Measurement: о The application will use ICMP (Internet Control Message Protocol) or traceroute- о like functionality to determine the number of hops between the source and destination. It will send packets with incrementing Time-To-Live (TTL) values to identify each hop along the path. 2. Destination Input: О о Users will be able to input a destination IP address or domain name (e.g., google.com or 8.8.8.8). The application will resolve domain names to IP addresses if 3. Hop-by-Hop Analysis: necessary. о The application will display the IP addresses of each intermediate router (hop) along the path. о It will calculate and display the total number of hops to reach the destination. 4. Latency Measurement (Optional): о The application can measure and display the round-trip time (RTT) for each hop, providing insights into network latency. 5. Cross-Platform Compatibility: The application will be designed to run on multiple operating systems (Windows, Linux, macOS) using Python or Java's cross-platform capabilities. 6. User-Friendly Interface: о о A simple command-line interface (CLI) will be provided for ease of use. Optionally, a graphical user interface (GUI) can be developed for enhanced usability. Technical Implementation: • • Python Implementation: Use the scapy library to craft and send custom packets with varying TTL values. Leverage the socket library for domain name resolution and basic networking operations. Implement ICMP packet handling to receive and process responses from routers. Java Implementation: о о О Use Java's java.net package to handle network communication. Implement ICMP packet creation and parsing manually or using third-party libraries like jpcap. Use multithreading to handle packet sending and receiving concurrently. Expected Output: 1. A list of IP addresses for each hop along the path. 2. The total number of hops to reach the destination. 3. (Optional) Round-trip time (RTT) for each hop. Server Code import socket import threading import random # Server Configuration HOST = "172.21.5.199" # Listen on all available network interfaces PORT = 12345 MAX_CAPACITY = 2000 # 2-litre bottle (2000 mL) clients = [] student_info = {} # Stores client IP and student number turn_index = 0 current fill=0 lock-threading.Lock() def handle_client(client_socket, client_address): global turn_index, current_fill try: # Receive student number from client student_number = client_socket.recv(1024).decode().strip() student_info[client_socket] = (client_address[0], student_number) print(f"New connection from {client_address[0]} | Student Number: {student_number}") while True: with lock: if current fill >=MAX CAPACITY: client_socket.sendall("Bottle is full! Stopping process.\n".encode()) break if clients [turn_index] = =client socket: pour_amount=random.randint(0, 50) current_fill += pour_amount message (f"Your turn! You poured {pour_amount} mL. " f"Current bottle level: {current_fill}/{MAX_CAPACITY} mL\n") client_socket.sendall (message.encode()) turn_index = (turn_index + 1) % len(clients) #Move to the next client else: client_socket.sendall("Not your turn. Please wait.\n".encode()) except ConnectionResetError: print(f"Client {client_address[0]} disconnected.") finally: client_socket.close() def start_server(): global clients server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind((HOST, PORT)) server_socket.listen(5) print(f"Server listening on {HOST}:{PORT}") while True: client_socket, client_address = server_socket.accept() clients.append(client_socket) client_thread = threading.Thread(target=handle_client, args=(client_socket, client_address)) client_thread.start() if name main ". start_server()
Task 2: Scan The Network Project Description: Developing a Hop-Counting Application in Python or Java Objective: The goal of this project is to develop a network application in Python or Java that measures and displays the number of hops a packet traverses as it travels from the source to a destination over the internet. This application will help users understand the path their data takes and the number of intermediate devices (routers) it passes through. Key Features: 1. Hop Count Measurement: о The application will use ICMP (Internet Control Message Protocol) or traceroute- о like functionality to determine the number of hops between the source and destination. It will send packets with incrementing Time-To-Live (TTL) values to identify each hop along the path. 2. Destination Input: О о Users will be able to input a destination IP address or domain name (e.g., google.com or 8.8.8.8). The application will resolve domain names to IP addresses if 3. Hop-by-Hop Analysis: necessary. о The application will display the IP addresses of each intermediate router (hop) along the path. о It will calculate and display the total number of hops to reach the destination. 4. Latency Measurement (Optional): о The application can measure and display the round-trip time (RTT) for each hop, providing insights into network latency. 5. Cross-Platform Compatibility: The application will be designed to run on multiple operating systems (Windows, Linux, macOS) using Python or Java's cross-platform capabilities. 6. User-Friendly Interface: о о A simple command-line interface (CLI) will be provided for ease of use. Optionally, a graphical user interface (GUI) can be developed for enhanced usability. Technical Implementation: • • Python Implementation: Use the scapy library to craft and send custom packets with varying TTL values. Leverage the socket library for domain name resolution and basic networking operations. Implement ICMP packet handling to receive and process responses from routers. Java Implementation: о о О Use Java's java.net package to handle network communication. Implement ICMP packet creation and parsing manually or using third-party libraries like jpcap. Use multithreading to handle packet sending and receiving concurrently. Expected Output: 1. A list of IP addresses for each hop along the path. 2. The total number of hops to reach the destination. 3. (Optional) Round-trip time (RTT) for each hop. Server Code import socket import threading import random # Server Configuration HOST = "172.21.5.199" # Listen on all available network interfaces PORT = 12345 MAX_CAPACITY = 2000 # 2-litre bottle (2000 mL) clients = [] student_info = {} # Stores client IP and student number turn_index = 0 current fill=0 lock-threading.Lock() def handle_client(client_socket, client_address): global turn_index, current_fill try: # Receive student number from client student_number = client_socket.recv(1024).decode().strip() student_info[client_socket] = (client_address[0], student_number) print(f"New connection from {client_address[0]} | Student Number: {student_number}") while True: with lock: if current fill >=MAX CAPACITY: client_socket.sendall("Bottle is full! Stopping process.\n".encode()) break if clients [turn_index] = =client socket: pour_amount=random.randint(0, 50) current_fill += pour_amount message (f"Your turn! You poured {pour_amount} mL. " f"Current bottle level: {current_fill}/{MAX_CAPACITY} mL\n") client_socket.sendall (message.encode()) turn_index = (turn_index + 1) % len(clients) #Move to the next client else: client_socket.sendall("Not your turn. Please wait.\n".encode()) except ConnectionResetError: print(f"Client {client_address[0]} disconnected.") finally: client_socket.close() def start_server(): global clients server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind((HOST, PORT)) server_socket.listen(5) print(f"Server listening on {HOST}:{PORT}") while True: client_socket, client_address = server_socket.accept() clients.append(client_socket) client_thread = threading.Thread(target=handle_client, args=(client_socket, client_address)) client_thread.start() if name main ". start_server()
Chapter13: Internet And Distributed Application Services
Section: Chapter Questions
Problem 12VE
Related questions
Question
Please help me answer this coding question in the images below for me(it is not a graded question):
write the code using python and also provide the outputs required

Transcribed Image Text:Task 2: Scan The Network
Project Description: Developing a Hop-Counting Application in Python or Java
Objective:
The goal of this project is to develop a network application in Python or Java that measures and
displays the number of hops a packet traverses as it travels from the source to a destination over the
internet. This application will help users understand the path their data takes and the number of
intermediate devices (routers) it passes through.
Key Features:
1. Hop Count Measurement:
о The application will use ICMP (Internet Control Message Protocol) or traceroute-
о
like functionality to determine the number of hops between the source and
destination.
It will send packets with incrementing Time-To-Live (TTL) values to identify each
hop along the path.
2. Destination Input:
О
о
Users will be able to input a destination IP address or domain name
(e.g., google.com or 8.8.8.8).
The application will resolve domain names to IP addresses if
3. Hop-by-Hop Analysis:
necessary.
о The application will display the IP addresses of each intermediate router (hop) along
the path.
о
It will calculate and display the total number of hops to reach the destination.
4. Latency Measurement (Optional):
о
The application can measure and display the round-trip time (RTT) for each hop,
providing insights into network latency.
5. Cross-Platform Compatibility:
The application will be designed to run on multiple operating systems (Windows,
Linux, macOS) using Python or Java's cross-platform capabilities.
6. User-Friendly Interface:
о
о
A simple command-line interface (CLI) will be provided for ease of use.
Optionally, a graphical user interface (GUI) can be developed for enhanced usability.
Technical Implementation:
•
•
Python Implementation:
Use the scapy library to craft and send custom packets with varying TTL values.
Leverage the socket library for domain name resolution and basic networking
operations.
Implement ICMP packet handling to receive and process responses from routers.
Java Implementation:
о
о
О
Use Java's java.net package to handle network communication.
Implement ICMP packet creation and parsing manually or using third-party libraries
like jpcap.
Use multithreading to handle packet sending and receiving concurrently.
Expected Output:
1. A list of IP addresses for each hop along the path.
2. The total number of hops to reach the destination.
3. (Optional) Round-trip time (RTT) for each hop.
![Server Code
import socket
import threading
import random
# Server Configuration
HOST = "172.21.5.199" # Listen on all available network interfaces
PORT = 12345
MAX_CAPACITY = 2000 # 2-litre bottle (2000 mL)
clients = []
student_info = {} # Stores client IP and student number
turn_index = 0
current fill=0
lock-threading.Lock()
def handle_client(client_socket, client_address):
global turn_index, current_fill
try:
# Receive student number from client
student_number = client_socket.recv(1024).decode().strip()
student_info[client_socket] = (client_address[0], student_number)
print(f"New connection from {client_address[0]} | Student Number: {student_number}")
while True:
with lock:
if current fill >=MAX CAPACITY:
client_socket.sendall("Bottle is full! Stopping process.\n".encode())
break
if clients [turn_index] =
=client socket:
pour_amount=random.randint(0, 50)
current_fill += pour_amount
message (f"Your turn! You poured {pour_amount} mL. "
f"Current bottle level: {current_fill}/{MAX_CAPACITY} mL\n")
client_socket.sendall (message.encode())
turn_index = (turn_index + 1) % len(clients) #Move to the next client
else:
client_socket.sendall("Not your turn. Please wait.\n".encode())
except ConnectionResetError:
print(f"Client {client_address[0]} disconnected.")
finally:
client_socket.close()
def start_server():
global clients
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((HOST, PORT))
server_socket.listen(5)
print(f"Server listening on {HOST}:{PORT}")
while True:
client_socket, client_address = server_socket.accept()
clients.append(client_socket)
client_thread = threading.Thread(target=handle_client, args=(client_socket, client_address))
client_thread.start()
if
name
main ".
start_server()](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fde7dd9b3-9eda-4198-b273-8135950dd6b7%2F67d92c9d-854e-4e5d-8a74-f157928d9b54%2Fsecm0ml_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Server Code
import socket
import threading
import random
# Server Configuration
HOST = "172.21.5.199" # Listen on all available network interfaces
PORT = 12345
MAX_CAPACITY = 2000 # 2-litre bottle (2000 mL)
clients = []
student_info = {} # Stores client IP and student number
turn_index = 0
current fill=0
lock-threading.Lock()
def handle_client(client_socket, client_address):
global turn_index, current_fill
try:
# Receive student number from client
student_number = client_socket.recv(1024).decode().strip()
student_info[client_socket] = (client_address[0], student_number)
print(f"New connection from {client_address[0]} | Student Number: {student_number}")
while True:
with lock:
if current fill >=MAX CAPACITY:
client_socket.sendall("Bottle is full! Stopping process.\n".encode())
break
if clients [turn_index] =
=client socket:
pour_amount=random.randint(0, 50)
current_fill += pour_amount
message (f"Your turn! You poured {pour_amount} mL. "
f"Current bottle level: {current_fill}/{MAX_CAPACITY} mL\n")
client_socket.sendall (message.encode())
turn_index = (turn_index + 1) % len(clients) #Move to the next client
else:
client_socket.sendall("Not your turn. Please wait.\n".encode())
except ConnectionResetError:
print(f"Client {client_address[0]} disconnected.")
finally:
client_socket.close()
def start_server():
global clients
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((HOST, PORT))
server_socket.listen(5)
print(f"Server listening on {HOST}:{PORT}")
while True:
client_socket, client_address = server_socket.accept()
clients.append(client_socket)
client_thread = threading.Thread(target=handle_client, args=(client_socket, client_address))
client_thread.start()
if
name
main ".
start_server()
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images

Recommended textbooks for you

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning

LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L

Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781285867168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning

LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L

Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781285867168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning

A+ Guide to Hardware (Standalone Book) (MindTap C…
Computer Science
ISBN:
9781305266452
Author:
Jean Andrews
Publisher:
Cengage Learning

Enhanced Discovering Computers 2017 (Shelly Cashm…
Computer Science
ISBN:
9781305657458
Author:
Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. Campbell
Publisher:
Cengage Learning