 \documentclass[a4paper,12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{graphicx} %BIlder einbinden
\usepackage{amsmath} %erweiterte Mathe-Zeichen
\usepackage{amsfonts} %weitere fonts
\usepackage[utf8]{inputenc} %Umlaute & Co
\usepackage{hyperref} %Links
\usepackage{ifthen} %ifthenelse
\usepackage{enumerate}
\usepackage{stmaryrd}

\usepackage{color}
\usepackage{algpseudocode} %Pseudocode
\usepackage{dsfont} % schöne Zahlenräumezeichen
\usepackage{amssymb, amsthm} %noch stärker erweiterte Mathe-Zeichen
\usepackage{tikz} %TikZ ist kein Zeichenprogramm
\usetikzlibrary{trees,automata,arrows,shapes}
\usepackage{pgfplots}

\pagestyle{empty}


\topmargin-50pt


\newcounter{aufgabe}
\def\tand{&}

\newcommand{\makeTableLine}[2][0]{%
  \setcounter{aufgabe}{1}%
  \whiledo{\value{aufgabe} < #1}%
  {%
    #2\tand\stepcounter{aufgabe}%
  }
}

\newcommand{\aufgTable}[1]{
  \def\spalten{\numexpr #1 + 1 \relax}
  \begin{tabular}{|*{\spalten}{p{1cm}|}}
    \makeTableLine[\spalten]{E\theaufgabe}$\Sigma$~~\\ \hline
    \rule{0pt}{15pt}\makeTableLine[\spalten]{}\\
  \end{tabular}
}

\def\header#1#2#3#4#5#6#7{\pagestyle{empty}
\begin{minipage}[t]{0.47\textwidth}
\begin{flushleft}
{\bf #4}\\
#5
\end{flushleft}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{flushright}
#6 \vspace{0.5cm}\\
%                 Number of Columns    Definition of Columns      second empty line
% \begin{tabular}{|*{5}{C{1cm}|}}\hline A1&A2&A3&A4&$\Sigma$\\\hline&&&&\\\hline\end{tabular}\\\vspace*{0.1cm}
\aufgTable{#7}
\end{flushright}
\end{minipage}
\vspace{1cm}
\begin{center}
{\Large\bf Sheet #1}

{(Hand in #3)}
\end{center}
}



%counts the exercisenumber
\newcounter{n}

%Kommando für Aufgaben
%\Aufgabe{AufgTitel}{Punktezahl}
\newcommand{\Aufgabe}[2]{\stepcounter{n}
    \textbf{Exercise \arabic{n}: #1} (#2 Points)}

\newcommand{\textcorr}[1]{\textcolor{red}{#1}}
\newenvironment{corr}{\color{red}}{\color{black}\newline}
\newcommand{\ok}{\begin{corr}
            $\checkmark$
        \end{corr}}

\newcommand{\enot}[2]{#1 \cdot 10^{#2}}
\newcommand{\kHz}{\mathit{kHz}}
\newcommand{\mHz}{\mathit{mHz}}

\begin{document}
%\header{BlattNr}{Tutor}{Abgabedatum}{Vorlesungsname}{Namen}{Semester}{Anzahl Aufgaben}
\header{10}{}{2016-01-13}{Kommunikationsnetze}{\textit{Jan-Peter Hohloch, 3908712}\\\textit{Jonas Jaszkowic, 3592719}}{WS 15/16}{4}
\vspace{1cm}
\Aufgabe{Token Bucket}{10+10}
\begin{enumerate}
    \item Time $t$ in seconds, bucket contains $C=3$ tokens initially and has bucket capacity $C_{max}=3$. Token rate is 1 token/s.
    \begin{center}
    $
      \begin{array}{c|c|c|c|c}
        t & \text{token added} & C & \text{packet} & \text{in-profile?}\\ \hline
        0   & +0 & 3 & p1 & \checkmark \\
        0.5 & +0 & 2 & p2 & \checkmark \\
        1   & +1 & 2 & p3 & \checkmark \\
        1.5 & +0 & 1 & p4 & \checkmark \\
        2   & +1 & 1 & p5 & \checkmark \\
        2.5 & +0 & 0 & p6 & \color{red}{\lightning} \\
        3   & +1 & 1 & p7 & \checkmark \\
        3.5 & +0 & 0 & p8 & \color{red}{\lightning} \\
        4   & +1 & 1 & p9 & \checkmark
      \end{array}
     $\\\hfill\ok
     \end{center}
    \item Packet p6 is the first which is out-of-profile. This packet is delayed and appended to the waiting queue. Each time a token is added to the bucket, the system tries to send this delayed packet.\\
    Each arriving package is enqueued. By this we get the following times for transmission:\\
    \begin{tabular}
        {c|ccccccccc}
        p & p1 & p2 & p3 &p4 & p5 & p6 & p7 & p8 & p9\\\hline
        t & 0  &0.5 &  1 &1.5&2   & 3 & 4 & 5 & 6
    \end{tabular}\hfill\ok
    \end{enumerate}\pagebreak
\Aufgabe{Wi-Fi - Problems}{5+10+5}
\begin{enumerate}
    \item In a wired network (e.g. Ethernet) the coliision detection is realized by sensing the carrier power and thus listen for another station sending over the same connection. In wireless networks there are no cables, just antennas which cannot simultaneously transmit and receive. The signal of a wireless device at transmission time is so strong that it will cover any other signal. Therefore there is no chance of detecting other signals possibly trying to use this connection. Furthermore it is possible that some stations are hidden (i.e. not in range) for some others, the AP cannot coordinate these participants because it simply does not know who is involved. (Hidden Station Problem) \ok
    \item The \textit{Hidden Station Problem} occurs when a node (here node \textbf{A} is in range (i.e. visible) from a wireless access point but not from other nodes (here node \textbf{C}) communicating with the same AP. When A and B start sending packets to the AP simultaneously, they cannot detect a collision while transmitting because they are out of range for each other. A solution to this problem is \textit{handshaking}: Assuming that B wants to send, it sends a ``ready to send'' (RTS) message to the AP. The AP broadcasts a ``clear to send'' (CTS) message. Both, B and C are hearing this message. C knows that some other station wants to send and refrains from sending. B is now sure that no other station station is transmitting simultanteously and starts sending. Thus, RTS/CTS prevents collision with packets from a hidden station. \ok
    \begin{center}
      \includegraphics[width=\textwidth]{hiddenstation.png}
    \end{center}
    \item The \textit{Exposed Station Problem} occurs when two ``pairs'' of stations want to communicate to each other. Here, S1 wants to send to R1 and S2 wants to send to R2 simultaneously. R1 and R2 are out of range but S1 and S2 are in range of each other. When the transmission of S1 to R1 is active, S2 is prevented from sending because it could interfere with the signal of S1. However, R2 could receive packets from S2 without collision because it is out of range of S1. \footnote{Image from \url{https://en.wikipedia.org/wiki/Exposed_node_problem}} \ok
    \begin{center}
      \begin{figure}[h]
         \includegraphics[width=\textwidth]{exposedstation.png}
         \caption{Exposed Station Problem}
      \end{figure}

    \end{center}
    %TODO: Quellen
\end{enumerate}\pagebreak
\Aufgabe{Wi-Fi - CSMA/CA, RTS/CTS}{10+10+10}
\begin{enumerate}
    \item Time to transmit one packet and receiving the acknowledgement:
    \begin{align*}
      T_1 &= \frac{l_d}{N_d} + \frac{l_a}{N_a} \\
         &= \frac{12000~bit}{11 \cdot 10^{6} ~bit/s} + \frac{112~bit}{1 \cdot 10^{6} ~bit/s} \\
         &= \frac{12}{11} \cdot 10^{-3}s + 0.112 \cdot 10^{-3}s \\
         &= 1.203 ms
    \end{align*}
    \includegraphics[width=.5\textwidth]{31.png}\\
    The maximum throughput $D_1$ in $bit/s$ is therefore:
    \begin{align*}
      D_1 = (1 / 1.203 ms) * (12000~bit + 112~bit) = 10.07 \cdot 10^{6} bit/s
    \end{align*} \ok
    \item Time to transmit one packet and receiving the acknowledgement:
    \begin{align*}
      T_2 &= t_{difs} + \frac{\sum_{X=0}^{31}X \cdot t_{slot}}{32} + t_{sifs} + T_1 \\
          &= 50 \mu s + 310 \mu s + 10 \mu s + 1203 \mu s \\
          &= 1573 \mu s \\
          &= 1.573 ms
    \end{align*}
    \includegraphics[width=.5\textwidth]{32.png}\\
    The average throughput $D_2$ in $bit/s$ is therefore:
    \begin{align*}
      D_2 = (1 / 1.573 ms) * (12000 + 112 bit) = 7.70 \cdot 10^{6} bit/s
    \end{align*}\ok
    \item Time to transmit one packet and receiving the acknowledgement:
    \begin{align*}
      T_3 &=  \frac{l_{rts}}{N_a} + \frac{l_{cts}}{N_a} + t_{sifs} + t_{sifs} + T_2 \\
          &= 160 \mu s + 112 \mu s + 20 \mu s + 1573 \mu s\\
          &= 292 \mu s + 1573 \mu s \\
          &= 1.865 ms
    \end{align*}
    \includegraphics[width=.5\textwidth]{33.png}\\
     The maximum throughput $D_3$ in $bit/s$ is therefore:
     \begin{align*}
       D_3 = (1 / 1.865 ms) * (12000 + 112 + 160 + 112) = 6.640 \cdot 10^{6} bit/s
     \end{align*}\ok
\end{enumerate}\pagebreak
\Aufgabe{Broadband Internet Access}{3+3+3+3+3+3+3+3+3+3}
\begin{enumerate}
    \item For DSL there is a \emph{splitter} for splitting Voice from Data and an \textit{ADSL modem} modulates and demodulates the data using DMT and creates downstream and upstream channels.\\
    For cable we need a \emph{cable modem}.\ok
    \item A \textit{DSL access multiplier} in combination with a \emph{splitter} does the same at the ISP side.\\
    For cable it is the \emph{Head end} \begin{corr}
        DSLAM / CMTS
    \end{corr}
    \item The range for ADSL is up to $\sim 5km$ (bandwidth decreasing). For DOCSIS (cable) the range is up to $\sim 170 km$ (good bandwidth for higher ranges but also decreasing).\ok
    \item The IP is assigned via PPP by the BRAS and Router.\\
    For cable the CMTS provides the IP via DHCP.\ok
    \item ADSL uses $26 - 108 \kHz$ for upstream and $138 - 1104 \kHz$ for downstream (values from lecture). With Annex B it is upstream: $138 -276 kHz$, downstream: $276-1104 / - 2208$ \footnote{according to \url{https://en.wikipedia.org/wiki/G.992.3\#/media/File:ADSL_annex_overview.svg}}\\ Cable uses $5 - 42 MHz$ for upstream, $54 - 450 MHz$ for video and $550 - 750 MHz$ for downstream. \begin{corr}
        prbly $\checkmark$
    \end{corr}
    \item Both (cable and DSL) are built hierarchically, on higher levels shaded media are used (e.g. common coaxial cable for neighbourhood for cable) \begin{corr}
        other explanation, but should be right
    \end{corr}
    \item Capacity sharing is realized with \textit{frequency division multiplexing (FDM)} (DSL) and with \textit{statistical time division multiplexing} (cable).\ok
    \item For DSL yes, the signal is demultiplexed before it reaches the consumer.\\
    For cable no, the cable modem receives all encrypted data broadcasted by the CMTS. The CM however only extract the data from the cable which is addressed to itself.\ok
    \item Multiple CM fight for a minislot, CMTS assigns these minislots to the competing CMs. The CMs uses the assigned minislot for data transmission to the CMTS.\\
    In DSL the data are just multiplexed (FDM).\ok
    \item The cable modem on the customer premise is configured and controlled by the CMTS using DOCSIS and layer 1 and 2 protocols.\\
    For DSL the BRAS is the corresponding instance.\ok
\end{enumerate}
\end{document}
