Computer Science 360 Mid-term Exam Name___________________ 1. Rank the following transmission media from fastest (1) to slowest (3). ____ a. Optical fiber ____ b. Wireless radio ____ c. Wired ethernet 2. A packet being transmitted is said to travel down the protocol stack toward the physical layer. As this occurs: a. headers are removed from the b. existing headers are overwritten packet c. headers are appended to the d. headers are prepended to the end of the packet front of the packet 3. Multibyte addresses and integer values must be specified in a. big endian format b. little endian format (most significant byte first) (LSB first) c. the format used by the source d. the format used by the computer destination computer 4. Which of the following addresses must be specified by the APPLICATION that wishes to send a packet over an IP network (circle all that apply) a. destination MAC address b. destination IP address c. destination transport protocol ID d. destination Port address 5. On success the socket() function returns a. a FILE * pointer b. a small integer c. a SOCK * pointer d. -1 6. To create a UDP socket the SECOND of the three parameters passed to socket() should be: a. SOCK_DGRAM b. AF_INET or PF_INET c. IPPROTO_IP d. SOCK_UDP 7. The bind function is used to a. bind a socket to a remote b. bind a socket to a local port and IP address port and IP address c. bind is used to perform both functions 8. A server using the RPS or TCP protocol a. must bind its socket to its b. must never bind its socket to local IP address its local IP address c. generally should NOT bind its d. generally should ALWAYS bind its socket to its local IP address socket to its local IP address 9. When a UDP (SOCK_DGRAM, IPPROTO_IP) socket is in use, an attempt to connect() the socket a. will fail unless an application b. will fail even if an application on the remote host has bound to on the remote host is bound to the remote port the remote port UNLESS the process bound to the socket is trying to read from it. c. will succeed ONLY if the remote d. can return success even if the host address in the struct remote IP address is not sockaddr_in specifies the IP address presently assigned to ANY host. of a host on the Internet that is presently powered on. 10. Root nameservers will communicate a. only with authorized nameservers b. only with applications running with root (superuser) privileges c. with any program regardless of whether it is an "official" nameserver or its privilege state 11. Before calling gethostbyname() a. a socket MUST be created b. a socket must NOT be created c. it doesn't matter whether or not a socket has been created. 12. An application protocol that uses UDP a. must supply a full and correct b. must supply a UDP header UDP header in the data passed but the UDP layer will by write() or sendto() compute the checksum c. Cannot supply the UDP header as it is fully built by the UDP layer. 13. Suppose a UDP receiver wishes to know the IP address and port of the sender. a. It must use read() b. It must use recvfrom() c. It may use either one. d. There is no way to find out this information! 14. In the design of the udping program which of the following involved the use of two threads: a. the udping server code b. the udping client code c. both used two threads d. neither one used two threads 15. Suppose the following option string is passed to getopt() char *optargs="icps:Sn"; For which set of options are additional arguments expected to be present: a. -i -c -p b. -s c. -ps d. -i -c -n 16. Which best distinguishes the struct timeval and the struct timespec a. timeval is double precision but b. timeval is in seconds and timespec is in seconds and micro-seconds but timespec nano-seconds is double precision c. timeval is in seconds and nano- c. timespec is in seconds and nano- seconds but timespec is in seconds but timeval is in seconds and micro-seconds seconds and micro-seconds 17. Consider a protocol in which a special ACK packet exists but no sequence numbers are actually transmitted. The Sender sends a packet and then waits for an ACK packet or a timeout. If a timeout occurs the sender retransmits the last packet sent. Which best describes this protocol's operation. a. if an ACK is dropped by the b. if a packet is dropped network the previous packet by the network the may be lost forever. receiver will end up with a duplicate copy of the packet c. if an ACK is dropped d. if a packet is dropped by the network the by the network the receiver may end up with packet will not be resent a duplicate copy of a packet and thus lost forever Suppose the sequence number space consists of {0, 1, 2, 3, 4, 5, 6, 7} Suppose a sender sends a burst of 5 packets having sequence numbers {6, 7, 0, 1, 2} using a go-back-n sliding window protocol and the packet with sequence number 1 is lost by the network. Assume NO timeout and re-transmissions have occurred YET. 18. After the receiver receives the packet with sequence number 2, its value of nxtrcv will be: a. 0 b. 1 c. 2 d. 3 19. After the receiver receives the packet with sequence number 2, it will send back an ACK packet having ACK number: a. 0 b. 1 c. 2 d. 3 20. After the sender receives the ACK mentioned in question 2 its value of lstack will be: a. 0 b. 1 c. 2 d. 3 21. Now assume that the sender timeout routine recognizes that an ACK is way overdue. The sender will retransmit packets having what sequence numbers? 22. Suppose a Stop and Wait protocol (in which the sender can send only ONE packet and then must wait for an acknowledgement) is in use. Suppose the round trip delay from the time the packet is sent until the ACK is received is 20msec. Suppose each packet carries 10,000 bits. What is the maximum bit rate that can be obtained on this connection regardless of how fast you make the underlying links. 23. The number of lines of debugging diagnostics per line of real code used by an inexperienced programmer in developing his or her first multithreaded program is closest to: a. one line per function b. one line per every 10 lines of code. c. one line per line of code NOTE: p_m_l() = pthread_mutex_lock() p_m_u() = pthread_mutex_unlock() p_c_w() = pthread_cond_wait() p_c_s() = pthread_cond_signal() 24. Suppose a function needs to wait until the value of "items" is non-zero. For correct operation the function must lock the mutex associated with "items" a. before it tests "items" or b. only before it calls p_c_w() calls p_c_w() c. Its not necessary to lock the mutex at all. 25. Suppose another function is going to increment items and signal the cv. For correct operation the function must lock the mutex associated with "items" a. before it increments "items" or b. only before it calls p_c_s() calls p_c_s() c. Because signaling never causes a thread to block its never necessary to lock mutex at all. 26. Which of the following strategies are correct for the signaler (circle all that are). a. items++; b. p_m_l(&item_mtx); p_m_l(&item_mtx); p_c_s(&item_cv); p_c_s(&item_cv); p_m_u(&item_mtx); p_m_u(&item_mtx); items++; c. p_m_l(&item_mtx); d. p_m_l(&item_mtx); p_c_s(&item_cv); items++; items++; p_c_s(&item_cv); p_m_u(&item_mtx); p_m_u(&item_mtx); 27. The CONNECT packet type carrying only the flag RPH_CONNECT is legal only in which of the following states (circle all that apply) a. RPS_CLOSE b. RPS_LISTEN c. RPS_CONN_PEND d. RPS_CONN_ACK 28. The DATA/ACK packet type carrying only the flag RPH_ACK is legal only in which of the following states (circle all that apply) a. RPS_CLOSE b. RPS_LISTEN c. RPS_CONN_PEND d. RPS_CONN_ACK 29. The CONNECT ACK packet type carrying the flags RPH_CONNECT and RPH_ACK is legal only in which of the following states: a. RPS_CLOSE b. RPS_LISTEN c. RPS_CONN_PEND d. RPS_CONN_ACK 30. In an "infinite" ring buffer which of the following is true: a. nextin >= nextout b. nextin <= nextout c. depending on circumstances d. they are always equal. sometimes nextin > nextout and sometimes nextout > nextin 31. In a producer/consumer problem the producer calls a. ring_get_item() and b. ring_get_slot() and ring_add_item() ring_add_slot() a. ring_get_item() and b. ring_get_slot() and ring_add_slot() ring_add_item() 32. In a producer/consumer problem the consumer calls a. ring_get_item() and b. ring_get_slot() and ring_add_item() ring_add_slot() a. ring_get_item() and b. ring_get_slot() and ring_add_slot() ring_add_item() 33. The ring_add_slot() function must invoke the following pthread calls: (circle all that are true) a. p_m_l() b. p_m_u() c. p_c_w() d. p_c_s() 34. The ring_get_item() function must invoke the following pthread calls: (circle all that are true) a. p_m_l() b. p_m_u() c. p_c_w() d. p_c_s() 35. The seq number carried in a packet will a. increase on packets going from b. increase on packets going from sender to receiver but stay the receiver to sender but stay the same on packets going from same on packets going from receiver to sender sender to receiver c. increase on packets flowing in d. Not change on packets flowing both directions in both directions. 34. Slots in the sender send ring will be returned to the free slot set a. as soon as the packet has been b. during ack processing by the transmitted by the sender thread sender thread. c. during ack processing by the d. during rps_write() calls in the receiver thread main thread. 35. Suppose an ACK packet arrives at the sender with ACK=8,WIN=6 a. How many free slots were there in the receiver's receive ring at the time the packet was sent? b. When the sender receives the ACK suppose nxtsnd=11. How many MORE packets can be sent before the sender must stop and wait for a new ack. For each of the operations described below identify the component of the rps system that carries out the operation. ____ 1. Invoke ring_get_slot() on the a. The rps_write() API function sender ring b. The rps_read() API function ____ 2. Invoke ring_add_slot() on the sender ring c. The rps_sender() thread ____ 3. Invoke ring_get_item() on the d. The rps_receiver() thread sender ring ____ 4. Invoke ring_add_item() on the sender ring. ____ 5. Invoke ring_get_slot() on the receiver ring ____ 6. Invoke ring_add_slot() on the receiver ring ____ 7. Invoke ring_get_item() on the receiver ring ____ 8. Invoke ring_add_item() on the receiver ring. 36. Which of the following should NEVER cause the caller to have to actually wait on a condition variable. a. Invoke ring_get_slot() on the b. Invoke ring_get_slot() on the sender ring receiver ring c. Invoke ring_get_item() on the b. Invoke ring_get_item() on the sender ring receiver ring