@ -6,9 +6,11 @@ __IronForest__ _(IF)_ is a decentralized P2P network.
IronForest hardware network has two types of devices: digital (IronForest Digital Device, IFDD) and analog (IronForest Digital Device, IFAD)
## IronForest tonnels
_The following description is meant to be read in Typora_
Devices communicate through tonnels. Tonnel is a list of IF nodes' IDs: $ T(a_1, a_n)=[a_1, a_2, \,..., \, a_n] $, where $a_i$ is an id. _Short tonnel_ ($s(T)$) is one of the $min\_tonnels$ shortest paths (by time) between two nodes. Each IF node $X$ has its own list of short tonnels $X.TT$ ($\forall \, T \in X.TT\,\, X\in T$). It is obvious, that if $T(a_1, a_n)_p=A$ and $T(a_1, a_n)_q=B$ , then $T(A, B)=T(a_1,a_n)_{p:q}$. Therefore, if node $X$ has ID of node $Y$ somewhere in its list of tonnels, it knows a tonnel to $Y$.
## IronForest tunnels
Devices communicate through tunnels. tunnel is a list of IF nodes' IDs: $ T(a_1, a_n)=[a_1, a_2, \,..., \, a_n] $, where $a_i$ is an id. _Short tunnel_ ($s(T)$) is one of the $min\_tunnels$ shortest paths (by time) between two nodes. Each IF node $X$ has its own list of short tunnels $X.TT$ ($\forall \, T \in X.TT\,\, X\in T$). It is obvious, that if $T(a_1, a_n)_p=A$ and $T(a_1, a_n)_q=B$ , then $T(A, B)=T(a_1,a_n)_{p:q}$. Therefore, if node $X$ has ID of node $Y$ somewhere in its list of tunnels, it knows a tunnel to $Y$.
```mermaid
graph TD;
@ -17,28 +19,28 @@ A---G---B;
E---Z---F;
```
_Here [A, G, B], [A, E, F, B], [A, E, Z, F, B] are tonnels from A to B, but the last one will not probably be short tonnel, because it will highly likely take more time for a packet to reach the $B$ node by this path._
_Here [A, G, B], [A, E, F, B], [A, E, Z, F, B] are tunnels from A to B, but the last one will not probably be short tunnel, because it will highly likely take more time for a packet to reach the $B$ node by this path._
Node $N$ is _known_ to node $B$ if node $B$ has node $N$ in its list of tonnels: $kn(N, B)=\exists T \in N.TT\,:\,B\in T$.
Node $N$ is _known_ to node $B$ if node $B$ has node $N$ in its list of tunnels: $kn(N, B)=\exists T \in N.TT\,:\,B\in T$.
On low-level, a also tonnel has its frequency $T.F$: IFADs retranslate signals on all frequencies from $F_2 \cup \{F_1\}$ and IFDDs set one of their transmitters to the $T.F$ frequency.
On low-level, a also tunnel has its frequency $T.F$: IFADs retranslate signals on all frequencies from $F_2 \cup \{F_1\}$ and IFDDs set one of their transmitters to the $T.F$ frequency.
#### Building a tonnel
#### Building a tunnel
How does node $A$ build a tonnel to an unknown node $B$?
How does node $A$ build a tunnel to an unknown node $B$?
$A$ sends a multicast message to the network. This message consists of type (tonnel request), destination $m.d=B$ and path (list) $m.P$ ($P_0=[A]$) and tonnel (empty for now). When another node $N$ receives message of this type, it appends its id to the path ($m.P+=[N]$) and resends this message either nobody if $N$ is a part of too much tonnels (this number is equal to the number of $F2$ radio modules on the IFDD board) either to all available nodes if node $B$ is not a known node to $N$ (if $!kn(N, B) = \nexists T \in N.TT: B\in T$) and message has no tonnel parameter either only to some nodes. Let's see the second variant more detailed.
$A$ sends a multicast message to the network. This message consists of type (tunnel request), destination $m.d=B$ and path (list) $m.P$ ($P_0=[A]$) and tunnel (empty for now). When another node $N$ receives message of this type, it appends its id to the path ($m.P+=[N]$) and resends this message either nobody if $N$ is a part of too much tunnels (this number is equal to the number of $F2$ radio modules on the IFDD board) either to all available nodes if node $B$ is not a known node to $N$ (if $!kn(N, B) = \nexists T \in N.TT: B\in T$) and message has no tunnel parameter either only to some nodes. Let's see the second variant more detailed.
So, node $N$ receives a message $m$. If message has not empty tonnel parameter $m.T$, then $N$ remembers tonnel T, sends message to the next node in the tonnel ($m.T_{k+1}, k: m.T_k = N$). If node $B$($m.d$) is known to $N$ ($kn(N, B)$), then:
So, node $N$ receives a message $m$. If message has not empty tunnel parameter $m.T$, then $N$ remembers tunnel T, sends message to the next node in the tunnel ($m.T_{k+1}, k: m.T_k = N$). If node $B$($m.d$) is known to $N$ ($kn(N, B)$), then:
1. $N$ checks if number of tonnels to $B$ is enough: $TT_2=\{T \in N.TT: B \in T\},\,\,|TT_2|>= tonnel\_num$, if not, then message is resent through all paths
2. $N$ sends message $m$ to $tonnel\_num$ of $TT_2$ ($TT_{2\,[1:tonnel\_num]}$)
1. $N$ checks if number of tunnels to $B$ is enough: $TT_2=\{T \in N.TT: B \in T\},\,\,|TT_2|>= tunnel\_num$, if not, then message is resent through all paths
2. $N$ sends message $m$ to $tunnel\_num$ of $TT_2$ ($TT_{2\,[1:tunnel\_num]}$)
$M=[m_1, \,...,\,m_{tonnel\_num}]$ is a list of first $tonnel\_num$ messages that reached B
$M=[m_1, \,...,\,m_{tunnel\_num}]$ is a list of first $tunnel\_num$ messages that reached B
When message $m_i \in M$ with updated path reaches $B$, $B$ remembers reversed of $m_i.P$ as the tonnel from $B$ to $A$: $T(A, B)=m.P$. $B$ decides frequency $T.F$ of tonnel (for hardware network). It sends a message with this frequency. to $A$ as multicast message using this tonnel. $A$ receives this tonnel and remembers it. Now $kn(A, B) \and kn(B, A)$.
When message $m_i \in M$ with updated path reaches $B$, $B$ remembers reversed of $m_i.P$ as the tunnel from $B$ to $A$: $T(A, B)=m.P$. $B$ decides frequency $T.F$ of tunnel (for hardware network). It sends a message with this frequency. to $A$ as multicast message using this tunnel. $A$ receives this tunnel and remembers it. Now $kn(A, B) \and kn(B, A)$.
## IronForest Hardware Network
@ -46,7 +48,7 @@ There are two types of IFHN devices: analog devices (IFAD) and digital (IFDD). T
IronForest hardware0 network has two frequencies: one (_F1_) for multicast and a frequency range (F2) for tonnels.
IronForest hardware0 network has two frequencies: one (_F1_) for multicast and a frequency range (F2) for tunnels.
## IronForest analog device (IFAD) description
@ -65,11 +67,7 @@ Digital device receives signal, amplifies it and demodulates. Then signal is pro
3. If this is an $F2$ signal, check if it needs resending by this IFDD, resend by radio and overlays if needed
4. If this is an $F1$ signal, process it and resend by radio and overlays
IFDD's MC has a list of known tonnels. If it is clear that the destination of a packet is a known node (known as a part of a tonnel), IFDD will not send packet to all available nodes, it will send it just like through a usual tonnel to this known node.
## Calculating network speed and price for square kilometer
_todo_
IFDD's MC has a list of known tunnels. If it is clear that the destination of a packet is a known node (known as a part of a tunnel), IFDD will not send packet to all available nodes, it will send it just like through a usual tunnel to this known node.