\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage[a4paper, total={6in, 9in}]{geometry}
\usepackage{listings} % For code formatting
\usepackage{xcolor} % For custom colors
\usepackage{graphicx}
\usepackage{fontspec}
\usepackage{subcaption}
\usepackage{wrapfig}
\usepackage{cancel}
\graphicspath{ {./figures/} }
\usepackage{xparse} % Allows advanced command definitions
\newcounter{problemcounter}
\NewDocumentCommand{\problem}{o}{
  \noindent
  \fbox{Problem %
    \IfNoValueTF{#1}
      {\stepcounter{problemcounter}\arabic{problemcounter}} % If no optional arg, use counter
      {#1} % Else, use custom label
  }
}

\setmainfont{UbuntuMono Nerd Font Mono}
% \setmainfont{Iosevka Term}

\title{Computer Networks - Midterm/Final Exam (Example)} % Added a placeholder title
\author{B11605076 Cheng-Ru}
\date{\today}

\begin{document}
\maketitle

\section*{Computer Networks Exam Questions}
\hrule
\vspace{0.5em}

\subsection*{Question 1: "Quickies" (35\%)}
Answer each of the following questions briefly, i.e., in at most a few sentences.

\begin{enumerate}
    \item [(a)] (15\%) What are the major differences between TCP and UDP? Why does DNS use UDP instead of TCP for its service?
    \vspace{2cm}
    \item [(b)] (10\%) According to the course's textbook, how many layers are included in the Internet (give their names too)? Give one example of an application, or protocol, or device, that corresponds to each layer.
    \vspace{2.5cm}
    \item [(c)] (10\%) What is the difference between a recursive query and an iterated query in the DNS?
    \vspace{2cm}
\end{enumerate}

\hrule
\vspace{0.5em}

\subsection*{Question 2: True or False (12\%)}
If your answer is \textbf{False}, please explain your reason.

\begin{enumerate}
    \item [(a)] (3\%) In a circuit switched network, all data belonging to a connection traverses the same route, whereas in a packet switched network, different packets belonging to the same connection may take different routes.
    \vspace{1.5cm}
    \item [(b)] (3\%) With non-persistent connections between browser and origin server, it is possible for a single TCP segment to carry two distinct HTTP request messages.
    \vspace{1.5cm}
    \item [(c)] (3\%) HTTP response messages can have an empty message body.
    \vspace{1.5cm}
    \item [(d)] (3\%) The \texttt{Date:} header in the HTTP response message indicates when the object in the response was last modified.
    \vspace{1.5cm}
\end{enumerate}

\hrule
\vspace{0.5em}

\subsection*{Question 3: P2P System (30\%)}
In BitTorrent, the file is divided into 256Kb chunks.

\begin{enumerate}
    \item [(a)] (10\%) Please explain the reason why BitTorrent chooses the chunk size as 256Kb. That is, you could explain what the pros and cons for the large chunk size (and the small chunk size) are.
    \vspace{2cm}
    \item [(b)] (10\%) What is the free rider problem in BitTorrent? Please explain how BitTorrent addresses the free rider problem.
    \vspace{2cm}
    \item [(c)] (10\%) NTU Computer Center hires you as the p2p expert to reduce its rising bandwidth costs due to the rising use of BitTorrent. How would you address this problem?
    \vspace{2cm}
\end{enumerate}

\hrule
\vspace{0.5em}

\subsection*{Question 4: Video Streaming and CDN (30\%)}

\begin{enumerate}
    \item [(a)] (10\%) What is the major challenge for video streaming over the Internet?
    \vspace{1.5cm}
    \item [(b)] (10\%) Please explain what spatial coding and temporal coding are for video.
    \vspace{2cm}
    \item [(c)] (10\%) Please list four techniques to address the issue of video streaming over the Internet.
    \vspace{2cm}
\end{enumerate}

\hrule
\vspace{0.5em}

\subsection*{Question 5: Socket Programming (10\%)}
This is a socket programming with TCP protocol in C language. Please fill in the...

\begin{figure}[h!]
    \begin{center}
        \includegraphics[width=0.95\textwidth]{q5.png}
    \end{center}
\end{figure}


\end{document}
