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

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.
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
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[2])) # Ping ten times for i in range(10): sendTime = time.time() message = 'PING '+ str(i +1)+""+ str(time.strftime("%H:%M:%S")) 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 TIMED OUT')
Server1 Code:
import random import sys from socket import * # Create a UDP socket # Notice the use of SOCK_DGRAM for UDP packets serverSocket = socket(AF_INET, 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 4: continue # Otherwise, the server responds serverSocket.sendto(message, address)
Server2 Code:
import random import sys from socket import * # Create a UDP socket # Notice the use of SOCK_DGRAM for UDP packets serverSocket = socket(AF_INET, SOCK_DGRAM) # Assign IP address and port number to socket serverSocket.bind(('',2527)) 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 4: continue # Otherwise, the server responds serverSocket.sendto(message, address)
Server3 Code:
import random import sys from socket import * # Create a UDP socket # Notice the use of SOCK_DGRAM for UDP packets serverSocket = socket(AF_INET, SOCK_DGRAM) # Assign IP address and port number to socket serverSocket.bind(('',2528)) 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 4: continue # Otherwise, the server responds serverSocket.sendto(message, 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 Server1,2nd to Server2,3rd to Server3,4th to Server1,5th to Server2,6th to Server3,7th to Server1,8th to Server2,9th to Server3, And the 10th ping must be distributed Server1. If the client requests one more time, it must continue where it left off. Picture_2 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_1
Picture_2
image text in transcribed

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

Step: 3

blur-text-image

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 Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

List the types of issues that related to a special needs situation.

Answered: 1 week ago

Question

1 What are the three key facets of HRP?

Answered: 1 week ago