# 2022: Компьютерные системы и сети. Материалы к лекциям.
[TOC]
## WebRTC
https://blog.logrocket.com/webrtc-over-websocket-in-node-js/
## MQTT Over Websockets Explained for Beginners
https://youtu.be/EvUI4vRhF88
## Tasks
https://www.cs.cornell.edu/courses/cs4450/2019sp/lecture27-review.pdf
## Testing The Mathis Equation with iperf and tc
https://netbeez.net/blog/packet-loss-round-trip-time-tcp/#:~:text=Testing%20The%20Mathis%20Equation%20with%20iperf%20and%20tc
## Puppeteer
https://nitayneeman.com/posts/getting-to-know-puppeteer-using-practical-examples/
## Алгоритмы маршрутизации
https://ru.wikipedia.org/wiki/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D1%8B_%D0%BC%D0%B0%D1%80%D1%88%D1%80%D1%83%D1%82%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8
## Category:Routing algorithms
https://en.wikipedia.org/wiki/Category:Routing_algorithms
# New internet vision
## Named_data_networking
https://en.wikipedia.org/wiki/Named_data_networking
## [New IP passages (excerpts from ICANN | New IP | October 2020 )](https://www.icann.org/en/system/files/files/octo-017-27oct20-en.pdf)
### Intelligent Operation Network (ION)
It is suggested that future networks will apply artificial intelligence, machine learning, and neural networks to identify and locate malfunctions in the network. A comprehensive and deeply correlated
analysis of measurements would be needed to allow the network to accurately pinpoint root causes of alarms and automatically invoke recovery mechanisms.
Requirements:
• “This capability in future networks enables the advanced intelligent operations described previously. The network requires instantaneous collection of network statistics with low latency.”
• “The network will need to report network monitoring information to the intelligent control functionalities from diverse discrete events... Such information should be given a higher priority, as a need for extremely low latency is expected, at millisecond level.”
### Network and Computing Convergence (NCC)
Networks may require multiple distributed network edge sites to interconnect and collaborate with each other to exploit the full potential of cloud computing.
*Instead of the conventional client-server model, applications would be able to dynamically schedule computing tasks to corresponding computing nodes at different locations according to specific service requirements.*
These networks are expected to support computing-aware network capabilities that can offer unified management, control, and operation in order to
guarantee differentiated service experience with much higher granularity than what is available at present.
Requirements:
• “As networks and computing converge, future networks should support
controllable in-time computing power allocation, including modelling, measuring, sensing, advertising and operation of computing power, with prescribed time limitations.”
• “Future networks should also support joint network and computing resource
scheduling.”
• “Based on ubiquitous computing resources, every network node can become a
resource provider. Flexible addressing capability is thus needed in order to optimally address computing sites and to avoid wasting network resources.”
### Industrial IoT with Cloudification (IIOT)
It is anticipated that future industrial networks will move towards the close integration of all components of the manufacturing process:
IoT sensors, robots, automated production lines, logistics, cloud computing resources and enterprise business systems.
These developments are expected to result in the automatic operation and control of industrial processes without significant human intervention.
Requirements:
• “IoT systems contain many control subsystems that run at cycle times ranging from sub-ms to 10 ms.”
• “It is a fundamental requirement for multiple-axis applications to have time synchronization in order to permit cooperation between various devices, sometimes remotely.”
• “In order to recover the clock signal and reach precise time synchronization, the machine control, especially the motion control sub-system, requires very small jitter at sub-microsecond level, and such a small jitter is expected to have bounded limits under some critical situations.”
• “IIoT systems demand high reliability and high security to avoid any potential risk of interrupting production. Specifically, the service availability requirement typically ranges from 99.9999% to 99.999999% for IIoT applications.”
# Ссылка на экзаменационную задачу по PDV
https://hackmd.io/@IvanVasil/Vasilevskiy
# Пример расчетной экзаменационной задачи
## Ненадежные WebSockets
В момент времени $t=0$ серверное приложение было соединено с 6 независимыми клиентскими приложениями по протоколу WebSockets:

Каждую минуту серверное приложение посылает сообщение клиентам и проверяет, какое количество клиентов у него находится. К сожалению, из-за состояния каналов связи, ограничений браузеров и серверов, вероятность отключения сокета между очередными сообщениями равна 1/2.
Через некоторое время все сокеты были отключены:

Распределенное клиент-серверное приложение считается работающим до тех пор, пока есть хотя бы одно работающее соединение. Такое поведение называется [плавной деградацией работы](https://en.wikipedia.org/wiki/Fault_tolerance#:~:text=The%20ability%20of%20maintaining%20functionality%20when%20portions%20of%20a%20system%20break%20down%20is%20referred%20to%20as%20graceful%20degradation.) клиент-серверной системы.
**Найдите среднее время (в минутах) работы этого приложения** с точностью 2 знака после запятой.
# Пример экзаменационной задачи на реализацию
## Модель ненадежных WebSockets
Построить клиент-серверное приложение, используя протокол Websockets, моделирующее условия расчетной задачи и выполняющее эмпирическую оценку времени существования распределенного приложения.
Для реализации можно воспользоваться в качестве шаблона приложением
https://replit.com/join/byvoqjthld-arthmax
[](https://replit.com/join/byvoqjthld-arthmax)
## Решение задачи " Ненадежные WebSockets"
Среднее время в данном случае - математическое ожидание времени работы при всех возможных вариантах поведения.
Случайной величиной здесь является величина $\widehat{T}$, принимающая значения из множества $\{ 1,2,3, ...\}$ - номера сообщения от сервера, и одновременно (по условию задачи)- это число минут в момент полной деградации системы.
Пусть $p(t)=P(\widehat T = t)$ - вероятность полной деградации системы на $t$-той минуте.
Тогда мы можем записать математическое ожидание $E(\widehat T)$ времени полной деградации как
$$
E(\widehat T) = \sum_{t=1}^{\infty} t\cdot p(t) \, \,
= \,\, 1\cdot P(\widehat T = 1) + 2 \cdot P(\widehat T = 2) + 3 \cdot P(\widehat T = 3) \,+ \,\,... \label{E1}\tag{1}
$$
Легко показать, что $(\ref{E1})$ можно переписать в виде $(\ref{E2})$:
$$
E(\widehat T) = P(\widehat T \ge 1) + P(\widehat T \ge 2) + P(\widehat T \ge 3) \,+ \,\,... \label{E2}\tag{2}
$$
Здесь $P(\widehat T \ge t)$ - вероятность того, что полный отказ произойдет на $t$-той минуте или позже.
Вероятность того, что какой-то конкретный сокет дожил до окончания $t$-той минуты:
$$
p_s(t) = (1/2)^t,
$$
а соответствующая вероятность, что он не дожил:
$$
\bar p_s(t) = 1 - p_s(t) =1 - (1/2)^t,
$$
Обозначим вероятность, что система прекратит свою работу до окончания $t-1$ минуты, то есть, что все 6 сокетов не дожили до начала $t$-той минуты, как
$$
P(\widehat T \le t-1)
$$
Тогда
$$
P(\widehat T \le t-1)= (\bar p_s(t-1))^6 = \left(1 - (1/2)^{t-1}\right)^6,
$$
поскольку отключения сокетов происходят независимо друг от друга.
Зная, что
$$
P(\widehat T \ge t) + P(\widehat T \le t-1)= 1,
$$
получаем
$$
P(\widehat T \ge t) = 1 - P(\widehat T \le t-1) = 1 - \left(1 - (1/2)^{t-1}\right)^6. \label{PgeT}\tag{3}
$$
Раскрывая скобки $(\ref{PgeT})$, получаем
$$
P(\widehat T \ge t) = 6 \left(\frac{1}{2} \right)^{t-1} -15 \left(\frac{1}{4} \right)^{t-1}+ 20 \left(\frac{1}{8} \right)^{t-1} -15 \left(\frac{1}{16} \right)^{t-1} +6 \left(\frac{1}{32} \right)^{t-1} - \left(\frac{1}{64} \right)^{t-1}.
$$
Поскольку (см. $(\ref{E2})$):
$$
E(\widehat T) = P(\widehat T \ge 1) + P(\widehat T \ge 2) + P(\widehat T \ge 3) \,+ \,\,... = \sum_{t=1}^\infty P(\widehat T \ge t),
$$
получаем
$$
E(\widehat T) = \Sigma_{t=1}^\infty \left[ 6 \left(\frac{1}{2} \right)^{t-1} -15 \left(\frac{1}{4} \right)^{t-1}+ 20 \left(\frac{1}{8} \right)^{t-1} -15 \left(\frac{1}{16} \right)^{t-1} +6 \left(\frac{1}{32} \right)^{t-1} - \left(\frac{1}{64} \right)^{t-1} \right]
$$
$$
E(\widehat T) = 6 \Sigma_{t=1}^\infty \left(\frac{1}{2} \right)^{t-1} -15 \Sigma_{t=1}^\infty \left(\frac{1}{4} \right)^{t-1}+ 20 \Sigma_{t=1}^\infty \left(\frac{1}{8} \right)^{t-1} -15 \Sigma_{t=1}^\infty\left(\frac{1}{16} \right)^{t-1} +6 \Sigma_{t=1}^\infty \left(\frac{1}{32} \right)^{t-1} - \Sigma_{t=1}^\infty \left(\frac{1}{64} \right)^{t-1}.
$$
И, используя формулу для суммы геометрической прогрессии, имеем
$$
E(\widehat T) = 6 \frac{1}{1-1/2} -15 \frac{1}{1-1/4}+ 20 \frac{1}{1-1/8} -15 \frac{1}{1-1/16} +6 \frac{1}{1-1/32} - \frac{1}{1-1/64} \approx 4.03 \text{[минуты]}.\\
$$
## Образец выравнивания многострочных формул
$$a := x^2-y^3 \tag{a}$$
$$
\begin{array}{rcr}
x+2y & = & -1 \\
-x+4y & = & 0 \\
\end{array}
$$
$$
\left\{
\begin{array}{rcl}
x+2y & = & -1 \\
-x+4y & = & 0 \\
\end{array}
\right.
$$
In equation $(2)$, we find the value of an
interesting integral:
$$
\begin{equation}
\ddot{\underline{\mathbf{r}}} = \frac{d^2\underline{\mathbf{r}}}{dt^2} = 0
\end{equation}
$$
Reference to label q is $\ref{q}$
$$
a := x^2-y^3 \label{a}
$$
$$
a := x^2-y^3 \label{q}\tag{*}
$$
Reference to label \ref{PgeT} is $\ref{PgeT}$
$$
\newcommand{\SES}[3]{ 0 \to #1 \to #2 \to #3 \to 0 }
\SES{A}{B}{C} \\
\SES{C}{A}{B}
\newcommand{\e}{ \varepsilon }
\newcommand{\m}[9]{ \left[
\begin{matrix}
#1 & #2 & #3 \\
#4 & #5 & #6 \\
#7 & #8 & #9
\end{matrix}
\right] }
$$
$$
\m{x }{0 }{0 }
{y }{\e}{0 }
{z }{0 }{\e}^{-1}
= \frac{1}{x\varepsilon}
\m{\e}{0}{0}
{-y}{x}{0}
{-z}{0}{x}
= \m{1/x}{0}{0}
{-\e^{-1}y/x}{\e^{-1}}{0}
{-\e^{-1}z/x}{0}{\e^{-1}}
$$
# Список литературы
1. High Performance Browser Networking, Ilya Grigorik, 2013, O'Reilly Media, Inc.
1. Kurose, J. F., & Ross, K. W. (2012). Computer Networking: A Top-Down Approach
1. Распределенные системы, Эндрю С. Таненбаум, Мартен ван Стин, 2021
1. Компьютерные сети, Таненбаум, Э., Шрага, В., 2009
1. Комп'ютерні мережі: принципи, технології, протоколи: навч. посібник для вузів. Укладач: Оліфер, В. Г., 2015
1. Безопасность сетей - Национальный Открытый Университет "ИНТУИТ" - 2016 - 571с.
1. Грегори Р. Эндрюс. Основы многопоточного, параллельного и распределенного программирования. – М.: Издательский дом «Вильямс», 2003
# Ресурсы
1. https://hpbn.co/ High Performance Browser Networking, Ilya Grigorik, online version
2. https://ebin.pub/9785970607084-9781543057386.html Распределенные системы, Эндрю С. Таненбаум, Мартен ван Стин
3. https://e.lanbook.com/book/100581 Безопасность сетей
4. http://www.parallel.ru – сервер Лаборатории Параллельных информационных технологий Научно-исследовательского вычислительного центра Московского государственного университета имени М.В.Ломоносова.
5. https://en.wikipedia.org/wiki/Transmission_Control_Protocol Transmission Control Protocol
6. https://replit.com/talk/learn/SocketIO-Tutorial-What-its-for-and-how-to-use/143781 Socket.IO Tutorial
7. https://en.wikipedia.org/wiki/WebSocket Протокол WebSocket
8. [TCP throughput calculator](https://www.switch.ch/fr/network/tools/tcp_throughput/?do+new+calculation=do+new+calculation)
# Статьи
[Keeping CALM: When Distributed Consistency Is Easy](https://cacm.acm.org/magazines/2020/9/246941-keeping-calm/fulltext)
[The Macroscopic Behavior of the TCP Congestion Avoidance Algorithm. Mathis, 1998](https://www.cs.utexas.edu/users/lam/395t/papers/Mathis1998.pdf)
[Distributed Solution of Large-Scale Linear Systems
via Accelerated Projection-Based Consensus](https://arxiv.org/pdf/1708.01413.pdf)
[Capacity Planning:
A Revolutionary Approach for Tomorrow’s Digital Infrastructure ](https://www.cmg.org/wp-content/uploads/2013/10/CMG-Revolutionary_Capacity_Planning-PAPER.pdf)
[Network_calculus](https://en.wikipedia.org/wiki/Network_calculus)
[A Network Calculus with Effective Bandwidth](https://www.comm.utoronto.ca/~jorg/archive/papers/effenv-bw-v8-R2v2.pdf)
[minplus playground](https://www.realtimeatwork.com/minplus-playground)
[What’s the Difference? Efficient Set Reconciliation without Prior Context](https://www.ics.uci.edu/~eppstein/pubs/EppGooUye-SIGCOMM-11.pdf)
[Approximate Distributed Set Reconciliation with Defined Accuracy. Dissertation](https://edoc.hu-berlin.de/bitstream/handle/18452/22105/dissertation_kruber_nico.pdf?sequence=5)
[String Reconciliation in Ditributed System](https://github.com/String-Reconciliation-Ditributed-System/cpisync)
https://en.wikipedia.org/wiki/Cheeger_constant_(graph_theory)
https://en.wikipedia.org/wiki/Conductance_(graph)