Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment, you will learn how a UDP load balancer works. A UDP load balancer is a type of load balancer that utilizes User
In this assignment, you will learn how a UDP load balancer works. A UDP load balancer is a type of load balancer that utilizes User Datagram Protocol UDP which operates at layer the transport layer in the open systems interconnection OSI model. UDP traffic communicates at an intermediate level between an application program and the internet protocol IP In this assignment, You will see in its most basic form how a UDP Load Balancer distributes the requests it receives to simple local servers. Firstly, you will examine simple Internet ping servers and a corresponding client written in Python. You can find these codes in the assignment attachment. The structure you should use in your assignment is as seen in Picture In this structure, the UDP load balancer receives requests from the client side and distributes the requests respectively among the servers you see.
Below you will find the exact code of the servers and clients you need to use in the assignment. Please include these four classes unchanged in your project and start analyzing them.
Client Code:
import time import sys from socket import # Check command line arguments if lensysargv: printUsage: python UDPPingerClient sysexit # Create a UDP socket # Notice the use of SOCKDGRAM for UDP packets
clientSocket socketAFINET, SOCKDGRAM # To set waiting time of one second for reponse from server clientSocket.settimeout # Declare server's socket address remoteAddr sysargv intsysargv # Ping ten times for i in range: sendTime time.time message 'PING stri strtimestrftimeH:M:S clientSocket.sendtobytesmessage 'utf remoteAddr try: data, server clientSocket.recvfrom recdTime time.time rtt recdTime sendTime printMessage Received", data printRound Trip Time", rtt except timeout: printREQUEST TIMED OUT'
Server Code:
import random import sys from socket import # Create a UDP socket # Notice the use of SOCKDGRAM for UDP packets serverSocket socketAFINET, SOCKDGRAM # Assign IP address and port number to socket serverSocket.bind while True: # Generate random number in the range of to rand random.randint # Receive the client packet along with the address it is coming from message, address serverSocket.recvfrom printmessage # Capitalize the message from the client message message.upper # If rand is less is than we consider the packet lost and do not respond if rand : continue # Otherwise, the server responds serverSocket.sendtomessage address
Server Code:
import random import sys from socket import # Create a UDP socket # Notice the use of SOCKDGRAM for UDP packets serverSocket socketAFINET, SOCKDGRAM # Assign IP address and port number to socket serverSocket.bind while True: # Generate random number in the range of to rand random.randint # Receive the client packet along with the address it is coming from message, address serverSocket.recvfrom printmessage # Capitalize the message from the client message message.upper # If rand is less is than we consider the packet lost and do not respond if rand : continue # Otherwise, the server responds serverSocket.sendtomessage address
Server Code:
import random import sys from socket import # Create a UDP socket # Notice the use of SOCKDGRAM for UDP packets serverSocket socketAFINET, SOCKDGRAM # Assign IP address and port number to socket serverSocket.bind while True: # Generate random number in the range of to rand random.randint # Receive the client packet along with the address it is coming from message, address serverSocket.recvfrom printmessage # Capitalize the message from the client message message.upper # If rand is less is than we consider the packet lost and do not respond if rand : continue # Otherwise, the server responds serverSocket.sendtomessage address
After reviewing and analyzing these codes, you should only make a ping distribution by adding the udpLoadBalancer class. But this distribution must be in order. So; First incoming ping to Servernd to Serverrd to Serverth to Serverth to Serverth to Serverth to Serverth to Serverth to Server And the th ping must be distributed Server If the client requests one more time, it must continue where it left off. Picture shows the order in which a request made by the client should be distributed to three servers and what kind of output you should get.Picture
Picture
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