Hola Habr! En este artículo, quiero hablar sobre resolver uno de los problemas comunes que Embox maneja mejor que GNU / Linux. Este es el tiempo de respuesta a un paquete transmitido a través del protocolo Ethernet. Como saben, la característica principal de la transmisión de datos a través de una red es el ancho de banda, y GNU / Linux lo está haciendo bien. Pero cuando se trata de reducir el tiempo que lleva recibir / transmitir un solo paquete de red, pueden surgir problemas. En particular, el cliente tenía una placa DE0-Nano-SoC con Linux, y con la ayuda de esta placa quería controlar cierto objeto a través de la red. La topología de la red es punto a punto, no hay enrutadores ni concentradores. Según el modelo de control, el tiempo de reacción debe ser inferior a 100 μs, y en Linux solo se pueden lograr 500 μs.

Para estimar el tiempo de transmisión, creamos un stand que consta de dos hosts.
GNU/Linux, — DE0-Nano-SoC Kit Embox. FPGA HPS (Hard Processing System, .. ARM), . , UDP- :
while (1) {
char buf[BUFLEN];
recvfrom(s, buf, BUFLEN);
sendto(s, buf, BUFLEN);
}
, DE0-Nano-SoC.
, :
for (int i = 0; i < N; i++) {
char buf_tx[BUFLEN], buf_rx[BUFLEN];
sprintf(buf_tx, "This is packet %d\n", i);
time_t time_begin = time_now();
sendto(s, buf_tx, BUFLEN);
recvfrom(s, buf_rx, BUFLEN);
time_t time_end = time_now();
if (memcmp(buf_tx, buf_rx, sizeof(buf))) {
printf("%d: Buffer mismatch\n", i);
}
if (time_end - time_begin > TIME_LIMIT) {
printf("Slow answer #%d: %d\n", i, time_end - time_begin);
}
}
, .
Github.
, , :
500 000 ( ) :
Avg: 4.52ms
Min: 3.12ms
Max: 12.24ms
, , — . , Linux . , .
, ? , .
, - , , ? — .
, ethernet- — USB-, 100/, .
1 :
Avg: 0.08ms
Min: 0.07ms
Max: 4.31ms
Linux
Linux. -: arm-linux-gnueabihf-gcc server.c -O2
. ELF :
Avg: 0.77ms
Min: 0.74ms
Max: 5.31ms
, Embox "" 9 , !
, "", , .
, , , UDP- .
, UDP-.
, UDP . , . . :
int net_tx(...) {
if (is_udp_packet()) {
timestamp2 = timer_get();
memcpy(packet[UDP_OFFT],
×tamp1,
sizeof(timestamp1));
memcpy(packet[UDP_OFFT + sizeof(timestamp2)],
×tamp2,
sizeof(timestamp2));
...
}
}
, , , Embox.
Avg: 8673
Min: 6191
Max: 11950
, ( ) 25%, (Avg: 0.08ms Max: 4.31ms). ( , , , ), . , , 25%.
, ?
— Linux, .
?
, — :
nice -n -20 ./client
— , , .
— round robin , chrt
:
chrt --rr 99 ./client
— . ( , .. ).

Embox , 10 . , , . , Linux, - bpfilter.
- — embox-devel@googlegroups.com, -, .