\documentclass[svv,addpoints]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[swedish,english]{babel}
\usepackage[hyphens]{url}
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage[backend=biber]{biblatex}
\usepackage[babel=true]{csquotes}
\usepackage[today,nofancy]{svninfo}
\usepackage{prettyref,varioref}
\usepackage{booktabs}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ragged2e}
\usepackage{siunitx}
\usepackage{nameref}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{wasysym}
\usepackage[parskip,prettyref,varioref]{miunmisc}
\addbibresource{literature.bib}
%\addbibresource{rfc.bib}

\newcommand{\Rom}[1]{\MakeUppercase{\romannumeral #1}}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\sisetup{per-mode = symbol}

\title{DT222A and DT098A\\
      Advanced Networking Concepts\\
      Laboratory assignment \Rom{1} \& \Rom{2}
}
\author{Lennart Franked\footnote{%
  E-post: \href{mailto:lennart.franked@miun.se}{lennart.franked@miun.se}.
}
}
\date{\today}

%\setlength{\parindent}{0pt}
\numberwithin{equation}{subsection}

\begin{document}
\maketitle

%\printanswers

\tableofcontents

\section*{Goals}

\input{L2_goals.tex}

\section*{Aims}
\input{L2_aims.tex}

\section*{Reading assignment}
\input{L2_read.tex}

\section{Introduction}
This laboratory assignment is split into two parts. The first part covers
IP subnetting, and in the second part, you will setup and configure a
network running static- and dynamic routing. 

You will work in groups of maximum four students for this assignment.

\section{Assignment}\label{sec:assignment}
This lab is divided into subsections, and each subsection contains a set of
instructions followed by a set of item that must be answered. Always
motivate your answers, add references when necessary and show your calculations.

\subsection{Laboratory Session 1: Subnetting}\label{subsubsec:iprangegroup}
During this first session you will in start by calculating your groups
IP-address range. Next you will subnet this network, according to a given
topology. Finally you will allocate the subnets to the different networks shown
in the topology~\prettyref{fig:topology}.

\subsubsection{Create the IP-address range}
The first thing needed is a IP-addressing range to use in our network.
Since this assignment is done in a laboratory setting, we don't have to comply
to the RFC1918\cite{rfc1918} standards of private IP-addressing. 

An IP address is written in the form shown in \prettyref{eq:ipaddress}.

\begin{equation}\label{eq:ipaddress}
  \underbrace{x}_{grp1}.\underbrace{x}_{grp2}.\underbrace{x}_{grp3}.
  \underbrace{x}_{grp4} \text{ where } \{ x \in \mathbb{Z} \mid 0 \leq x \leq
  255 \} 
\end{equation}

We need however to take into consideration that the address range of 224.0.0.0/3
have been reserved, for amongst other thing multicast, and localhost. Because of this,  we will need
to use another modulus-value on the first octet when we are generating a usable ip-address range.

Start by creating your groups unique IP-address range using \prettyref{eq:grpip}
\begin{equation}\label{eq:grpip}
  \underbrace{x}_{grp1}.\underbrace{y}_{grp2}.\underbrace{y}_{grp3}.
  \underbrace{y}_{grp4} \text{ where } \{ x,y \in \mathbb{Z} \mid 0 \leq x \leq
  223, 0 \leq y \leq 255 \} 
\end{equation}

Where each octet will be based on each group members birthday. Value X is
calculated according to \prettyref{eq:birthdayX}, and value Y is calculated
according to \prettyref{eq:birthdayY}.

\begin{equation}\label{eq:birthdayX}
  YY*MM+DD \mod{223}
\end{equation}

\begin{equation}\label{eq:birthdayY}
  YY*MM+DD \mod{255}
\end{equation}. 

The fourth group in the IP-address should be set to 0.
Finally we will start with a subnet mask of /20, and you will end up with an
address range that looks like \prettyref{eq:subnet}

\begin{equation}\label{eq:subnet}
\underbrace{x}_{grp1}.\underbrace{y}_{grp2}.\underbrace{y}_{grp3}.
  \underbrace{0}_{grp4}/20
\end{equation}

Before continue to the next part, answer the following item:
\begin{itemize}
  \item What is the network-ID of your groups subnet?
  \item What is the broadcast address of your groups subnet?
  \item How many hosts in total can this subnet hold?
\end{itemize}

\subsubsection{Planning your network}\label{subsec:planning}

\begin{figure}[h!]
  \includegraphics[width=\textwidth]{pictures/topology.png}
  \caption{Lab topology}\label{fig:topology}
  %The figure shows four routers connected with serial cable in a 'circular
  %topology'.The routers have been named RT-A, RT-B, RT-C and RT-D. RT-A also
  %have a loopback connection that simulates the connection to the internet.
  %Each router also have an ethernet network connected to it. an  Connection
  %between the routers are as follows:
  %RT-A -> RT-C -> RT-D -> RT-B -> RT-A.  
  %The figure also shows each routers different interfaces, along with how many
  %hosts each network connected to that interface should hold. Also what serial
  %interface should be the DCE (data communication equipment) and which serial
  %interface should be the DTE (data terminating equipment). This information
  %is also given in the interface tables for each router that is presented
  %next.
\end{figure}


With the help of \prettyref{tab:RT-A_Interfacetable},
\prettyref{tab:RT-B_Interfacetable}, \prettyref{tab:RT-C_Interfacetable},
\prettyref{tab:RT-D_Interfacetable} and \prettyref{fig:topology} create suitable
subnets from the subnet that was given to you in \prettyref{subsubsec:iprangegroup}.

\emph{NOTE:\@ It is possible to allocate more than one subnet per interface.}

Questions regarding subsection: \prettyref{subsec:planning}\\

\begin{itemize}
\item Create a table for each of the eight networks that contains the
network-ID and subnet mask for the subnet/subnets in that network.
\item Fill the `IP-address' and `Subnet mask' in the interface tables and
give each interface an IP-address based upon your addressing scheme. In the
case you might need several subnets, give the corresponding interface an
IP-address from both subnets.
\end{itemize}

%Router A Interface table
\begin{table}[p]
  \caption{Interface table for RT-A}\label{tab:RT-A_Interfacetable}
  \hspace{-3cm}
  \renewcommand{\arraystretch}{1.5} % Default value: 1
  \begin{tabularx}{1.6\textwidth}{l l l l l l X}
    \textbf{RT-A Interface} & IP-Address & Subnet mask & DCE/DTE & Bandwidth & \# Hosts & Description\\
    \toprule
    Serial 0/0/0 & & & DCE & \num{256} \unit{\kilo\bit\per\second} & 2 & Link to RT-C interface S0/0/1\\
    \midrule
    Serial 0/0/1 & & & DTE & 128 \unit{\kilo\bit\per\second} & 2 & Link to RT-B interface S0/0/1\\
    \midrule
    FastEthernet 0/0 & & & & 100 \unit{\mega\bit\per\second} & 2100 & Link to RT-A Ethernet network\\
    \midrule
    Loopback 0 & & & & 100 \unit{\mega\bit\per\second} & & WAN-connection using address \newline 200.169.248.12/24\\
    \bottomrule
  \end{tabularx}
\end{table}

%Router B Interface table
\begin{table}[p]
  \caption{Interface table for RT-B}\label{tab:RT-B_Interfacetable}
  \renewcommand{\arraystretch}{1.5} % Default value: 1
  \hspace{-3cm}
  \begin{tabular}{l l l l l l l}
    \textbf{RT-B Interface} & IP-Address & Subnet mask & DCE/DTE & Bandwidth & \# Hosts & Description\\
    \toprule
    Serial 0/0/0 & & & DCE & 64 \unit{\kilo\bit\per\second} & 2 & Link to RT-D interface S0/0/0\\
    \midrule
    Serial 0/0/1 & & & DCE & 128 \unit{\kilo\bit\per\second}  & 2 & Link to RT-A interface S0/0/1\\
    \midrule
    FastEthernet 0/0 & & & & 100 \unit{\mega\bit\per\second} & 1000 & Link to RT-B Ethernet network\\
    \bottomrule
  \end{tabular}
\end{table}

%Router C Interface table
\begin{table}[p]
  \caption{Interface table for RT-C}\label{tab:RT-C_Interfacetable}
  \renewcommand{\arraystretch}{1.5} % Default value: 1
  \hspace{-3cm}
  \begin{tabular}{l l l l l l l}
    \textbf{RT-C Interface} & IP-Address & Subnet mask & DCE/DTE & Bandwidth & \# Hosts & Description\\
    \toprule
    Serial 0/0/0 & & & DTE & 128 \unit{\kilo\bit\per\second} & 2 & Link to RT-D interface S0/0/1\\
    \midrule
    Serial 0/0/1 & & & DTE & 256 \unit{\kilo\bit\per\second} & 2 & Link to RT-A interface S0/0/0\\
    \midrule
    FastEthernet 0/0 & & & & 100 \unit{\mega\bit\per\second} & 300 & Link to RT-C Ethernet network\\
    \bottomrule
  \end{tabular}
\end{table}

%Router D Interface table
\begin{table}[p]
  \caption{Interface table for RT-D}\label{tab:RT-D_Interfacetable}
  \renewcommand{\arraystretch}{1.5} % Default value: 1
  \hspace{-3cm}
  \begin{tabular}{l l l l l l l}
    \textbf{RT-D Interface} & IP-Address & Subnet mask & DCE/DTE & Bandwidth & \# Hosts & Description\\
    \toprule
    Serial 0/0/0 & & & DTE & 64 \unit{\kilo\bit\per\second} & 2 & Link to RT-B interface S0/0/0\\
    \midrule
    Serial 0/0/1 & & & DCE & 128 \unit{\kilo\bit\per\second} & 2 & Link to RT-C interface S0/0/0\\
    \midrule
    FastEthernet 0/0 & & & & 100 \unit{\mega\bit\per\second} & 600 & Link to RT-D Ethernet network\\
    \bottomrule
  \end{tabular}
\end{table}



\newpage
\subsection{Laboratory Session 2: Building the network}\label{subsec:base}
In this session we will now create the network shown in
\prettyref{fig:topology}.

The teacher will give you an introduction to the network lab in the beginning of
the session, and assign each group with the necessary equipment.

Once you have been assigned the equipment, start by connecting the routers
according to the topology. \emph{Make sure that you are connecting the correct
interfaces togheter}. Otherwise you will encounter alot of problems further down
the road.

For each router make sure that you have configured the following:
\begin{itemize}
  \item Hostname
  \item Run the following commands in the Router Configuration Mode:
    \begin{itemize}
      \item \texttt{Router(config)\# line console 0}
      \item \texttt{Router(config-line)\# logging synchronous} \% prevents log
        messages to interrupt the command line input.
      \item \texttt{Router(config-line)\# exit}
      \item \texttt{Router(config)\# no ip domain-lookup} \% Prevents
        DNS-lookups that will lock the console for a short time.
    \end{itemize}
  \item Interfaces
    \begin{itemize}
      \item Set the IP address according to the ip-address plan you made in the
        previous laboratory session.
      \item For the DCE serial interfaces, set the clock rate to reflect the
        speed of the serial link between the routers.
      \item When you create a sub-interface you need to enable the ``host
        interface'', and for each sub-interface you must change so that the
        router will use IEEE 802.1Q standard for VLAN-tagging.
        See~\prettyref{tab:conf_intf}
    \end{itemize}
\end{itemize}

Once you have configured the interfaces, issue a \texttt{ping} between
neighbouring routers to ensure connectivity.

Save the running configuration to a file named \texttt{L3\_basic\_conf.txt} on
your computer, using the instructions given in~\prettyref{subsec:backup}.  

\subsubsection{Setting up static routing}\label{subsec:static}
You now have a base network set-up, however you should only be able to ping
between neighbouring routers. In order for the routers to be able to reach
beyond their neighbors, we will configure a couple of static routes,
see~\prettyref{tab:conf_routing}.

\begin{itemize}
  \item Router A
    \begin{itemize}
      \item Create static routes so that Router A can reach all the subnets on 
        routers B - D, including the links between Router D --- C and Router D --- B.
      \item Configure a default route out towards Loopback0.
    \end{itemize}
  \item Router B and C
    \begin{itemize}
      \item Create static routes so that Router B and C can reach all subnets on 
        Router D.
      \item Set a default route towards Router A.
    \end{itemize}
  \item Router D
    \begin{itemize}
      \item Set a default route towards router A through both Routers B and C.
    \end{itemize}
\end{itemize}

Once you have configured static routes, check that everything works by issuing
\texttt{pings} to all the router interfaces.

Save your running config to a file named \texttt{L3\_static\_routing.txt},
see~\prettyref{subsec:backup}.

Questions regarding subsection: \nameref{subsec:static}
\begin{itemize}
  \item In your report, list all the static routes you configured along with
  a short explanation.
  \item Issue multiple \texttt{pings} from RT-D to the loopback on RT-A,
  which path will the ICMP-packet take and why?
  \item With the help of modifying the cost of the static routers, force the
  ping packets to always travel through router C when trying to reach loopback
  on RT-A from RT-D. How did you achieve this?  
\end{itemize}

\subsubsection{Setting up dynamic routing}\label{subsec:dynamic}
Restart the routers so that they are empty from configurations, and load your
base config according to the instructions given in~\prettyref{subsec:restore}

Static routing works fine in small networks like this, however networks are
seldom small and it can quickly become very cumbersome to maintain static routes
over larger network. Therefore you will now configure OSPF in this network.

Before you start configuring OSPF though, you must calculate the cost of each of
the links. The bandwidth of the links can be found in \prettyref{fig:topology}
and in each routers interface table.\@ cOSPF (which is Cisco's implementation of
OSPF) use the following formula for calculating the cost of a link:

\begin{equation}
  \label{eq:ospf}
  \text{cost} = \num{100000000} / \text{bandwidth (bps)} 
\end{equation}

Questions regarding subsection: \nameref{subsec:dynamic} part 1.
\begin{itemize}
  \item Draw up the topology and write the cost on each link according
   \prettyref{eq:ospf}.
   \item\label{item:calculation} Each group member will now select one of
   the four routers, and from this router calculate the shortest path to all the
   sub-networks using Dijkstra's algorithm. What are the costs to reach the
   different networks?
\end{itemize}

Next step is now to configure OSPF routing in the topology,
see~\prettyref{tab:conf_routing} for how to make the configurations.

For each router, make sure that the following configuration guidelines are
followed.
\begin{itemize}
  \item Use OSPF area 0 for all the networks.
  \item Use the \texttt{bandwidth} command on all the interfaces to ensure that
    OSPF are using the correct bandwidth in its calculations.
\end{itemize}

Finally, save your configuration as \texttt{L3\_ospf\_conf.txt}

Questions regarding subsection: \nameref{subsec:dynamic} part 2.
\begin{itemize}
  \item Issue the command \texttt{show ip route} and look at the metric OPSF
  use for all the networks in the routing table. Are the metrics the same as the
  metrics you calculated in item \prettyref{item:calculation}?
  \item Issue the \texttt{ping} command from RT-D to the loopback on RT-A.
  Which path does the ICMP-packet take to reach RT-A loopback?
  \item Modify the OSPF-metric so that it prefers to send packages
  though RT-B instead of RT-C when sending packages from RT-D to RT-A.
  Show how you achieved this.
  \item Which group member was doing the configuration for this part?
\end{itemize}

\section{Examination}
Hand in your laboratory report in PDF-format, together with all the
configuration files in the submission box for `laboratory assignment 1 \& 2'. 
\emph{Remember to add the names of all the group members in the report.}
\printbibliography
\newpage

\section*{Router Configuration Cheat Sheet}
\begin{table}[h!]
  \hspace{-2cm}
  \begin{tabularx}{1.3\textwidth}{L X}
    \large{\textbf{Basic IOS}}&\\
    \textbf{Command} & \textbf{Description}\\
    \toprule
    \texttt{Router> enable}\newline
    \texttt{Router\#} & Enables privileged commands\\
    \midrule
    \texttt{Router\# configure terminal}\newline
    \texttt{Router(config)\#} & Enters configuration mode\\
    \midrule
    \texttt{Router(config)\# exit} & Leaves current mode (configuration,
    priviliged, interface\dots) \\
    \midrule
    \texttt{Router(config)\#~?} & Shows available commands with description\newline
                                 Can be used on partially entered commands as
                                 well\\
    \midrule
    \texttt{Router\# ena<tab>}\newline
    \texttt{Router\# enable}   & Tab completion, by pressing tab on a started
    command, if the command exist, it will auto-complete.\\
    \midrule
    \texttt{Router(config)\# no <command>} e.g \newline
    \texttt{Router(config-if)\# ip address 129.0.0.1 255.255.255.0}\newline
    \texttt{Router(config-if)\# no ip address 129.0.0.1 255.255.255.0}\newline
    \texttt{Router(config-if)\# ip address 192.0.0.1 255.255.255.0} & Removes
      the command <command> written in the same place as the original command.\\
    \midrule
    \texttt{Router(config)\# hostname MyRouter}\\
    \texttt{MyRouter(config)\# } & Changes the hostname to `MyRouter' (MyRouter
    is of course just a placeholder for whatever name you want to give your
    router)\\
    \bottomrule
  \end{tabularx}
  \end{table}
  \begin{table}[h!]\label{tab:conf_intf}
  \hspace{-2cm}
  \begin{tabularx}{1.3\textwidth}{L X}
    \large{\textbf{Configuring Interfaces}}& \\
    \textbf{Command} & \textbf{Description}\\
    \toprule
    \texttt{Router(config)\#interface <interface>}\newline
    \texttt{Router(config-if)\#} & Enters a specific interface for
                                   configuration\newline
                                   <interface>: Name of the interface, eg serial
                                   0/0/0, fastethernet 0/0, loopback0\dots\\
    \midrule
    \texttt{Router(config-if)\# ip address 10.9.0.7 255.255.255.0} & Sets the IP
    address on the selected interface to 10.9.0.7/24\\
    \midrule
    \texttt{Router(config-if)\# no shutdown} & Enables the interface (interfaces
    are by default turned off)\\
    \midrule
    \texttt{Router(config)\# interface serial 0/0/0}\newline
    \texttt{Router(config-if)\# clock rate 64000} & Sets the clock rate on a
    serial interface to 64000 bps\\
    \midrule
    \texttt{Router(config-if)\# bandwidth 64} & Sets the bandwidth value (the
    value that routing protocols use for metric calculation) to 64 000 bps\\
    \midrule
    \texttt{Router(config)\# interface fastethernet 0/0}\newline
    \texttt{Router(config-if)\# no shutdown}\newline
    \texttt{Router(config-if)\# exit}\newline
    \texttt{Router(config)\# interface fastethernet 0/0.1}\newline
    \texttt{Router(config-subif)\# }\newline & Creates a logical subinterface, used when
    multiple subnets needs to be given on same physical interface.\\
    \texttt{Router(config-subif)\# encapsulation dot1q 1 } & Sets the VLAN-id of
    the subinterface to 1 (VLAN-ID Must be unique for each subinterface)\newline
    \emph{If subinterfaces are used, the IP address for each subinterface is added
    here.}\\ 
    \bottomrule
    \bottomrule
  \end{tabularx}
\end{table}
\begin{table}[h!]\label{tab:conf_routing}
  \hspace{-2cm}
  \begin{tabularx}{1.3\textwidth}{L X}
    \large{\textbf{Configuring Routing}}& \\
    \textbf{Command} & \textbf{Description}\\
    \toprule
    \texttt{Router(config)\#}{ip route <network-id> <mask> <next-hop> <cost> } &
    Configures a static route\newline
    <network-id>: The Destination network to reach\newline
    <mask>: The subnet mask to use for the static route \newline
    <net-hop>: The ip-address to the next hop router\newline
    <cost>: (Optional) Change the cost for this route\\
    \midrule
    \texttt{Router(config)\# router ospf <process id>}\newline
    \texttt{Router(config-router)\# } & Enables OSPF Routing\newline
                                        <process id>: Sets the process id of the
                                        OSPF process. Allows multiple OSPF
                                        instances to be run. Common usage is
                                        area ID.\\
    \midrule
    \texttt{Router(config-router)\#}{network <network-id> <wildcard> area
    <area-id>} & In OSPF configuration mode. Sets what interface(s) that should
    be enabled for OSPF.\newline
    <network-id>: The network-id of the subnet that the interface(s) belongs
    to.\newline
    <wildcard>: Inverted subnet mask eg. $255.255.255.0 \rightarrow 0.0.0.255$\newline
    <area-id>: Which OSPF area that the interface should belong to (use area
    0)\\
    \end{tabularx}
  \end{table}
  \begin{table}[h!]
    \hspace{-2cm}
    \begin{tabularx}{1.3\textwidth}{L X}
    \large{\textbf{Tools for troubleshooting}}& \\
    \textbf{Command} & \textbf{Description}\\
    \toprule
    \texttt{Router\# ping <dest. ip>} & Ping\\
    \midrule
    \texttt{Router\# ping}\newline
    \texttt{Protocol [ip]:}\newline
    \texttt{Target IP address: <dest. ip>}\newline
    \texttt{\dots}\newline
    \texttt{Extended commands [n]: yes}\newline
    \texttt{Source address or interface: <source address or interface>}\newline
    \texttt{\dots} & Extended Ping\newline Allows to choose which
    interface\newline to be used as the source interface\newline when performing a ping operation.\\
    \midrule
    \texttt{Router\# traceroute <destination ip>} & Performs a traceroute\\
    \midrule
    \texttt{Router\# show running-config} & Shows the full configuration of the
    router.\\
    \midrule
    \texttt{Router\# show ip interface brief} & Lists all the interfaces and
    their status (up/down, address etc.)\\
    \midrule
    \texttt{Router\# show ip route} & Displays the current routing table.\\
    \midrule
    \texttt{Router\# show ip ospf <process-id>} & Shows the OSPF settings\\
    \midrule
    \texttt{Router\# show ip ospf interface} & Shows OSPF-related interface
    configurations.\\
    \midrule
    \texttt{Router\# show ip ospf neighbor} & Shows OSPF neighbor information
    (used to verify that two router have established a OSPF-adjecency.)\\
    \midrule
    \texttt{Router\# show ip ospf <process-id> database} & Displays the OSPF
    database\\
    \bottomrule
    \end{tabularx}
  \end{table}

  \subsection*{Backing up Router Configurations}\label{subsec:backup}
  \begin{enumerate}
    \item In teraterm go to \texttt{file} -> \texttt{log}
    \item Select where you want the configuration to be save.
    \item In the routers privileged mode run \texttt{show running-config}
    \item Press \texttt{space} until you get the prompt again.
    \item Close the log in teraterm.
  \end{enumerate}

  \subsection*{Restoring a Router from a Backup}\label{subsec:restore}
  \begin{enumerate}
    \item In the router go to the global configuration mode
      \texttt{Router(config)\#} 
    \item In Teraterm, go to \texttt{File} -> \texttt{Send}
    \item Select your \texttt{L3\_basic\_conf.txt}
    \item Your router have now been reconfigured with your basic configuration.
  \end{enumerate}


\end{document}
