\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}}

\begin{document}
%\header{BlattNr}{Tutor}{Abgabedatum}{Vorlesungsname}{Namen}{Semester}{Anzahl Aufgaben}
\header{8}{}{2015-12-06}{Kommunikationsnetze}{\textit{Jonas Jaszkowic, 3592719}\\\textit{Jan-Peter Hohloch, 3908712}}{WS 15/16}{4}
\vspace{1cm}
\Aufgabe{ALOHA, CSMA and CSMA/CD}{5+5+5+5}\\
    We used the following random numbers:\\
    \begin{itemize}
        \item $^1,^2,^3,^8=0$
        \item $^4,^6,^{12},^{13},^{12.1}=1$
        \item $^7=2$
        \item $^5=3$
        \item $^9,^{10},^{11},^{14},^{15},^{16} \geq 9$
        \item $^{17}< 0.5$
        \item $^{18} > 0.5$
    \end{itemize}
    \includegraphics[width=\textwidth]{a1.jpg}\\\begin{corr}
        Zufallszahlen entsprechen nicht der Konvention auf manchen Folien\\
    \end{corr}
\Aufgabe{Code Division Multiple Access(CDMA)}{10+10+10}
\begin{enumerate}
	\item Generate Walsh-Tables for $n=8$:\\
        \begin{math}
            W_1=\begin{pmatrix}
                -1
            \end{pmatrix},\ W_2=\begin{pmatrix}
                -1 & -1\\
                -1 & 1
            \end{pmatrix},\ W_4=\begin{pmatrix}
                -1 & -1 & -1 & -1\\
                -1 & 1 & -1 & 1\\
                -1 & -1 & 1 & 1\\
                -1 & 1 & 1 & -1\\
            \end{pmatrix}\\
            W_8=\begin{pmatrix}
                -1 & -1 & -1 & -1&-1 & -1 & -1 & -1\\
                -1 & 1 & -1 & 1&-1 & 1 & -1 & 1\\
                -1 & -1 & 1 & 1&-1 & -1 & 1 & 1\\
                -1 & 1 & 1 & -1&-1 & 1 & 1 & -1\\
                -1 & -1 & -1 &-1&1 & 1 & 1 & 1\\
                -1 & 1 & -1 & 1&1 & -1 & 1 & -1\\
                -1 & -1 & 1 & 1&1 & 1 & -1 & -1\\
                -1 & 1 & 1 & -1&1 & -1 & -1 & 1\\
            \end{pmatrix}=\begin{pmatrix}
                c_0&c_1&c_2&c_3&c_4&c_5&c_6&c_7
            \end{pmatrix}
        \end{math}
	\item $c_2$ is orthogonal to all other chips:\\
        \begin{math}\begin{scriptsize}
            c_0\cdot c_2=\begin{pmatrix}
                -1\\-1\\-1\\-1\\-1\\-1\\-1\\-1
            \end{pmatrix}\cdot\begin{pmatrix}
                -1\\-1\\1\\1\\-1\\-1\\1\\1
            \end{pmatrix}=1+1-1-1+1+1-1-1=0\\
            c_1\cdot c_2=\begin{pmatrix}
                -1\\1\\-1\\1\\-1\\1\\-1\\1
            \end{pmatrix}\cdot \begin{pmatrix}
                -1\\-1\\1\\1\\-1\\-1\\1\\1
            \end{pmatrix}=1-1-1+1+1-1-1+1=0\\
            c_3\cdot c_2=\begin{pmatrix}
                -1\\1\\1\\-1\\-1\\1\\1\\-1
            \end{pmatrix}\cdot \begin{pmatrix}
                -1\\-1\\1\\1\\-1\\-1\\1\\1
            \end{pmatrix}=1-1+1-1+1-1+1-1=0\\
            c_4\cdot c_2=\begin{pmatrix}
                -1\\-1\\-1\\-1\\1\\1\\1\\1
            \end{pmatrix}\cdot\begin{pmatrix}
                -1\\-1\\1\\1\\-1\\-1\\1\\1
            \end{pmatrix}=1+1-1-1-1-1+1+1=0\\
            c_5\cdot c_2=\begin{pmatrix}
                -1\\1\\-1\\1\\1\\-1\\1\\-1
            \end{pmatrix}\cdot \begin{pmatrix}
                -1\\-1\\1\\1\\-1\\-1\\1\\1
            \end{pmatrix}=1-1-1+1-1+1+1-1=0\\
            c_6\cdot c_2=\begin{pmatrix}
                -1\\-1\\1\\1\\1\\1\\-1\\-1
            \end{pmatrix}\cdot\begin{pmatrix}
                -1\\-1\\1\\1\\-1\\-1\\1\\1
            \end{pmatrix}=1+1+1+1-1-1-1-1=0\\
            c_7\cdot c_2=\begin{pmatrix}
                -1\\1\\1\\-1\\1\\-1\\-1\\1
            \end{pmatrix}\cdot\begin{pmatrix}
                -1\\-1\\1\\1\\-1\\-1\\1\\1
            \end{pmatrix}=1-1+1-1-1+1-1+1=0\\
            \end{scriptsize}\Rightarrow c_2
        \end{math} is orthogonal to all other chips.
	\item Stations 1 to 4 send \texttt{00,01,10,11}:\\
    \begin{itemize}
        \item Stations 0 and 5 to 7 send $\begin{pmatrix}
                0&0&0&0&0&0&0&0
            \end{pmatrix}$ for two ticks
        \item Station 1 sends
            \begin{enumerate}
                \item $(-1)\cdot\begin{pmatrix}
                -1&1&-1&1&-1&1&-1&1
            \end{pmatrix}=\begin{pmatrix}
                1&-1&1&-1&1&-1&1&-1
            \end{pmatrix}$
                \item $(-1)\cdot\begin{pmatrix}
                -1&1&-1&1&-1&1&-1&1
            \end{pmatrix}=\begin{pmatrix}
                1&-1&1&-1&1&-1&1&-1
            \end{pmatrix}$
            \end{enumerate}
        \item Station 2 sends
            \begin{enumerate}
                \item $(-1)\cdot \begin{pmatrix}
                -1&-1&1&1&-1&-1&1&1
            \end{pmatrix}=\begin{pmatrix}
                1&1&-1&-1&1&1&-1&-1
            \end{pmatrix}$
                \item $1\cdot \begin{pmatrix}
                -1&-1&1&1&-1&-1&1&1
            \end{pmatrix}=\begin{pmatrix}
                -1&-1&1&1&-1&-1&1&1
            \end{pmatrix}$
            \end{enumerate}
        \item Station 3 sends
            \begin{enumerate}
                \item $1\cdot \begin{pmatrix}
                -1&1&1&-1&-1&1&1&-1
            \end{pmatrix}= \begin{pmatrix}
                -1&1&1&-1&-1&1&1&-1
            \end{pmatrix}$
                \item $(-1)\cdot  \begin{pmatrix}
                -1&1&1&-1&-1&1&1&-1
            \end{pmatrix}= \begin{pmatrix}
                1&-1&-1&1&1&-1&-1&1
            \end{pmatrix}$
            \end{enumerate}
        \item Station 4 sends
            \begin{enumerate}
                \item $1\cdot \begin{pmatrix}
                -1&-1&-1&-1&1&1&1&1
            \end{pmatrix}=\begin{pmatrix}
                -1&-1&-1&-1&1&1&1&1
            \end{pmatrix}$
                \item $1\cdot \begin{pmatrix}
                -1&-1&-1&-1&1&1&1&1
            \end{pmatrix}=\begin{pmatrix}
                -1&-1&-1&-1&1&1&1&1
            \end{pmatrix}$
            \end{enumerate}
    \end{itemize}
    $\Rightarrow$ Data is: \begin{enumerate}
        \item \begin{math}
            \begin{array}
                {l c c c c c c c c}
                &1&-1&1&-1&1&-1&1&-1\\
                +&1&1&-1&-1&1&1&-1&-1\\
                +&-1&1&1&-1&-1&1&1&-1\\
                +&-1&-1&-1&-1&1&1&1&1\\\hline
                =&0&0&0&-4&2&2&2&-2
            \end{array}
            \end{math}
        \item \begin{math}
            \begin{array}
                {l c c c c c c c c}
                &1&-1&1&-1&1&-1&1&-1\\
                +&-1&-1&1&1&-1&-1&1&1\\
                +&1&-1&-1&1&1&-1&-1&1\\
                +&-1&-1&-1&-1&1&1&1&1\\\hline
                =&0&-4&0&0&2&-2&2&2
            \end{array}
        \end{math}
    \end{enumerate}
    \begin{tikzpicture}
        \begin{axis}[
            axis lines = middle,
            enlargelimits,
            clip=false,
            xlabel=t,
            ylabel=f(t),
            x=0.7cm,
            y=0.7cm,
            ]
            \addplot[thick,mark=none,const plot,black, fill=black] coordinates {(0,0) (1,0) (2,0) (3,-4) (4,2) (5,2) (6,2) (7,-2) (8,0) (9,-4) (10,0) (11,0) (12,2) (13,-2) (14,2) (15,2) (16,0)};
        \end{axis}
    \end{tikzpicture}\ok
\end{enumerate}
\Aufgabe{Token Ring}{10+10}
\begin{enumerate}
	\item The maximum capacity is asked so we assume each line to have $20m$:\begin{align*}
        x&=&n\cdot \left(1bit+ \frac{20m}{\frac{2}{3}\cdot 3\cdot 10^8 \frac{m}{s}}\cdot 4Mbit/s\right)\\
        &\overset{n=10}{=}& 10bit + 10\cdot 10^{-7}\cdot 4 Mbit\\
        &=& 10bit +4 bit\\
        &=& 14 bit
    \end{align*}\ok
	\item Assume only the token has to circulate ($3\cdot 8 bit= 24bit$):\\
    \begin{align*}
        &24 bit &\le& n\cdot \left(1bit+ \frac{20m}{\frac{2}{3}\cdot 3\cdot 10^8 \frac{m}{s}}\cdot 4Mbit/s\right)\\
        \Leftrightarrow & 24 bit &\le & n\cdot 1.4 bit\\
        \Leftrightarrow &\frac{24}{1.4} & \leq & n\\
        \overset{n\in\mathds{N}}{\Rightarrow} & 18 &\leq& n
    \end{align*}
    $\Rightarrow$ We need at least 18 stations to let the whole token circulate.\ok
\end{enumerate}
\Aufgabe{Ethernet}{5+5+5+5+5+5}
\begin{enumerate}
	\item A bridge is a Layer-2 switch. Switching can be done on different layers but always means the connection of different LANs or devices on the respective layer (e.g. connection Applications)
    \begin{corr}
        fast das gleiche, Ausnahme 2-Port Bridge ist kein Switch
    \end{corr}
	\item A bridged implementation of a network allows for lowering the overall load by only sending the messages in the networks participating in the conversation. Additional buffering can be implemented in the bridge.
    \begin{corr}
        Trennung Kollisionsdomänen
    \end{corr}
	\item CSMA/CD is not needed if the network is full duplex because there is no collision if only one stations sends on the one line for this direction.
	\item \texttt{1A:7B:C3:4D:EF:95} is transmitted as \texttt{A1:B7:3C:D4:FE:59}, in binary representation \texttt{1010 0001 1011 0111 0011 1100 1101 0100 1111 1110 0101 1001}
	\item Minimum are 46bytes, so we need 4bytes padding
	\item Maximum are 1500bytes, so we need two frames (if no special additional compression is used). We have 1510bytes of message and twice the remaining frame (18byte) $1510byte+2\cdot 18byte= 1546byte$\\
    We need padding since the first frame is fully filled: $+46-10=36$\\
    $\Rightarrow 1546bit+36bit=1582bit$
\end{enumerate}
\end{document}
