-
Notifications
You must be signed in to change notification settings - Fork 771
Networking: Review Questions
- Wiki w/Interactive MC Questions
- See Coding questions
- See Short answer questions
- See MP Wearables Food For Thought questions
What is a socket?
What is special about listening on port 1000 vs port 2000?
- Port 2000 is twice as slow as port 1000
- Port 2000 is twice as fast as port 1000
- Port 1000 requires root privileges
- Nothing
Describe one significant difference between IPv4 and IPv6
When and why would you use ntohs?
If a host address is 32 bits which IP scheme am I most likely using? 128 bits?
Which common network protocol is packet based and may not successfully deliver the data?
Which common protocol is stream-based and will resend data if packets are lost?
What is the SYN ACK ACK-SYN handshake?
Which one of the following is NOT a feature of TCP?
- Packet re-ordering
- Flow control
- Packet re-tranmission
- Simple error detection
- Encryption
What protocol uses sequence numbers? What is their initial value? And why?
What are the minimum network calls are required to build a TCP server? What is their correct order?
What are the minimum network calls are required to build a TCP client? What is their correct order?
When would you call bind on a TCP client?
What is the purpose of socket bind listen accept ?
Which of the above calls can block, waiting for a new client to connect?
What is DNS? What does it do for you? Which of the CS241 network calls will use it for you?
For getaddrinfo, how do you specify a server socket?
Why may getaddrinfo generate network packets?
Which network call specifies the size of the allowed backlog?
Which network call returns a new file descriptor?
When are passive sockets used?
When is epoll a better choice than select? When is select a better choice than epoll?
Will write(fd, data, 5000)
always send 5000 bytes of data? When can it fail?
How does Network Address Translation (NAT) work?
@MCQ Assuming a network has a 20ms Transmit Time between Client and Server, how much time would it take to establish a TCP Connection? 20 ms 40 ms 100 ms 60 ms @ANS 3 Way Handshake @EXP @END
What are some of the differences between HTTP 1.0 and HTTP 1.1? How many ms will it take to transmit 3 files from server to client if the network has a 20ms transmit time? How does the time taken differ between HTTP 1.0 and HTTP 1.1?
Writing to a network socket may not send all of the bytes and may be interrupted due to a signal. Check the return value of write
to implement write_all
that will repeatedly call write
with any remaining data. If write
returns -1 then immediately return -1 unless the errno
is EINTR
- in which case repeat the last write
attempt. You will need to use pointer arithmetic.
// Returns -1 if write fails (unless EINTR in which case it recalls write
// Repeated calls write until all of the buffer is written.
ssize_t write_all(int fd, const char *buf, size_t nbyte) {
ssize_t nb = write(fd, buf, nbyte);
return nb;
}
Implement a multithreaded TCP server that listens on port 2000. Each thread should read 128 bytes from the client file descriptor and echo it back to the client, before closing the connection and ending the thread.
Implement a UDP server that listens on port 2000. Reserve a buffer of 200 bytes. Listen for an arriving packet. Valid packets are 200 bytes or less and start with four bytes 0x65 0x66 0x67 0x68. Ignore invalid packets. For valid packets add the value of the fifth byte as an unsigned value to a running total and print the total so far. If the running total is greater than 255 then exit.
Legal and Licensing information: Unless otherwise specified, submitted content to the wiki must be original work (including text, java code, and media) and you provide this material under a Creative Commons License. If you are not the copyright holder, please give proper attribution and credit to existing content and ensure that you have license to include the materials.