Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10. Refer to the code snippet below and answer the following questions: (a) To w

ID: 3732112 • Letter: 1

Question

10. Refer to the code snippet below and answer the following questions: (a) To what host IP address and what port the program attempts to connect? What line(s) in the code contain this information? (b) What transport protocol is used? What line(s) in the code indicate this? (c) Is there any checking performed in this snippet (including underlying transport and network protocols) to ensure that the other end has accepted the connection and is receiving data? Explain why. (d) How many packets are exchanged between the computer running the program and the re mote host if the function call near the end of the snippet (send (sfd, data, len, 0)) is successful?

Explanation / Answer

a)
It is trying to connect to "at5030-eng2453server.lakeheadu.ca"
Port number it is trying to connect to is 40233
These values are present in the getaddrinfo() function.

b)
The transport protocol we are using is UDP.
Lines 3,4 indicates this and also line containing sendto()(Line 20) also indicates that we are using UDP protocol since in C, we use sendto() for UDP protocol

c)
No. There is no checking performed to ensure that the other end has accepted the connection and is receiving data. This is because we are using the UDP protocol and it is unreliable. It only cares about sending the packet and it doesn't care about the message delivery to the recipient.

d)
If the function call is successful , then , since the for loop is running for 3 times and for each iteration of the loop , we are sending a packet. Hence, 3 packets will be sent

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote