\documentclass[a4paper,9pt]{article}

\author{Camil Staps\\\small{s4498062}}
\title{Networking\\\large{Assignment 7}}
\date{May 22, 2016}

\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{geometry}
\usepackage[hidelinks]{hyperref}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{subcaption}
\usepackage{verbatimbox}

\begin{document}

\maketitle

\section{Cyclic Redundancy Checks}
\begin{enumerate}[label=\alph*)]
	\item It computes the remainder of $(D\cdot2^r\oplus R) \div G$, and checks
		that it equals $0$.
	\item See \autoref{fig:longdiv:b}. The answer is \texttt{111}.
	\item See \autoref{fig:longdiv:c}. The answer is \texttt{010}.
	\item See \autoref{fig:longdiv:d}. The answer is \texttt{111}.
\end{enumerate}

\begin{figure}[h]
	\small
	\begin{subfigure}[b]{.32\linewidth}
		\centering
		\begin{verbbox}
			1001010101 000
			1001
			0000010101 000
			     1001
			0000000111 000
			       100 1
			0000000011 100
			        10 01
			0000000001 110
			         1 001
			0000000000 111
		\end{verbbox}
		\theverbbox%
		\caption{\label{fig:longdiv:b}}
	\end{subfigure}
	\begin{subfigure}[b]{.32\linewidth}
		\centering
		\begin{verbbox}
			0101101010 000
			 1001
			0001001010 000
			   1001
			0000000010 000
			        10 01
			0000000000 010
		\end{verbbox}
		\theverbbox%
		\caption{\label{fig:longdiv:c}}
	\end{subfigure}
	\begin{subfigure}[b]{.32\linewidth}
		\centering
		\begin{verbbox}
			1010100000 000
			1001
			0011100000 000
			  1001
			0001110000 000
			   1001
			0000111000 000
			    1001
			0000011100 000
			     1001
			0000001110 000
			      1001
			0000000111 000
			       100 1
			0000000011 100
			        10 01
			0000000001 110
			         1 001
			0000000000 111
		\end{verbbox}
		\theverbbox%
		\caption{\label{fig:longdiv:d}}
	\end{subfigure}
	\caption{Computing CRC using long division\label{fig:longdiv}}
\end{figure}

\section{Address Resolution Protocol}
\begin{enumerate}
	\item We call the left router R and the right router S. Let $R_i$ be the
		interface of router $R$ for subnet $i$. Then:

			A --- 192.168.1.100; B --- 192.168.1.200;\\
			C --- 192.168.2.100; D --- 192.168.2.200;\\
			E --- 192.168.3.100; F --- 192.168.3.200;\\
			R$_1$ --- 192.168.1.1; R$_2$ --- 192.168.2.1;\\
			S$_2$ --- 192.168.2.2; S$_3$ --- 192.168.3.2;\\

	\item
		A --- 00.00.00.00.00.A0; B --- 00.00.00.00.00.B0;\\
		C --- 00.00.00.00.00.C0; D --- 00.00.00.00.00.D0;\\
		E --- 00.00.00.00.00.E0; F --- 00.00.00.00.00.F0;\\
		R$_1$ --- 88.88.88.00.00.00; R$_2$ --- 88.88.88.00.88.00;\\
		S$_2$ --- 88.88.88.88.00.00; S$_3$ --- 88.88.88.88.88.00.

	\item Host E looks up the MAC address of the first hop router (S$_3$), and
		sends the datagram there. Router S receives the datagram, figures out that
		the next hop is router R, looks up the MAC address of R$_2$ and sends the
		datagram there. Router R then forwards the datagram in a frame to host B on
		interface R$_1$. Concretely, the following frames are sent:

		\begin{table}[h]
			\centering
			\begin{tabular}{l | l | l | l}
				Src. IP       & Src. MAC          & Dest. IP      & Dest. MAC \\\hline
				192.168.3.100 & 00.00.00.00.00.E0 & 192.168.3.2   & 88.88.88.88.88.00\\
				192.168.2.2   & 88.88.88.88.88.00 & 192.168.2.1   & 88.88.88.00.88.00\\
				192.168.1.1   & 88.88.88.00.88.00 & 192.168.1.200 & 00.00.00.00.00.B0\\
			\end{tabular}
		\end{table}

	\item The same happens, but before E can send the frame to S$_3$, it has to
		get to know its address. It sends an ARP request to the broadcast address
		with the request for 192.168.3.2's (that is, S$_3$'s) MAC address. The
		router replies with an ARP packet. After this, E has all the addresses it
		needs (and all other nodes as well), so the same as above happens.

		\begin{table}[h]
			\centering
			\begin{tabular}{l | l | l | l | l}
				Src. IP       & Src. MAC          & Dest. IP      & Dest. MAC         & Protocol\\\hline
				192.168.3.100 & 00.00.00.00.00.E0 & 192.168.3.2   & FF.FF.FF.FF.FF.FF & ARP\\
				192.168.3.2   & 88.88.88.88.88.00 & 192.168.3.100 & 00.00.00.00.00.E0 & ARP\\
				192.168.3.100 & 00.00.00.00.00.E0 & 192.168.3.2   & 88.88.88.88.88.00 & IP\\
				192.168.2.2   & 88.88.88.88.88.00 & 192.168.2.1   & 88.88.88.00.88.00 & IP\\
				192.168.1.1   & 88.88.88.00.88.00 & 192.168.1.200 & 00.00.00.00.00.B0 & IP\\
			\end{tabular}
		\end{table}
\end{enumerate}

\section{Self-learning}
\begin{enumerate}[label=(\roman*)]
	\item %todo
	\item %todo
	\item %todo
	\item %todo
\end{enumerate}

\section{All things learned put together}
%todo

\end{document}
