Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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 4 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_1. In this structure, the UDP load balancer receives requests from the client side and distributes the requests respectively among the 3 servers you see. Picture_1 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 len (sys.argv) !=3 : print("Usage: python UDPPingerclient ") sys.exit() Create a UDP socket Notice the use of SOCK DGRAM for UDP packets 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 len (sys.argv) !=3 : print ("Usage: python UDPPingerclient n) sys.exit () Create a UDP'socket Notice the use of SOCk DGRAM for dDe packets clientSocket =socket(AF INET, SOCK DGRAM) \# To set waiting time of one second for reponse from server clientSocket.settimeout (1) \# Declare server's socket address remoteAddr = (sys.argv[1], int (sys.argv[21)) \# Bing ten times for i in range (10): sendTime = time.time () clientsocket. sendto (bytes (message, 'utf-8'), remoteAddr) try: data, server = clientsocket. recvfrom(1024) recdTime = time.time () rtt = recdTime - sendTime print ("Message Received", data) print ("Round Trip Time", rtt) except timeout: print ('REQUEST TIMBD OUT') Server1 Code: mport random import sys from socket import * Create a ung socket \# Notice the use of SOCK DCRAM for UDR packets serversocket =socket(AF - INDT, SOCK DGRAM) \# Assign IP address and port number to socket serverSocket. bind ( ( ' ', 2526) ) while True: \# Generate random number in the range of 0 to 10 rand = random.randint (0,10) \# Receive the client packet along with the address it is coming from message, address = serverSocket.recvfrom(1024) print (message) \# Capitalize the message from the client message = message.upper () \# If rand is less is than 4, we consider the packet lost and do not respond if rand

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago