\documentclass[12pt]{article}
\usepackage{latexsym,amssymb,amsmath} % for \Box, \mathbb, split, etc.
% \usepackage[]{showkeys} % shows label names
\usepackage{cite} % sorts citation numbers appropriately
\usepackage{path}
\usepackage{url}
\usepackage{verbatim}
\usepackage[pdftex]{graphicx}

% horizontal margins: 1.0 + 6.5 + 1.0 = 8.5
\setlength{\oddsidemargin}{0.0in}
\setlength{\textwidth}{6.5in}
% vertical margins: 1.0 + 9.0 + 1.0 = 11.0
\setlength{\topmargin}{0.0in}
\setlength{\headheight}{12pt}
\setlength{\headsep}{13pt}
\setlength{\textheight}{625pt}
\setlength{\footskip}{24pt}

\renewcommand{\textfraction}{0.10}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\floatpagefraction}{0.90}

\makeatletter
\setlength{\arraycolsep}{2\p@} % make spaces around "=" in eqnarray smaller
\makeatother

% change equation, table, figure numbers to be counted inside a section:
\numberwithin{equation}{section}
\numberwithin{table}{section}
\numberwithin{figure}{section}

% begin of personal macros
\newcommand{\half}{{\textstyle \frac{1}{2}}}
\newcommand{\eps}{\varepsilon}
\newcommand{\myth}{\vartheta}
\newcommand{\myphi}{\varphi}

\newcommand{\IN}{\mathbb{N}}
\newcommand{\IZ}{\mathbb{Z}}
\newcommand{\IQ}{\mathbb{Q}}
\newcommand{\IR}{\mathbb{R}}
\newcommand{\IC}{\mathbb{C}}
\newcommand{\Real}[1]{\mathrm{Re}\left({#1}\right)}
\newcommand{\Imag}[1]{\mathrm{Im}\left({#1}\right)}

\newcommand{\norm}[2]{\|{#1}\|_{{}_{#2}}}
\newcommand{\abs}[1]{\left|{#1}\right|}
\newcommand{\ip}[2]{\left\langle {#1}, {#2} \right\rangle}
\newcommand{\der}[2]{\frac{\partial {#1}}{\partial {#2}}}
\newcommand{\dder}[2]{\frac{\partial^2 {#1}}{\partial {#2}^2}}

\newcommand{\nn}{\mathbf{n}}
\newcommand{\xx}{\mathbf{x}}
\newcommand{\uu}{\mathbf{u}}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\usepackage{titlesec}
\newcommand{\junk}[1]{{}}
\usepackage{xcolor}
\definecolor{darkblue}{rgb}{0,0,0.4}
\usepackage[colorlinks = true,
linkcolor = darkblue,
urlcolor  = darkblue,
citecolor = darkblue,
anchorcolor = darkblue]{hyperref}
% set two lengths for the includegraphics commands used to import the plots:
\newlength{\fwtwo} \setlength{\fwtwo}{0.45\textwidth}
% end of personal macros

\begin{document}
\DeclareGraphicsExtensions{.jpg}

\begin{center}
\textsc{\Large Computer Networks} \\[2pt]
	\textsc{\large Assignment 2}\\
	\vspace{0.5cm}
  Ali Gholami \\[6pt]
  Department of Computer Engineering \& Information Technology\\
  Amirkabir University of Technology  \\[6pt]
  \def\UrlFont{\em}
  \url{https://aligholamee.github.io}\\
    \href{aligholami7596@gmail.com}{\textit{aligholami7596@gmail.com}}
\end{center}

\begin{abstract}
This assignment takes a brief look at the challenges through the data transferring in a network. In problem 1 and 2, the \textit{delay} issue is discussed. Terms like \textit{Transmission Delay, Queuing Delay, Propagation Delay \& Processing Delay} is discussed. Problem 3, takes a deeper point of view for the \textit{Packet Switching \& Circuit Switching} communication. Advantages \& Disadvantages of both techniques is discussed also.
\end{abstract}

\subparagraph{Chapter 1 key words.} \textit{Store \& Forward, Cut Through, Circuit Switching, Virtual Circuit Switching, Packet Switching, Datagram, Queuing Delay, Transmission Delay, Propagation Delay, Processing Delay, Traffic Intensity, Frequency Division Multiplexing, Time Division Multiplexing.}

\section{Switch in The Middle}

Assume there is a single packet switcher between two nodes in a network. The transmission rate from the first node through the packet switcher is shown by \textit{R1}. The transmission rate from the packet switcher through the other node is shown by \textit{R2}. Given that the packet switcher conducts \textit{Store \& Forward} method to transmit the data, find the \textit{end-to-end delay} of sending a packet with size \textit{L}.

\subsection*{Solution}

The transmission rate for the path between \textit{$N_1$} \& \textit{Switch} is \textit{$R_1$}. Meaning that, it takes 1 second for $R_1$ bytes of data to be transferred from \textit{$N_1$} to the \textit{Switch}. Hence a packet with the length \textit{L} will take \textit{$\frac{L}{R_1}$} to be transferred. When the packet transmission through the switch is completed, the switch starts transmitting the packet to the \textit{$N_2$}. It takes \textit{$\frac{L}{R_2}$} for this transmission to be completed as we discussed above.

\begin{equation}
		D_{end-to-end} = \frac{L}{R_1} + \frac{L}{R_2}
\end{equation}
	

\section{P Packets N Links}
The formula for transmitting a single packet with length \textit{L} through \textit{N} links is given in equation 1.2. Assume the transmission rate to be \textit{R} for all of the paths through links. Find the formula to send \textit{P} packets through this linkage of nodes.

\begin{equation}
	D_{end-to-end} = \frac{N*L}{R}
\end{equation}

\subsection*{Solution}
Before getting into the details, I'll give an example for the above formula. Assuming that \textit{N} is 2. We have a \textit{source} node that sends the data, a \textit{middle} link node and a \textit{destination} node. The \textit{end-to-end} delay will be $\frac{2L}{R}$; Hence we can say that the packet transmission system is using the \textit{Store \& Forward} method. Having the same assumption(\textit{N = 2}) in mind, we can say that sending \textit{P} packets through this network will take 

\begin{equation}
D_{(end-to-end\ |\ N=2)} = \frac{2L}{R} + (P-1)*\frac{L}{R}
\end{equation}

That's because the first packet will take $\frac{L}{R}$ to be completely sent to the node in the \textit{middle}. When the middle node starts sending the first packet to the final node, the transmission of the second packet has started already. By the time the first packet reaches the final node, the second packet is in the middle node. Currently, it has been $\frac{2L}{R}$ passed from the moment that first packet was sent. It only take an $\frac{L}{R}$ for the second packet to be completely transferred to the final node. Generalizing the idea in mind, we can find out that sending \textit{P} packets with \textit{N = 2} is equal to what's represented in equation 1.3. If we have \textit{N} links, we have to wait $\frac{NL}{R}$ for the first packet. It also takes

\begin{equation}
D_{(end-to-end\ |\ N=P-1)} = (P-1)*\frac{L}{R}
\end{equation}
for the other packets to be transmitted through the network.\\

Finally, we'll have to wait 
\begin{equation}
D_{(end-to-end)} = \frac{NL}{R} + (P-1)*\frac{L}{R}
\end{equation}
for \textit{P} packets to be sent over an \textit{N} link network.

\section{Circuit Switching vs Packet Switching}

Assume a program that transmits data in a constant rate. This program also keeps running for some time. Answer the following questions and give your reasons.

a) Which one do you think is a better network implementation choice for this type program? A \textit{Circuit Switched} network or a \textit{Packet Switched} one?

b) Assuming that this network implements the \textit{Packet Switching} method and the traffic generated by this program is as above. Also, assume that the total transmission rate of all programs is less than the \textit{transmission rate} of individual links. Do we need a mechanism to handle the congestion in such a network?

\subsection*{Solution}

a) A \textit{Circuit Switched} network is a better approach for this type of program. The program described above is a \textit{sensitive} use case in the network. Let's assume we have a \textit{Video Platform} like \textit{Youtube}. It is important to mention that in a \textit{Packet Switched} network, the average time for packet transmission might be similar to the \textit{Circuit Switched} approach. but, the \textit{constance} \& \textit{steadiness} of data stream is an important factor in such programs. In a \textit{Circuit Switched} network, there is an initial delay to form the pathways through the nodes, but the \textit{Quality of Service} is much higher than the other approach. There is also much less \textit{Header Overhead} for sending the packets. According to the sayings of \textit{Prof. Khorsandi}, instead of using a \textit{Circuit Switched} network, we can implement a \textit{Dual-Queue Based} approach containing a \textit{Sensitive Queue} \& a  \text{Insensitive Queue}. One for the sensitive workloads \& the other one for the routine jobs. According to this idea, there are \textit{14} queues used in the current implementation of \textit{Packet Switched} networks.\\
\\
b) By definition, \textit{conjestion} occurs when an increase in the offered load results in a decrease in the effective throughput of the network. The main cause is that the \textit{packet arrival rate} at some gateway exceeds its \textit{service rate}.

\begin{equation}
	Arrival\ Rate > Service\ Rate
\end{equation}

At this point, packets are buffered, leading to delays. The additional delay can cause sources to retransmit, increasing the load on the bottleneck. This feedback leads to a rapidly deteriorating situation where retransmissions dominate the traffic, and effective throughput rapidly diminishes\cite{CCSK}.
Since the \textit{interval rate} of all programs is won't exceed the \textit{service rate}, we \textbf{won't} need any congestion handling mechanism.


\begin{thebibliography}{9}
	\bibitem{CCSK} 
	Srinivasan Keshav. 
	\textit{A Mechanism for Congestion Control in Computer Networks}. 
	Computer Systems Research Group,
	Computer Science Division,
	Department of Electrical Engineering and Computer Science,
	University of California, Berkeley,
	Berkeley, CA 94720.
	
\end{thebibliography}

\end{document}