Skip to content
Snippets Groups Projects
Commit 98dd0e98 authored by Wendy Nguyen's avatar Wendy Nguyen
Browse files

update

parent 9f9d4135
No related branches found
No related tags found
No related merge requests found
1. How does the remote client determine when a command's output is fully received from the server, and what techniques can be used to handle partial reads or ensure complete message transmission?
_answer here_
>_The remote client determines when command output is complete by looking for the EOF character (RDSH_EOF_CHAR) sent by the server. Since TCP may split messages into multiple packets, the client needs to:_
>
>- _Use a loop to keep receiving data until EOF is found_
>- _Buffer partial reads and append new data_
>- _Check each received chunk for the EOF marker_
>- _Only consider the command complete once EOF is received_
>
>_This ensures reliable message boundaries even if TCP fragments the data across multiple network packets._
2. This week's lecture on TCP explains that it is a reliable stream protocol rather than a message-oriented one. Since TCP does not preserve message boundaries, how should a networked shell protocol define and detect the beginning and end of a command sent over a TCP connection? What challenges arise if this is not handled correctly?
_answer here_
>_A networked shell protocol should:_
>
>- _Use null termination (\0) for commands sent from client to server_
>- _Use a special EOF character for server responses back to client_
>- _Include message length headers if needed_
>
>_Challenges if not handled properly:_
>
>- _Commands could get merged or split incorrectly_
>- _Client might hang waiting for more data_
>- _Buffer overflows from incomplete message boundaries_
>- _Difficulty synchronizing requests with responses_
3. Describe the general differences between stateful and stateless protocols.
_answer here_
>_Stateful protocols maintain information about previous interactions between client and server. The server keeps track of client state across multiple requests. For example, FTP remembers your current directory. Stateless protocols treat each request independently with no memory of previous interactions. Each request must contain all needed information. HTTP is stateless - each request stands alone._
>
>- Stateful requires server memory/resources to track state
>- Stateless is simpler but may need to resend info each time
>- Stateful better for ongoing sessions
>- Stateless better for scalability and reliability
4. Our lecture this week stated that UDP is "unreliable". If that is the case, why would we ever use it?
_answer here_
>_UDP is useful when speed is more important than reliability, like:_
>- Video streaming/gaming where dropping frames is better than lag
>- DNS lookups where retries are fast and cheap
>- Simple network protocols that handle >reliability themselves
>- IoT devices that need minimal overhead
>The lack of handshakes and acknowledgements makes UDP much faster than TCP when 100% reliability isn't required.
5. What interface/abstraction is provided by the operating system to enable applications to use network communications?
_answer here_
\ No newline at end of file
>The operating system provides sockets as the main interface for network communication. Sockets abstract away the low-level networking details and provide a file descriptor-like API that applications can use to:
>
>- Create network connections (socket())
>- Connect to servers (connect())
>- Send/receive data (send()/recv())
>- Close connections (close())
>
>This lets applications focus on their logic rather than networking implementation details.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment