 \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{Jonas Jaszkowic, 3592719}\\\textit{Jan-Peter Hohloch, 3908712}}{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}
     $
     \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. Simultaneously incoming packets which are not in the queue are preferred. At time $t=3$ the buckets content is $C=1$ and packet p7 is arriving, consuming the last token. Therefore, the packets in the queue have to wait again. At $t=3.5$ the buckets content is $C=0$, the arriving packet p8 is delayed and appended to the waiting queue. At time $t=4$, the bucket contains again $C=1$, this last token is consumed by incoming packet p9. Thus, the queue does not change.% At time $t=4.5$ no new packet is incoming, since no token is added, $C=0$ stays the same.
    At time $t=5$ the bucket contains is $C=1$. No new packet is incoming, therefore the delayed packet p6 can finally be sent consuming the token.
    % At time $t=5.5$, to token is added and no packet is incoming, $C=0$ stays the same.
    At time $t=6$ the bucket contains is $C=1$, since no packet is incoming, the delayed packet p8 can finally be sent consuming the last token.\\
    %TODO: aren't packages in queue sent first?
    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   & 5 & 3 & 6 & 4
    \end{tabular}
\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)
    \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.
    \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.
    \begin{center}
      \includegraphics[width=\textwidth]{exposedstation.png}
    \end{center}
\end{enumerate}
\Aufgabe{Wi-Fi - CSMA/CA, RTS/CTS}{10+10+10}
\begin{enumerate}
    \item Time to transmit one packet and receiving the acknowledgment:
    \begin{align*}
      T_1 &= \frac{l_d}{N_d} + \frac{l_a}{N_a} \\
         &= \frac{12000~bit}{11 \cdot 10^{6} ~Mbit/s} + \frac{112~bit}{1 \cdot 10^{6} ~Mbit/s} \\
         &= \frac{12}{11} \cdot 10^{-3} + 0.112 \cdot 10^{-3} \\
         &= 1.203 ms
    \end{align*}
    The maximum throuput $D_1$ in $bit/s$ is therefore:
    \begin{align*}
      D_1 = (1000 ms / 1.203 ms) * (12000 + 112 bit) = 10.07 \cdot 10^{6} bit/s
    \end{align*}
    \item Time to transmit one packet and receving the acknowledgment:
    \begin{align*}
      T_2 &= t_{difs} + \frac{\sum_{X=0}^{31}X \cdot t_{slot}}{32} + t_{sifs} + T_1 \\
          &= 20 \mu s + 15.5 \mu s + 10 \mu s + 1203 \mu s \\
          &= 1248.5 \mu s \\
          &= 1.2485 ms
    \end{align*}
    The maximum throughput $D_@$ in $bit/s$ is therefore:
    \begin{align*}
      D_2 = (1000 ms / 1.2485 ms) * (12000 + 112 bit) = 9.701 \cdot 10^{6} bit/s
    \end{align*}
    \item Time to transmit one packet and receiving the acknowledgment:
    \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 + 1285 ms\\
          &= 292 \mu s + 1285 \mu s \\
          &= 1.577ms
    \end{align*}
     The maximum throughput $D_@$ in $bit/s$ is therefore:
     \begin{align*}
       D_3 = (1000 ms / 1.577 ms) * (12000 + 112 + 160 + 112) = 7.852 \cdot 10^{6} bit/s
     \end{align*}
\end{enumerate}
\Aufgabe{Broadband Internet Access}{3+3+3+3+3+3+3+3+3+3}
\begin{enumerate}
    \item An \textit{ADSL modem} modulates and demodulates the data using DMT and creates downstream and upstream channels.
    \item A \textit{DSL access multiplier} does the same at the ISP side.
    \item The typical range is $12000ft = 3657.6m$.
    \item The router assigns the IP address from the \textit{BRAS} to the customer using the \textit{PPP} protocol.
    \item ADSL uses $26 - 108 \kHz$ for upstream and $138 - 1104 \kHz$ for downstream.\\ Cable uses $5 - 42 \mHz$ for upstream, $54 - 450 \mHz$ for video and $550 - 750 \mHz$ for downstream.
    \item The data from separate coaxial cables are multiplexed on a single shared medium.
    \item Capacity sharing is realized with \textit{frequency division multiplexing} and with \textit{statistical time division multiplexing}.
    \item 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.
    \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.
    \item The cable modem on the customer premise is configured and controlled by the CMTS using DOCSIS and layer 1 and 2 protocols.
\end{enumerate}
\end{document}
