# Lab 1
[TOC]
1. Create a client-server application in javascript using the HTTP protocol that tests the total request to server and back (RTT) travel time with the calculation of **minimum, maximum, median and average RTT, standard deviation and skewness ratio** for client-to-server request frequencies 16Hz, 8Hz, 4Hz, 2Hz, 1Hz, and for client request sizes 128, 256, 512, 1024, 2048 bytes.
Present the results in the form of tables
2. Test the operation of your client-server application on a personal area network (PAN) and on a wide area network (WAN on replit.com hosting).
3. Estimate the distance to the server and the characteristics of the client-server channel that can be obtained from this data
4. Compare the obtained data with the data of the system network utility ping.
## Theoretical information
### Round-Trip Time (RTT)
The Round-Trip Time (RTT) refers to the time it takes for a signal to travel from its source to a destination and for the acknowledgment of that signal to return to the source. In the context of networking, RTT is commonly employed as an indicator of a network connection's responsiveness and performance.
### Standard Deviation
The standard deviation is a metric that quantifies the degree of variation or dispersion within a dataset. When applied to RTT measurements, the standard deviation can provide insights into the extent to which RTT values deviate from the average RTT. A higher standard deviation indicates that the RTT values are more widely spread out, indicating greater variability. Conversely, a lower standard deviation suggests that the RTT values are more consistent and less prone to significant fluctuations.
The standard deviation $σ$ of a sample is calculated using the formula:
$$
\sigma = \sqrt{\frac{\sum_{i=1}^{n}(x_i - \bar{x})^2}{n}}
$$
Here:
- $x_i$ represents each individual value in the sample.
- $\bar{x}$ represents the mean of the sample.
- $n$ is the number of values in the sample.
### Skewness Ratio
Skewness is a statistical measure that assesses the asymmetry of the probability distribution of a real-valued random variable relative to its mean. A skewness ratio above zero suggests a right-skewed distribution (positively skewed), meaning that the tail on the right side is longer and the majority of values are concentrated on the left. Conversely, a skewness ratio below zero indicates a left-skewed distribution (negatively skewed), where the tail on the left side is longer and the majority of values are concentrated on the right. A skewness ratio of zero signifies a symmetric distribution, where the values are evenly distributed around the mean without any noticeable skewness.
The skewness ratio $SR$ of a sample is calculated using the formula:
$$
SR = \frac{\frac{1}{n} \sum_{i=1}^{n}(x_i - \bar{x})^3}{\sigma^3}
$$
Here:
- $x_i$ represents each individual value in the sample.
- $\bar{x}$ represents the mean of the sample.
- $\sigma$ is the standard deviation of the sample.
- $n$ is the number of values in the sample.
## Code
[**Replit code here**](https://replit.com/@AlinaYezhkova/csn1)
### index.js
```javascript
const server = http.createServer((req, res) => {
console.log(req.url);
if (req.method === 'GET'){
if (req.url === '/') {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(contentHTML);
}
else if (req.url === '/styles.css') {
res.writeHead(200, {'Content-Type': 'text/css'});
res.end(contentStyles);
}
else if (req.url === '/script.js') {
res.writeHead(200, {'Content-Type': 'text/javascript'});
res.end(contentScript);
}
else {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(req.url);
}
}
else
if (req.url === '/measureRTT') {
let requestData = '';
req.on('data', chunk => {requestData += chunk;});
req.on('end', () => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(requestData);
});
}
});
```
This code snippet creates an HTTP server using Node.js's 'http' module. It handles incoming requests and responses. It implements a route '/measureRTT' for measuring Round-Trip Time (RTT) by responding with the received request data. The server responds to GET requests with the data received from the client.
### File: script.js
```javascript
function requestToServer(requestSize) {
const data = generateData(requestSize);
console.log("fetching data of length="+data.length)
const startTime = Date.now();
fetch('/measureRTT'+'/'+data )
.then(response => {
const rtt = Date.now() - startTime;
return response.text()
.then(responseData => {
const sizeInBytes = responseData.length;
console.log("responseData:"+responseData);
console.log('Response size=', sizeInBytes, 'bytes');
calculateMetrics(rtt);
});
})
.catch(error => {
console.error('Error sending request:', error);
});
}
```
The function `requestToServer(requestSize)` is responsible for sending a GET request to the server to measure the Round-Trip Time (RTT):
1. **Generate Data**: It generates data of the specified size using the `generateData()` function. This data will be sent in the body of the GET request.
2. **Start Time**: It records the current time as the start time before sending the request.
3. **Fetch Request**: It uses the `fetch()` function to send a GET request to the '/measureRTT' endpoint of the server. The request includes the generated data in the body and specifies the content type as 'text/plain'.
4. **Handle Response**: It handles the response from the server using a promise chain. When the response is received, it calculates the RTT by subtracting the start time from the current time. Then it parses the response data as text and calculates the size of the response body in bytes. Finally, it logs the response size and calls the `calculateMetrics()` function to calculate and update the metrics based on the RTT:
```javascript
function calculateMetrics(rtt) {
rttValues.push(rtt);
minRTT = calculateMinimum(rttValues);
maxRTT = calculateMaximum(rttValues);
medianRTT = calculateMedian(rttValues);
avgRTT = calculateAverage(rttValues);
stdDevRTT = calculateStandardDeviation(rttValues);
skewnessRatio = calculateSkewnessRatio(rttValues);
myConsole.innerText =
"Current frequency: " + frequenciesHz[currentFrequencyIndex] + "\n" +
"Amount of requests: " + rttValues.length + "\n" +
"RTT: " + rtt + " ms\n" +
"Minimum RTT: " + minRTT + " ms\n" +
"Maximum RTT: " + maxRTT + " ms\n" +
"Median RTT: " + medianRTT + " ms\n" +
"Average RTT: " + avgRTT + " ms\n" +
"Standard Deviation RTT: " + stdDevRTT + " ms\n" +
"Skewness Ratio: " + skewnessRatio + "\n";
updateLoadingBar();
}
```
The following statistics are based on **100 requests** per round.
## Results of the test on a personal area network (PAN)
Technical characteristics of the computer on which the experiment was conducted:
```
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 12
On-line CPU(s) list: 0-11
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
CPU family: 6
Model: 158
Thread(s) per core: 2
Core(s) per socket: 6
Socket(s): 1
Stepping: 10
CPU max MHz: 4500.0000
CPU min MHz: 800.0000
```
***Firefox*** browser was used to run the client part of the application.
<table>
<thead>
<tr>
<th>Freq (Hz)</th>
<th>Request size</th>
<th>Total Requests</th>
<th>Min RTT (ms)</th>
<th>Max RTT (ms)</th>
<th>Med RTT (ms)</th>
<th>Avg RTT (ms)</th>
<th>STD RTT (ms)</th>
<th>Skewness Ratio</th>
</tr>
</thead>
<tbody>
<!-- Results will be dynamically added here -->
<tr>
<td>16</td>
<td>128</td>
<td>100</td>
<td>2</td>
<td>90</td>
<td>6</td>
<td>8.91</td>
<td>11.18</td>
<td>0.0518</td>
</tr><tr>
<td>8</td>
<td>128</td>
<td>100</td>
<td>2</td>
<td>81</td>
<td>6</td>
<td>8.54</td>
<td>10.66</td>
<td>0.0492</td>
</tr><tr>
<td>4</td>
<td>128</td>
<td>100</td>
<td>2</td>
<td>15</td>
<td>6</td>
<td>5.89</td>
<td>1.65</td>
<td>0.0086</td>
</tr><tr>
<td>2</td>
<td>128</td>
<td>100</td>
<td>2</td>
<td>12</td>
<td>6</td>
<td>6.00</td>
<td>1.43</td>
<td>-0.0064</td>
</tr><tr>
<td>1</td>
<td>128</td>
<td>100</td>
<td>1</td>
<td>32</td>
<td>6</td>
<td>6.57</td>
<td>4.94</td>
<td>0.0266</td>
</tr><tr>
<td>16</td>
<td>256</td>
<td>100</td>
<td>2</td>
<td>21</td>
<td>6</td>
<td>6.40</td>
<td>2.96</td>
<td>0.0248</td>
</tr><tr>
<td>8</td>
<td>256</td>
<td>100</td>
<td>1</td>
<td>55</td>
<td>6</td>
<td>6.25</td>
<td>7.18</td>
<td>0.0564</td>
</tr><tr>
<td>4</td>
<td>256</td>
<td>100</td>
<td>1</td>
<td>47</td>
<td>6</td>
<td>7.78</td>
<td>6.90</td>
<td>0.0402</td>
</tr><tr>
<td>2</td>
<td>256</td>
<td>100</td>
<td>2</td>
<td>28</td>
<td>6</td>
<td>5.83</td>
<td>2.85</td>
<td>0.0461</td>
</tr><tr>
<td>1</td>
<td>256</td>
<td>100</td>
<td>2</td>
<td>8</td>
<td>6</td>
<td>5.77</td>
<td>1.57</td>
<td>-0.0095</td>
</tr><tr>
<td>16</td>
<td>512</td>
<td>100</td>
<td>2</td>
<td>13</td>
<td>6</td>
<td>6.06</td>
<td>1.86</td>
<td>0.0019</td>
</tr><tr>
<td>8</td>
<td>512</td>
<td>100</td>
<td>1</td>
<td>20</td>
<td>6</td>
<td>6.38</td>
<td>3.10</td>
<td>0.0146</td>
</tr><tr>
<td>4</td>
<td>512</td>
<td>100</td>
<td>2</td>
<td>11</td>
<td>7</td>
<td>6.32</td>
<td>1.68</td>
<td>-0.0051</td>
</tr><tr>
<td>2</td>
<td>512</td>
<td>100</td>
<td>2</td>
<td>40</td>
<td>6</td>
<td>6.42</td>
<td>4.12</td>
<td>0.0571</td>
</tr><tr>
<td>1</td>
<td>512</td>
<td>100</td>
<td>1</td>
<td>11</td>
<td>6</td>
<td>5.78</td>
<td>1.75</td>
<td>-0.0064</td>
</tr><tr>
<td>16</td>
<td>1024</td>
<td>100</td>
<td>1</td>
<td>26</td>
<td>6</td>
<td>6.01</td>
<td>3.79</td>
<td>0.0223</td>
</tr><tr>
<td>8</td>
<td>1024</td>
<td>100</td>
<td>1</td>
<td>20</td>
<td>6</td>
<td>5.54</td>
<td>2.98</td>
<td>0.0138</td>
</tr><tr>
<td>4</td>
<td>1024</td>
<td>100</td>
<td>1</td>
<td>20</td>
<td>6</td>
<td>6.02</td>
<td>2.36</td>
<td>0.0179</td>
</tr><tr>
<td>2</td>
<td>1024</td>
<td>100</td>
<td>1</td>
<td>8</td>
<td>6</td>
<td>5.52</td>
<td>1.78</td>
<td>-0.0083</td>
</tr><tr>
<td>1</td>
<td>1024</td>
<td>100</td>
<td>2</td>
<td>40</td>
<td>7</td>
<td>6.84</td>
<td>4.78</td>
<td>0.0568</td>
</tr><tr>
<td>16</td>
<td>2048</td>
<td>100</td>
<td>2</td>
<td>137</td>
<td>7</td>
<td>13.38</td>
<td>22.24</td>
<td>0.0374</td>
</tr><tr>
<td>8</td>
<td>2048</td>
<td>100</td>
<td>2</td>
<td>16</td>
<td>7</td>
<td>6.70</td>
<td>1.88</td>
<td>0.0048</td>
</tr><tr>
<td>4</td>
<td>2048</td>
<td>100</td>
<td>2</td>
<td>18</td>
<td>7</td>
<td>6.95</td>
<td>2.12</td>
<td>0.0057</td>
</tr><tr>
<td>2</td>
<td>2048</td>
<td>100</td>
<td>1</td>
<td>11</td>
<td>7</td>
<td>5.96</td>
<td>2.37</td>
<td>-0.0010</td>
</tr><tr>
<td>1</td>
<td>2048</td>
<td>100</td>
<td>2</td>
<td>44</td>
<td>8</td>
<td>7.46</td>
<td>4.66</td>
<td>0.0530</td>
</tr></tbody>
</table>
### Summary and сonclusions
The table presents the results of a test conducted on a personal area network (PAN) under varying frequencies and request sizes. Here's a summary of the findings:
- **Frequency (Hz)**: Ranged from 1 Hz to 16 Hz, indicating the rate at which requests were sent to the server.
- **Request Size**: Varied from 128 bytes to 2048 bytes, representing the size of each request sent.
- **Total Requests**: Consisted of 100 requests for each combination of frequency and request size.
#### Observations:
- **RTT Metrics**:
- **Min RTT (ms)**: Ranged from 1 ms to 2 ms, indicating the shortest round-trip time observed.
- **Max RTT (ms)**: Spanned from 8 ms to 90 ms, representing the longest round-trip time observed.
- **Median RTT (ms)**: Varied between 6 ms and 8 ms, reflecting the middle value of the round-trip time distribution.
- **Avg RTT (ms)**: Ranged from 6 ms to 13.3 ms, representing the average round-trip time observed.
- **STD RTT (ms)**: Showcased standard deviations ranging from 1.4 ms to 22.2 ms, indicating the spread of round-trip times around the mean.
- **Skewness Ratio**: Spanned from -0.0095 to 0.0571, reflecting the symmetry or asymmetry of the round-trip time distribution.
#### Conclusions:
- **Impact of Frequency**: Higher frequencies generally resulted in shorter round-trip times, as evidenced by the decreasing trend in average and median RTT with increasing frequency.
- **Effect of Request Size**: Larger request sizes tended to lead to longer round-trip times, possibly due to increased processing overhead or network congestion.
- **RTT Distribution**: The skewness ratio provided insights into the shape of the RTT distribution, with values closer to zero indicating a more symmetric distribution.
- **Optimization Opportunities**: Based on the observed metrics, optimizations such as tuning the request size or adjusting the frequency can be explored to improve overall system performance and reduce latency.
## Results of the test on a wide area network (WAN on replit.com hosting).
<table id="results-table">
<thead>
<tr>
<th>Freq (Hz)</th>
<th>Request size</th>
<th>Total Requests</th>
<th>Min RTT (ms)</th>
<th>Max RTT (ms)</th>
<th>Med RTT (ms)</th>
<th>Avg RTT (ms)</th>
<th>STD RTT (ms)</th>
<th>Skewness Ratio</th>
</tr>
</thead>
<tbody>
<!-- Results will be dynamically added here -->
<tr>
<td>16</td>
<td>128</td>
<td>100</td>
<td>199</td>
<td>510</td>
<td>213</td>
<td>219.73</td>
<td>33.06</td>
<td>0.0761</td>
</tr><tr>
<td>8</td>
<td>128</td>
<td>100</td>
<td>200</td>
<td>456</td>
<td>212</td>
<td>216.92</td>
<td>26.30</td>
<td>0.0759</td>
</tr><tr>
<td>4</td>
<td>128</td>
<td>100</td>
<td>200</td>
<td>265</td>
<td>210</td>
<td>215.72</td>
<td>15.62</td>
<td>0.0212</td>
</tr><tr>
<td>2</td>
<td>128</td>
<td>100</td>
<td>198</td>
<td>294</td>
<td>212</td>
<td>219.68</td>
<td>19.88</td>
<td>0.0192</td>
</tr><tr>
<td>1</td>
<td>128</td>
<td>100</td>
<td>164</td>
<td>334</td>
<td>211</td>
<td>212.49</td>
<td>29.17</td>
<td>0.0123</td>
</tr><tr>
<td>16</td>
<td>256</td>
<td>100</td>
<td>183</td>
<td>512</td>
<td>195</td>
<td>212.00</td>
<td>59.56</td>
<td>0.0414</td>
</tr><tr>
<td>8</td>
<td>256</td>
<td>100</td>
<td>182</td>
<td>250</td>
<td>194</td>
<td>200.22</td>
<td>14.80</td>
<td>0.0181</td>
</tr><tr>
<td>4</td>
<td>256</td>
<td>100</td>
<td>179</td>
<td>263</td>
<td>193</td>
<td>198.59</td>
<td>16.27</td>
<td>0.0225</td>
</tr><tr>
<td>2</td>
<td>256</td>
<td>100</td>
<td>181</td>
<td>367</td>
<td>197</td>
<td>206.52</td>
<td>28.57</td>
<td>0.0296</td>
</tr><tr>
<td>1</td>
<td>256</td>
<td>100</td>
<td>185</td>
<td>297</td>
<td>199.5</td>
<td>210.85</td>
<td>26.06</td>
<td>0.0173</td>
</tr><tr>
<td>16</td>
<td>512</td>
<td>100</td>
<td>185</td>
<td>290</td>
<td>206.5</td>
<td>213.23</td>
<td>23.61</td>
<td>0.0153</td>
</tr><tr>
<td>8</td>
<td>512</td>
<td>100</td>
<td>183</td>
<td>295</td>
<td>201.5</td>
<td>211.35</td>
<td>25.86</td>
<td>0.0170</td>
</tr><tr>
<td>4</td>
<td>512</td>
<td>100</td>
<td>187</td>
<td>273</td>
<td>200</td>
<td>204.72</td>
<td>16.06</td>
<td>0.0239</td>
</tr><tr>
<td>2</td>
<td>512</td>
<td>100</td>
<td>182</td>
<td>490</td>
<td>204</td>
<td>215.73</td>
<td>37.55</td>
<td>0.0432</td>
</tr><tr>
<td>1</td>
<td>512</td>
<td>100</td>
<td>186</td>
<td>367</td>
<td>202.5</td>
<td>213.59</td>
<td>30.04</td>
<td>0.0214</td>
</tr><tr>
<td>16</td>
<td>1024</td>
<td>100</td>
<td>179</td>
<td>590</td>
<td>198</td>
<td>216.85</td>
<td>65.53</td>
<td>0.0432</td>
</tr><tr>
<td>8</td>
<td>1024</td>
<td>100</td>
<td>179</td>
<td>233</td>
<td>195</td>
<td>197.06</td>
<td>9.28</td>
<td>0.0110</td>
</tr><tr>
<td>4</td>
<td>1024</td>
<td>100</td>
<td>179</td>
<td>291</td>
<td>199</td>
<td>204.72</td>
<td>18.04</td>
<td>0.0215</td>
</tr><tr>
<td>2</td>
<td>1024</td>
<td>100</td>
<td>183</td>
<td>358</td>
<td>200.5</td>
<td>207.17</td>
<td>23.89</td>
<td>0.0352</td>
</tr><tr>
<td>1</td>
<td>1024</td>
<td>100</td>
<td>186</td>
<td>277</td>
<td>201</td>
<td>207.15</td>
<td>17.93</td>
<td>0.0176</td>
</tr><tr>
<td>16</td>
<td>2048</td>
<td>100</td>
<td>186</td>
<td>264</td>
<td>207.5</td>
<td>214.24</td>
<td>20.52</td>
<td>0.0098</td>
</tr><tr>
<td>8</td>
<td>2048</td>
<td>100</td>
<td>190</td>
<td>407</td>
<td>208.5</td>
<td>219.19</td>
<td>33.42</td>
<td>0.0300</td>
</tr><tr>
<td>4</td>
<td>2048</td>
<td>100</td>
<td>186</td>
<td>1032</td>
<td>208.5</td>
<td>225.87</td>
<td>91.54</td>
<td>0.0771</td>
</tr><tr>
<td>2</td>
<td>2048</td>
<td>100</td>
<td>192</td>
<td>577</td>
<td>209</td>
<td>220.67</td>
<td>41.67</td>
<td>0.0658</td>
</tr><tr>
<td>1</td>
<td>2048</td>
<td>100</td>
<td>186</td>
<td>315</td>
<td>209</td>
<td>217.98</td>
<td>24.24</td>
<td>0.0138</td>
</tr></tbody>
</table>
### Summary and сonclusions
The table provides the results of a test conducted on a wide area network (WAN) hosted on replit.com, examining various frequencies and request sizes. Here's a summary and analysis of the findings:
- **Frequency (Hz)**: Ranged from 1 Hz to 16 Hz, indicating the rate at which requests were sent to the server.
- **Request Size**: Varied from 128 bytes to 2048 bytes, representing the size of each request sent.
- **Total Requests**: Consisted of 100 requests for each combination of frequency and request size.
#### Observations:
- **RTT Metrics**:
- **Min RTT (ms)**: Ranged from 164 ms to 200 ms, indicating the shortest round-trip time observed.
- **Max RTT (ms)**: Spanned from 233 ms to 1032 ms, representing the longest round-trip time observed.
- **Median RTT (ms)**: Varied between 193 ms and 213 ms, reflecting the middle value of the round-trip time distribution.
- **Avg RTT (ms)**: Ranged from 197 ms to 220.67 ms, representing the average round-trip time observed.
- **STD RTT (ms)**: Showcased standard deviations ranging from 9.28 ms to 91.54 ms, indicating the spread of round-trip times around the mean.
- **Skewness Ratio**: Spanned from 0.0098 to 0.0771, reflecting the symmetry or asymmetry of the round-trip time distribution.
#### Conclusions:
- **Impact of Frequency**: Higher frequencies generally resulted in shorter round-trip times, as evidenced by the decreasing trend in average and median RTT with increasing frequency.
- **Effect of Request Size**: Larger request sizes tended to lead to longer round-trip times, possibly due to increased processing overhead or network congestion, although the impact was less pronounced compared to the PAN.
- **RTT Distribution**: The skewness ratio provided insights into the shape of the RTT distribution, with values closer to zero indicating a more symmetric distribution. However, compared to the PAN, the WAN exhibited slightly higher skewness ratios, suggesting a more pronounced asymmetry in the distribution.
- **Optimization Opportunities**: Based on the observed metrics, optimizations such as fine-tuning the request size or adjusting the frequency can be explored to improve overall system performance and reduce latency, especially in the context of wide area networks where factors like network congestion and packet loss may have a more significant impact.
## Comparison of Results between Personal Area Network (PAN) and Wide Area Network (WAN)
#### Round-Trip Time (RTT) Metrics:
- **Minimum RTT (ms)**:
- Ranged from 1 ms to 2 ms
- Ranged from 164 ms to 200 ms, indicating the shortest round-trip time observed.
- **Observation**: PAN generally exhibits significantly shorter minimum RTT compared to WAN.
- **Maximum RTT (ms)**:
- PAN: Spanned from 8 ms to 90 ms
- WAN: Spanned from 233 ms to 1032 ms
- **Observation**: WAN generally experiences higher maximum RTT compared to PAN.
- **Median RTT (ms)**:
- PAN: Varied between 6 ms and 8 ms
- WAN: Varied between 183 ms and 195 ms.
- **Observation**: PAN generally demonstrates shorter median RTT compared to WAN.
- **Average RTT (ms)**:
- PAN: Ranged from 6 ms to 13.3 ms
- WAN: Ranged from 197 ms to 220.67 ms
- **Observation**: PAN generally yields lower average RTT compared to WAN.
- **Standard Deviation (STD) RTT (ms)**:
- PAN: Ranging from 1.4 ms to 22.2 ms,
- WAN: Ranging from 9.28 ms to 91.54 ms
- **Observation**: PAN generally exhibits lower variability in RTT compared to WAN.
- **Skewness Ratio**:
- PAN: Spanned from -0.0095 to 0.0571
- WAN: Spanned from 0.0098 to 0.0771
- **Observation**: PAN generally demonstrates slightly lower skewness ratios compared to WAN, indicating a more symmetric distribution of RTT.
#### General Observations:
- **Impact of Network Type**: PAN typically offers lower latency and more consistent performance compared to WAN, as it operates within a smaller, more controlled environment.
- **Variability**: WAN experiences higher variability in RTT metrics, likely due to factors such as network congestion, packet loss, and longer physical distances between nodes.
- **Optimization Opportunities**: While PAN may require less optimization due to its inherently stable environment, WAN performance can benefit significantly from optimizations targeting network efficiency, congestion management, and protocol enhancements.
## Comparison of the obtained data with the data of the [system network utility ping](https://2ip.ua/ru/services/ip-service/ping-traceroute)
### Results of the ping commad:
```
[anonymous@2ip ~]$ ping -c 10 https://3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev/
PING 3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev (34.75.151.117): 56 data bytes
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=0 ttl=57 time=96.900 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=1 ttl=57 time=96.700 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=2 ttl=57 time=96.900 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=3 ttl=57 time=97.200 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=4 ttl=57 time=97.000 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=5 ttl=57 time=97.100 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=6 ttl=57 time=96.900 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=7 ttl=57 time=97.100 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=8 ttl=57 time=96.800 ms
64 bytes from 117.151.75.34.bc.googleusercontent (34.75.151.117): icmp_seq=9 ttl=57 time=97.000 ms
--- 3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev ping statistics ---
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 96.700/96.960/97.200/0.143 ms
```
Let's look at the locations of 2ip.ua and [replit](https://3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev)
<table class="table">
<tbody>
<tr>
<td>Domain:</td>
<td>2ip.ua</td>
<td>3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev</td>
</tr>
<tr>
<td>Country:</td>
<td>Netherlands</td>
<td>United States Of America</td>
</tr>
<tr>
<td>Region:</td>
<td>Noord-holland</td>
<td>California</td>
</tr>
<tr>
<td>City:</td>
<td>Amsterdam</td>
<td>Mountain View</td>
</tr>
<tr>
<td>Latitude:</td>
<td>52.37403</td>
<td>37.405992</td>
</tr>
<tr>
<td>Longitude:</td>
<td>4.88969</td>
<td>-122.078515</td>
</tbody>
</table>
Distance between site 2ip.ua and [replit](https://3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev) is:
<table>
<tbody>
<tr>
<td>Meters</td>
<td>8793041.02</td>
</tr>
<tr>
<td>Kilometers</td>
<td>8793.04</td>
</tr>
<tr>
<td>Miles</td>
<td>5463.74</td>
</tr>
</tbody>
</table>
And now let's see at my current location and [replit](https://3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev):
<table class="table">
<tbody>
<tr>
<td>Domain:</td>
<td>78.26.151.209</td>
<td>3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev</td>
</tr>
<tr>
<td>Country:</td>
<td>Ukraine</td>
<td>United States Of America</td>
</tr>
<tr>
<td>Region:</td>
<td>Odeska Oblast</td>
<td>California</td>
</tr>
<tr>
<td>City:</td>
<td>Odessa</td>
<td>Mountain View</td>
</tr>
<tr>
<td>Latitude:</td>
<td>46.477274</td>
<td>37.405992</td>
</tr>
<tr>
<td>Longitude:</td>
<td>30.732597</td>
<td>-122.078515</td>
</tbody>
</table>
Distance between me and [replit](https://3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev) is:
<table class="table table-striped">
<tbody>
<tr>
<td>Meters</td>
<td>10301421.39</td>
</tr>
<tr>
<td>Kilometers</td>
<td>10301.42</td>
</tr>
<tr>
<td>Miles</td>
<td>6401.01</td>
</tr>
</tbody>
</table>
```
natanius@od-mobile-136:~$ ping -c 10 3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev
PING 3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev (34.75.151.117) 56(84) bytes of data.
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=1 ttl=105 time=138 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=2 ttl=105 time=137 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=3 ttl=105 time=138 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=4 ttl=105 time=140 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=5 ttl=105 time=138 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=6 ttl=105 time=137 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=7 ttl=105 time=137 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=8 ttl=105 time=140 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=9 ttl=105 time=137 ms
64 bytes from 117.151.75.34.bc.googleusercontent.com (34.75.151.117): icmp_seq=10 ttl=105 time=137 ms
--- 3eb92c6b-e84c-4e44-9407-35dce7c43ad4-00-2607akwr7pdd6.worf.replit.dev ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9019ms
rtt min/avg/max/mdev = 136.538/137.910/140.316/1.154 ms
```
## Speed of the signal
The speed of the signal is determined by the speed of light in the medium through which the signal is being transmitted. The speed of light in a vacuum is approximately 299,792,458 meters per second (m/s). However, in most cases, signals are transmitted through cables or other mediums, which have a lower speed of light.
In the case of a digital signal being transmitted over a coaxial cable, the speed of the signal is approximately 2/3 the speed of light in the medium (coaxial cable). This is because the signal is transmitted as an electromagnetic wave, and the wave travels at 2/3 the speed of light in the medium.
For example, if the signal is being transmitted over a coaxial cable, the speed of the signal would be approximately $\frac{2}{3} \times 299,792,458 \, \text{m/s} = 199,854,742.67 \, \text{m/s} = 199 \, \text{km/ms}$.
However, the actual speed of the signal may vary depending on the specific medium and signal type.
With this speed, a signal would cover a distance of 199 km in 1 millisecond. Therefore, in 96 milliseconds, the signal would travel a distance of $96 \, \text{ms} \times 199 \, \text{km/ms} = 19,104 \, \text{km}$
and in 137 milliseconds the signal would travel a distance of $137 \, \text{ms} \times 199 \, \text{km/ms} = 27,263 \, \text{km}$
## Conclusions
So, an RTT of 96 ms indicates that the signal has traveled approximately 19,104 kilometers round trip between the source and the destination. This means the distance between servers is twice smaller: 9552 km.
Pretty accurate if we compare it with the data from 2ip.ua (8793 km).
In case of local ping to repl.it the distance is 27,263/2=13631.5
According to the data from 2ip.ua the distance between me and server repl.it(10301.42 km).
The speed of a signal in a local network looks very slow, it can be due to several reasons, such as network congestion, low-quality cables, or outdated network devices. However, in the context of this work, it seems that the delay is specifically related to signal processing on the server.
There are several possible reasons for delay in signal processing on the server:
* Inefficient code: If the code that processes the signal is not optimized, it may take longer to execute, leading to delays (for example POST method delays).
* Hardware limitations: If the server's hardware is not powerful enough to handle the processing demands, it may cause delays.
* Network issues: Even though the network itself may not be the cause of the delay, network issues between the client and the server can still cause delays in signal processing.
* Software bugs: Software bugs in the server software or the code that processes the signal can cause delays or even prevent the signal from being processed altogether.