1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
pentagon [3]
3 years ago
15

Lab 2: UDP Pinger Lab In this lab, you will learn the basics of socket programming for UDP in Python. You will learn how to send

and receive datagram packets using UDP sockets and also, how to set a proper socket timeout. Throughout the lab, you will gain familiarity with a Ping application and its usefulness in computing statistics such as packet loss rate. You will first study a simple Internet ping server written in the Python, and implement a corresponding client. The functionality provided by these programs is similar to the functionality provided by standard ping programs available in modern operating systems. However, these programs use a simpler protocol, UDP, rather than the standard Internet Control Message Protocol (ICMP) to communicate with each other. The ping protocol allows a client machine to send a packet of data to a remote machine, and have the remote machine return the data back to the client unchanged (an action referred to as echoing). Among other uses, the ping protocol allows hosts to determine round-trip times to other machines
PYTHON ONLY PLEASE WITH COMMENTS
# UDPPingerServer.py
# We will need the following module to generate randomized lost packets
import random
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(('', 12000))
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)
# 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)

Packet Loss UDP

provides applications with an unreliable transport service. Messages may get lost in the network due to router queue overflows, faulty hardware or some other reasons. Because packet loss is rare or even non-existent in typical campus networks, the server in this lab injects artificial loss to simulate the effects of network packet loss. The server creates a variable randomized integer which determines whether a particular incoming packet is lost or not.

Client Code You need to implement the following client program. The client should send 10 pings to the server. Because UDP is an unreliable protocol, a packet sent from the client to the server may be lost in the network, or vice versa. For this reason, the client cannot wait indefinitely for a reply to a ping message. You should get the client wait up to one second for a reply; if no reply is received within one second, your client program should assume that the packet was lost during transmission across the network. You will need to look up the Python documentation to find out how to set the timeout value on a datagram socket.

Specifically, your client program should

(1) send the ping message using UDP (Note: Unlike TCP, you do not need to establish a connection first, since UDP is a connectionless protocol.)

(2) print the response message from server, if any

(3) calculate and print the round trip time (RTT), in seconds, of each packet, if server responses

(4) otherwise, print "Request timed out"

During development, you should run the UDPPingerServer.py on your machine, and test your client by sending packets to localhost (or, 127.0.0.1). After you have fully debugged your

code, you should see how your application communicates across the network with the ping server and ping client running on different machines.

Message Format

The ping messages in this lab are formatted in a simple way. The client message is one line, consisting of ASCII characters in the following format: Ping sequence_number time where sequence_number starts at 1 and progresses to 10 for each successive ping message sent by the client, and time is the time when the client sends the message.
Computers and Technology
1 answer:
Alex17521 [72]3 years ago
8 0

Answer:

huhhuikkkkkkkkkkkkkkkkkkkkkkkkkkkk

You might be interested in
Which of the following statements about light-emitting diodes is correct?
defon

The correct answer if B

4 0
3 years ago
Computer Applications
abruzzese [7]

Answer:

a b e

Explanation:

3 0
3 years ago
This is in government
Anon25 [30]
I would have thought that it was C.

5 0
3 years ago
This provides an easy method for workers to use their computers.
Keith_Richards [23]

GUI is your the method.Hope that helps.

3 0
4 years ago
Read 2 more answers
Window to Viewport Transformation is the process of transforming a 2D world-coordinate objects to device coordinates. Objects in
klemol [59]

Answer:

It is not necessary to display data in a graph if the linear transformation, a line segment, maps the window to the port preserving relative positions of the two dimensional view. The real world object is a transformedinto relative position points to the viewing volume.

Computer graphics begins then with linear transformations called clipping.

Explanation:

When surfing the internet using your mouse through tablets and mobile phones, the wizard´s default provided viewport varies as it is a polygon or the visible window mapped in computer graphics for a user redered by device-specific coordinates, position and orientation.

You can add multiple viewpoints as it is an HTML meta tag, @ rule in CSS. Styles and other features can be set when designing websites so you can provide the site to be shown in different devices.

5 0
4 years ago
Other questions:
  • A college meal plan allows students to:
    7·2 answers
  • To use the Web, each client computer requires a data link layer software package called a Web browser. True False
    8·1 answer
  • If the pc-doctor software is installed on a computer's hard drive, what two different ways can the program be started?
    9·1 answer
  • Which one of the following is not the name of a 20th century school composition
    14·2 answers
  • Rachelle is an office manager for an active real estate agency. She’s overseeing a transition to a more complete reliance on ele
    9·1 answer
  • Which of the following conditions will maximize the amount of interest you earn
    5·1 answer
  • Microsoft outlook is one of the most widely used _____ software applications
    6·1 answer
  • Use the drop-down menus to select the type of goal described in each statement. I want to finish all of my social studies homewo
    14·1 answer
  • Which steps will open the Access Options dialog box? Complete each statement using the drop-down menus
    14·2 answers
  • How to type this [attachment] type of symbol in ms word.​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!