Answered step by step
Verified Expert Solution
Question
1 Approved Answer
for server.py import socket import sys if len(sys.argv) == 3: # Get IP address of Server and also the port number from argument 1 and
for server.py
import socket import sys if len(sys.argv) == 3: # Get "IP address of Server" and also the "port number" from argument 1 and argument 2 ip = sys.argv[1] port = int(sys.argv[2]) else: print("Run like : python3 server.py ") exit(1) # Create a UDP socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Bind the socket to the port server_address = (ip, port) s.bind(server_address) print("Do Ctrl+c to exit the program !!") while True: print("####### Server is listening #######") data, address = s.recvfrom(4096) # Split the data into password and message password, message = data.decode('utf-8').split(' ', 1) # Check if the password is correct if password == "1234": # Process the message print(" 2. Server received: ", message, " ") send_data = input("Type some text to send => ") s.sendto(send_data.encode('utf-8'), address) print(" 1. Server sent : ", send_data," ") else: # Ignore the message print("Incorrect password")
for client.py
import socket import sys # Prompt the user to enter a password password = input("Enter password: ") if len(sys.argv) == 3: # Get "IP address of Server" and also the "port number" from argument 1 and argument 2 ip = sys.argv[1] port = int(sys.argv[2]) else: print("Run like : python3 client.py ") exit(1) # Create socket for server s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) print("Do Ctrl+c to exit the program !!") # Let's send data through UDP protocol while True: send_data = input("Type some text to send =>") # Concatenate the password and message send_data = password + " " + send_data s.sendto(send_data.encode('utf-8'), (ip, port)) print(" 1. Client Sent : ", send_data, " ") data, address = s.recvfrom(4096) print(" 2. Client received : ", data.decode('utf-8'), " ") # close the socket s.close()
Rewrite the codes for the server and the client, then connected to oracle VM by using
Wireshark, then screenshot the output - use seed ubuntu 20.04
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started