% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames*,x11names*,table}{xcolor}
%
\documentclass[
  addpoints, answers]{exam}
\usepackage{lmodern}
\usepackage{setspace}
\setstretch{1.2}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\definecolor{default-linkcolor}{HTML}{A50000}
\definecolor{default-filecolor}{HTML}{A50000}
\definecolor{default-citecolor}{HTML}{4077C0}
\definecolor{default-urlcolor}{HTML}{4077C0}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
  pdftitle={Networking Questions},
  pdfauthor={ECEn 522R},
  hidelinks,
  breaklinks=true,
  pdfcreator={LaTeX via pandoc with the Eisvogel template}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=2.5cm,includehead=true,includefoot=true,centering,]{geometry}
\usepackage{listings}
\newcommand{\passthrough}[1]{#1}
\lstset{defaultdialect=[5.3]Lua}
\lstset{defaultdialect=[x86masm]Assembler}
% add backlinks to footnote references, cf. https://tex.stackexchange.com/questions/302266/make-footnote-clickable-both-ways
\usepackage{footnotebackref}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering

% Make use of float-package and set default placement for figures to H.
% The option H means 'PUT IT HERE' (as  opposed to the standard h option which means 'You may put it here if you like').
\usepackage{float}
\floatplacement{figure}{H}

\usepackage{lastpage}


%%
%% added
%%

%
% language specification
%
% If no language is specified, use English as the default main document language.
%

\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[shorthands=off,main=english]{babel}
\else
    % Workaround for bug in Polyglossia that breaks `\familydefault` when `\setmainlanguage` is used.
  % See https://github.com/Wandmalfarbe/pandoc-latex-template/issues/8
  % See https://github.com/reutenauer/polyglossia/issues/186
  % See https://github.com/reutenauer/polyglossia/issues/127
  \renewcommand*\familydefault{\sfdefault}
    % load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic)
  \usepackage{polyglossia}
  \setmainlanguage[]{english}
\fi


%
% for the background color of the title page
%

%
% break urls
%
\PassOptionsToPackage{hyphens}{url}

%
% When using babel or polyglossia with biblatex, loading csquotes is recommended
% to ensure that quoted texts are typeset according to the rules of your main language.
%
\usepackage{csquotes}

%
% captions
%
\definecolor{caption-color}{HTML}{777777}
\usepackage[font={stretch=1.2}, textfont={color=caption-color}, position=top, skip=4mm, labelfont=bf, singlelinecheck=false, justification=raggedright]{caption}
% \setcapindent{0em}

%
% blockquote
%
\definecolor{blockquote-border}{RGB}{221,221,221}
\definecolor{blockquote-text}{RGB}{119,119,119}
\usepackage{mdframed}
\newmdenv[rightline=false,bottomline=false,topline=false,linewidth=3pt,linecolor=blockquote-border,skipabove=\parskip]{customblockquote}
\renewenvironment{quote}{\begin{customblockquote}\list{}{\rightmargin=0em\leftmargin=0em}%
\item\relax\color{blockquote-text}\ignorespaces}{\unskip\unskip\endlist\end{customblockquote}}

%
% Source Sans Pro as the de­fault font fam­ily
% Source Code Pro for monospace text
%
% 'default' option sets the default
% font family to Source Sans Pro, not \sfdefault.
%
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
    \usepackage[default]{sourcesanspro}
  \usepackage{sourcecodepro}
  \else % if not pdftex
    \usepackage[default]{sourcesanspro}
  \usepackage{sourcecodepro}

  % XeLaTeX specific adjustments for straight quotes: https://tex.stackexchange.com/a/354887
  % This issue is already fixed (see https://github.com/silkeh/latex-sourcecodepro/pull/5) but the
  % fix is still unreleased.
  % TODO: Remove this workaround when the new version of sourcecodepro is released on CTAN.
  \ifxetex
    \makeatletter
    \defaultfontfeatures[\ttfamily]
      { Numbers   = \sourcecodepro@figurestyle,
        Scale     = \SourceCodePro@scale,
        Extension = .otf }
    \setmonofont
      [ UprightFont    = *-\sourcecodepro@regstyle,
        ItalicFont     = *-\sourcecodepro@regstyle It,
        BoldFont       = *-\sourcecodepro@boldstyle,
        BoldItalicFont = *-\sourcecodepro@boldstyle It ]
      {SourceCodePro}
    \makeatother
  \fi
  \fi

%
% heading color
%
\definecolor{heading-color}{RGB}{40,40,40}
% \addtokomafont{section}{\color{heading-color}}
% When using the classes report, scrreprt, book,
% scrbook or memoir, uncomment the following line.
%\addtokomafont{chapter}{\color{heading-color}}

%
% variables for title and author
%
\usepackage{titling}
\setlength{\droptitle}{-10em} % Move title up

%
% tables
%

%
% remove paragraph indention
%
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines

%
%
% Listings
%
%


%
% general listing colors
%
\definecolor{listing-background}{HTML}{F7F7F7}
\definecolor{listing-rule}{HTML}{B3B2B3}
\definecolor{listing-numbers}{HTML}{B3B2B3}
\definecolor{listing-text-color}{HTML}{000000}
\definecolor{listing-keyword}{HTML}{435489}
\definecolor{listing-keyword-2}{HTML}{1284CA} % additional keywords
\definecolor{listing-keyword-3}{HTML}{9137CB} % additional keywords
\definecolor{listing-identifier}{HTML}{435489}
\definecolor{listing-string}{HTML}{00999A}
\definecolor{listing-comment}{HTML}{8E8E8E}

\lstdefinestyle{eisvogel_listing_style}{
  language         = java,
  numbers          = left,
  xleftmargin      = 2.7em,
  framexleftmargin = 2.5em,
  backgroundcolor  = \color{listing-background},
  basicstyle       = \color{listing-text-color}\linespread{1.0}\small\ttfamily{},
  breaklines       = true,
  frame            = single,
  framesep         = 0.19em,
  rulecolor        = \color{listing-rule},
  frameround       = ffff,
  tabsize          = 4,
  numberstyle      = \color{listing-numbers},
  aboveskip        = 1.0em,
  belowskip        = 0.1em,
  abovecaptionskip = 0em,
  belowcaptionskip = 1.0em,
  keywordstyle     = {\color{listing-keyword}\bfseries},
  keywordstyle     = {[2]\color{listing-keyword-2}\bfseries},
  keywordstyle     = {[3]\color{listing-keyword-3}\bfseries\itshape},
  sensitive        = true,
  identifierstyle  = \color{listing-identifier},
  commentstyle     = \color{listing-comment},
  stringstyle      = \color{listing-string},
  showstringspaces = false,
  escapeinside     = {/*@}{@*/}, % Allow LaTeX inside these special comments
  literate         =
  {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
  {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
  {à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
  {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
  {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
  {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
  {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
  {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
  {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
  {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
  {€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
  {»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1
  {…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1
  {”}{{''}}1
}
\lstset{style=eisvogel_listing_style}

%
% Java (Java SE 12, 2019-06-22)
%
\lstdefinelanguage{Java}{
  morekeywords={
    % normal keywords (without data types)
    abstract,assert,break,case,catch,class,continue,default,
    do,else,enum,exports,extends,final,finally,for,if,implements,
    import,instanceof,interface,module,native,new,package,private,
    protected,public,requires,return,static,strictfp,super,switch,
    synchronized,this,throw,throws,transient,try,volatile,while,
    % var is an identifier
    var
  },
  morekeywords={[2] % data types
    % primitive data types
    boolean,byte,char,double,float,int,long,short,
    % String
    String,
    % primitive wrapper types
    Boolean,Byte,Character,Double,Float,Integer,Long,Short
    % number types
    Number,AtomicInteger,AtomicLong,BigDecimal,BigInteger,DoubleAccumulator,DoubleAdder,LongAccumulator,LongAdder,Short,
    % other
    Object,Void,void
  },
  morekeywords={[3] % literals
    % reserved words for literal values
    null,true,false,
  },
  sensitive,
  morecomment  = [l]//,
  morecomment  = [s]{/*}{*/},
  morecomment  = [s]{/**}{*/},
  morestring   = [b]",
  morestring   = [b]',
}

\lstdefinelanguage{XML}{
  morestring      = [b]",
  moredelim       = [s][\bfseries\color{listing-keyword}]{<}{\ },
  moredelim       = [s][\bfseries\color{listing-keyword}]{</}{>},
  moredelim       = [l][\bfseries\color{listing-keyword}]{/>},
  moredelim       = [l][\bfseries\color{listing-keyword}]{>},
  morecomment     = [s]{<?}{?>},
  morecomment     = [s]{<!--}{-->},
  commentstyle    = \color{listing-comment},
  stringstyle     = \color{listing-string},
  identifierstyle = \color{listing-identifier}
}

% Command to create signature line if needed
\newcommand{\nameandsignature} {
\textit{I have read and understand the above examination instructions:} \newline

{\Large
Name: \rule{2.5in}{1pt} \\ \newline
Signature: \rule{2.5in}{1pt}
}
}

% Document information
\title{Networking Questions}
\author{ \\ }
\date{January 31, 2022}


% Header and footer
\lhead{Networking Questions}
\chead[]{}
\rhead{: }
\runningheadrule

\lfoot[]{}
\cfoot{\thepage}
\rfoot[]{}
\footrule


% Define words for score table
\vqword{\textbf{Question}}
\vpgword{\textbf{Page}}
\vpword{\textbf{Points}}
\vsword{\textbf{Score}}
\vtword{\textbf{Total:}}



\renewcommand{\solutiontitle}{\noindent\textbf{Answer:}\par\noindent}

%%
%% end added
%%

\begin{document}

\maketitle

\begin{center}
  \vspace{1cm}
  \multicolumngradetable{1}[questions]
  \vspace{1cm}
\end{center}

{\large \textbf{Name:} [Put name here]}


\newpage


\begin{questions}


\question[3] How does HTTP detect the end of a request? How does IPv4 detect the end of a packet? Why are they different?

\begin{solution}[\stretch{1}]
[Put answer here]
\end{solution}


\newpage


\question[3] Find the end-to-end delay (including the transmission delays and propagation delays on each of the three links, but ignoring queueing delays and processing delays) from when the left host begins transmitting the first bit of a packet to the time when the last bit of that packet is received at the server at the right. The speed of light propagation delay on each link is $3 \times 10^8$ m/s. Note that the transmission rates are in Mbps and the link distances are in Km. Assume a packet length of 4000 bits. Give your answer in milliseconds.
\begin{center}
\includegraphics[width=0.8\textwidth]{/Users/philipbl/Documents/BYU/Classes/ECEn 526 - Winter 2022/homeworks/networking_questions/assets/end-to-end_delay.jpg}
\end{center}

\begin{parts}
      \part Link 1 Delay

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Link 2 Delay

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Link 3 Delay

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Total Delay

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
\end{parts}




\newpage


\question[2] Suppose that the packet length is L = 5 KB, and that the link transmission rate along the link to router on the right is R = 1 Mbps. Assume that 1 KB = 1000 bytes.
\begin{center}
\includegraphics[width=0.5\textwidth]{/Users/philipbl/Documents/BYU/Classes/ECEn 526 - Winter 2022/homeworks/networking_questions/assets/single_link_transmission_time.jpg}
\end{center}

\begin{parts}
      \part What is the transmission delay (the time needed to transmit all of a packet's bits into the link)?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part What is the maximum number of packets per second that can be transmitted by the link?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
\end{parts}




\newpage


\question[3] Consider the scenario shown above, with four different servers connected to four different clients over four three-hop paths. The four pairs share a common middle hop with a transmission capacity of $R$ = 300 Mbps. The four links from the servers to the shared link have a transmission capacity of $R_S$ = 50 Mbps. Each of the four links from the shared middle link to a client has a transmission capacity of $R_C$ = 30 Mbps per second.
\begin{center}
\includegraphics[width=0.5\textwidth]{/Users/philipbl/Documents/BYU/Classes/ECEn 526 - Winter 2022/homeworks/networking_questions/assets/end-to-end_throughput.jpg}
\end{center}

\begin{parts}
      \part What is the maximum achievable end-to-end throughput (in Mbps) for each of four client-to-server pairs, assuming that the middle link is fair-shared (i.e., divides its transmission rate equally among the four pairs)?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Which link is the bottleneck link for each session?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Assuming that the senders are sending at the maximum rate possible, what are the link utilizations for the sender links ($R_S$), client links ($R_C$), and the middle link ($R$)?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
\end{parts}




\newpage


\question[5] Using the following HTTP GET message, answer the following questions:

\begin{verbatim}
GET /526/hw1/answers.txt HTTP/1.1
Host: ecenetworking.byu.edu
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0
\end{verbatim}


\begin{parts}
      \part What is the name of the file that is being retrieved in this GET message?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part What version of HTTP is the client running?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Assuming this request came from a web browser, what was the full URL that was typed into the address bar?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part What browser and operating system did this request come from?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Assuming that the file does not exist, write out the HTTP response? You do not need to include any extra headers.

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
\end{parts}




\newpage


\question[2] What does fairness mean in the context of TCP? What feature of TCP makes it fair? How?

\begin{solution}[\stretch{1}]
[Put answer here]
\end{solution}


\question[1] How does TCP detect duplicate data?

\begin{solution}[\stretch{1}]
[Put answer here]
\end{solution}


\newpage


\question[3] Consider UDP and TCP.

\begin{parts}
      \part List the guarantees UDP provides (hint: there is at least one).

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part List the guarantees of TCP (hint: there is at least four).

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Why would someone use UDP over TCP?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
\end{parts}




\newpage


\question[10] HTTP is a text-based protocol, meaning that data is sent in plain text, rather than binary-encoded data. Design a binary-encoded version of an HTTP request. Look at the TCP and IP packet structures for inspiration. List each field, the size of each field (in bytes or bits), and a brief description of the field. The description should include a justification for the size of the field and any limitations that were introduced. For example, an HTTP request must include a version:

  \begin{table}[H]
  \centering
  \begin{tabular}{|l|l|p{10cm}|}
  \hline
  \textbf{Field Name} & \textbf{Field Size} & \textbf{Field Description} \\ \hline \hline
  Version             & 4 bits              & The HTTP version. 4 bits can represent 16 values. This can represent current versions and most likely all future versions of HTTP. Version 1.0 corresponds to the binary value 0, 1.1 corresponds to the binary value 1, and 2.0 corresponds to the binary value 2. \\ \hline
    ...               & ...                 & ...      \\ \hline
  \end{tabular}
  \end{table}

Your protocol should be able to accommodate variable size file names, variable header values, and variable payloads.


\begin{solution}[\stretch{2}]
[Put answer here]
\end{solution}


\newpage


\question[5] Consider the scenario below in which three hosts, with private IP addresses 10.0.0.13, 10.0.0.2, 10.0.0.20 are in a local network behind a NATed router that sits between these three hosts and the larger Internet. IP datagrams being sent from, or destined to, these three hosts must pass through this NAT router. The router’s interface on the LAN side has IP address 10.0.0.1, while the router’s address on the Internet side has IP address 143.100.122.56. Suppose that the host with IP address 10.0.0.20 sends an IP datagram destined to host 128.119.161.189. The source port is 3451, and the destination port is 80.
\begin{center}
\includegraphics[width=0.8\textwidth]{/Users/philipbl/Documents/BYU/Classes/ECEn 526 - Winter 2022/homeworks/networking_questions/assets/nat.png}
\end{center}

\begin{parts}
      \part Consider the datagram at step 1, after it has been sent by the host but before it has reached the NATted router. What are the source and destination IP addresses for this datagram? What are the source and destination port numbers for the TCP segment in this IP datagram?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Now consider the datagram at step 2, after it has been transmitted by the NATted router. What are the source and destination IP addresses for this datagram? What are the source and destination port numbers for the TCP segment in this IP datagram? Specify the entry that has been made in the router's NAT table.

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Now consider the datagram at step 3, just before it is received by the NATted router. What are the source and destination IP addresses for this datagram? What are the source and destination port numbers for the TCP segment in this IP datagram?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Last, consider the datagram at step 4, after it has been transmitted by the NATted router but before it has been received by the host. What are the source and destination IP address for this datagram? What are the source and destination port numbers for the TCP segment in this IP datagram?

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
\end{parts}




\newpage


\question[2] What are the congestion window (\texttt{cwnd}) and and receive window (\texttt{rwnd}) used for in TCP?

\begin{solution}[\stretch{1}]
[Put answer here]
\end{solution}


\question[3] What are the pros and cons of the following multiple access protocols?

\begin{parts}
      \part Channel Partitioning

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Random Access

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
    \part Taking Turns

    \begin{solution}[\stretch{1}]
        [Put answer here]
        \end{solution}
\end{parts}






\end{questions}

\end{document}