JMU
Sample Questions for the Final Exam


  1. Answer the Sample Questions for Exam 1.
  2. Answer the Sample Questions for Exam 2.
  3. Choose the best answer to each of the following:
    (1) _____ A traditional string telephone allows for which kind of communication?
    1. Simplex
    2. Half Duplex
    3. Full Duplex
    4. Quadraplex
    (2) _____ The Domain Name System (DNS) makes use of:
    1. Authoritative Name Servers
    2. Root Name Servers
    3. Caching Name Servers
    4. All of the above
    5. None of the above
  4. Is a CS361 lecture synchronous or asynchronous? Does it use a channel that is simplex, half-duplex, or duplex?
  5. Identify two common switching modes.
  6. At what layer (assuming a 5-layer view) do each of the following typically operate? Explain.
    Ethernet


    IP


    TCP


    DNS


  7. Explain how non-recursive queries (i.e., referrals) are handled in the Domain Name System (DNS).
  8. Explain the difference between connection-oriented and connectionless transport layer protocols. Is this the same as the differene between stream-oriented and message-oriented protocols?
  9. When we discussed TCP we used a state diagram. When we discussed UDP we didn't. Why?
  10. Explain why, in TCP, the client must acknowledge the SYNACK (also known as the ACKofSYN) sent by the server.
  11. Convert the IP address 198.58.104.19 to binary. How can you use the binary representation to determine that this is a class C address?
  12. Explain why IP fragmentation tends to increase the overall amount of data that is transmitted.
  13. Describe (in detail) the Carrier Sense Multiple Access/Collision Detection (CSMA/CD) process.
  14. Explain why Wi-Fi uses Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA) rather than CSMA/CD. Be specific.
  15. Explain why Wi-Fi uses virtual carrier sensing (rather than direct carrier sensing).
  16. Consider the following fragment.
      int fd;
      ssize_t input_length;
      struct sockaddr_in   destination;
    
      fd = socket(AF_INET, SOCK_DGRAM, 0);
      
      memset(&destination, 0, sizeof(struct sockaddr_in));
      destination.sin_family = AF_INET;
      inet_pton(AF_INET, "134.126.125.234", &(destination.sin_addr));
      destination.sin_port = htons(22801);
      
    1. Does this fragment use UDP or TCP? How do you know?
    2. Is the next system call more likely to be sendto() or recvfrom()? How do you know?
  17. Consider the following fragment.
     
    static void
    *display_wrapper(void *arg)
    {
      char  *s;
      long  result;
    
      s = (char *)arg;
      result = display(s);
      return (void *)result;
    }
      
    1. Is this fragment more likely to be used in a program that uses multiple processes or multiple threads?
    2. What warning/diagnostic message might you receive if you changed the type of result from long to int?
  18. Write an application-layer client that uses TCP at the transport layer to send login information to a server using the following protocol.
    1. The server transmits a prompt (e.g., "ID:") to the client.
    2. The client displays the prompt.
    3. The client reads from standard input.
    4. The client transmits the user's response to the server.
    5. The server transmits a prompt (e.g., "Password:") to the client.
    6. The client displays the prompt.
    7. The client reads from standard input.
    8. The client transmits the user's response to the server.
  19. Write a sequential (i.e., not concurrent) course name server that uses UDP at the transport layer. It must receive a text message of 4 characters (denoting a 3-character CS course number and a terminating '\0' character) and send a message of 81 characters or less back to the client (to the same host and port it received the message from) containing the name of the course (terminated by a '\0' character). If the request does not correspond to an actual course the server must send the message "There is no CS course with that number.". Note: You may hard-code the data required by the server or read them from a file, whichever you prefer.
  20. Write a client that will work with the server from the previous question.
  21. Consider the client-server application in the two questions.
    1. Explain why this application is not reliable.
    2. How might acknowledgements be used to make it reliable.
    3. Why would the acknowledgement scheme need to be complicated if the application-layer protocol used more than two messages (i.e., more than just a request and a response)?
    4. Why would the ackowledgement scheme need to be more complicated if the server could handle multiple requests concurrently?
  22. Consider the following UML state model of the TCP protocol (where TCB stands for "Transmission Control Block" and represents the state information used by the protocol).
    /bernstdh/web/common/lectures/images/statechart_tcp.gif
    1. What system call causes the system to transition from the Closed state to the Listen state? Be spcific.
    2. What system call causes the system to transition from the Closed state to the SYN-Sent state? Be specific.
    3. When does the system transition from the Listen state to the SYN-Received state? Your answer must refer to a specific system call.
  23. Consider the following program.
    static void
    handle_connection(int connection_fd)
    {
      char id[4];
      int i, index, n;
    
      read(connection_fd, id, 3);
      id[3] = '\0';
      
      index = get_index(id);
      if (index < 0)
        {
          write(connection_fd, "No Such Course", 15);
        }
      else
        {
          n = lines[index];
          for (i=0; i<n; i++)
            {
              write(connection_fd, description[index][i], 70);
              write(connection_fd, "\n", 1);
            }
        }
      close(connection_fd);
    }
    
    
    
    int main(void)
    {
      int connection_fd, listening_fd;
      int pid;
      struct sockaddr_in address;
      
      memset(&address, 0, sizeof(address));
      address.sin_family = AF_INET;
      address.sin_port = htons(22801);
      address.sin_addr.s_addr = htonl(INADDR_ANY);
    
      listening_fd = socket(AF_INET, SOCK_STREAM, 0);
      bind(listening_fd, (struct sockaddr *)&address, sizeof(struct sockaddr));
      listen(listening_fd, 0);
    
      while (1)
        {
          connection_fd = accept(listening_fd, NULL, NULL);
          handle_connection(connection_fd);
        }
    
      return 0;
    }  
    
    1. Is this a client or a server (at the application layer)?
    2. Rewrite the above program so that it handles each connection in its own process.
    3. Rewrite the above program so that it handles each connection in its own thread. (Note: You must use a wrapper for the handle_connection() function. That is, you must not change the signature of the handle_connection() function.)

Copyright 2017