<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-2">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>V implementacich TCP je, ze po x us/ms nebo zaplneni bufferu se
odesle packet. Nevola se explicitne tcp_output, to si zajistti ta
nizsi vrstva sama. Mozna Vam v tom lwpi neco chybi, nejake
pravidelne volani obsluhy ethernetu. Rozhodne by se ethernet mel
obslouzit vicekrat nez vola ten Vas sw, pote to spatne dopadne asi
nejspis jak pisete. Mozna to lwpi neovlada prijeti vice packetu
najednou, ktere jdou mimo poradi a tim je nizsi rychlost, to
nevim. <br>
</p>
<p>Jirka<br>
</p>
<pre class="moz-signature" cols="72">
</pre>
<div class="moz-cite-prefix">Dne 07.10.2017 v 14:25 Jaroslav Buchta
napsal(a):<br>
</div>
<blockquote type="cite"
cite="mid:dbd8ef8d-170c-37b8-212d-22bb398b2c92@hascomp.cz">
<meta http-equiv="Context-Type" content="text/html;
charset=iso-8859-2">
<div class="moz-cite-prefix">Tak zpet, to ani tak klicove neni,
dulezitejsi je zavolat tcp_output(pcb), bez toho to posle az po
nejakem timeoutu, i kdyz jsou plne buffery<br>
<br>
Co je horsi, je stabilita, pokud posilam data max. rychlosti,
dojde po case k zacykleni, coz me trosku znervoznuje... Proto
ten delay.<br>
<br>
Jeste jsem zmenil princip cekani na pakety v
ethernetif.c/ethernetif_input, je tam binarni semafor, tak kdyz
to nestihne oblouzit do prichodu dalsiho paketu, ztrati se
informace a pakety se zacnou "courat" zpozdene. Zmenil jsem ho
na pocitaci a pocet bufferu zvetsil ze 4 -> 8<br>
<br>
Ma nekdo nejake hlubsi zkusenosti jak to dal stabilizovat? <br>
<br>
<br>
Nejstabilnejsi vysledky dava tento program ale stejne se dosahne
jenom cca 500kB/s: (s optimalizovanym prekladem 1MB pokud delay
zmensim na 1ms, ale Yield nestaci a stejne se to po cca 300MB
sekne...)<br>
<br>
if (connCount != 0)<br>
{<br>
uint16_t n = tcp_sndbuf(pcbAccepted);<br>
if (n == 0)<br>
{<br>
osDelay(3);<br>
}<br>
else<br>
{<br>
if (n > sizeof(bufSend)) n = sizeof(bufSend);<br>
err_t e = tcp_write(pcbAccepted, bufSend, n,
TCP_WRITE_FLAG_MORE); //TCP_WRITE_FLAG_MORE);<br>
if (e == ERR_OK)<br>
{<br>
tcp_output(pcbAccepted);<br>
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin,
GPIO_PIN_SET);<br>
}<br>
else<br>
{<br>
//Error_Handler();<br>
}<br>
}<br>
}<br>
<br>
<br>
<br>
Dne 07.10.2017 v 11:50 Jaroslav Buchta napsal(a):<br>
</div>
<blockquote type="cite"
cite="mid:90c8c6be-4382-8a64-652e-d604258bdaee@hascomp.cz">
<div class="moz-cite-prefix">Tak jsem zjistil, ze klicove je
pouzit<br>
tcp_nagle_disable(pcb);<br>
Nyni to zase zdrzuje PC nez odpovi ACK, jdu zkoumat dal...<br>
<br>
Dne 07.10.2017 v 11:31 Jaroslav Buchta napsal(a):<br>
</div>
<blockquote type="cite"
cite="mid:573b179a-ec92-e34b-df7a-6c12ec60f3b2@hascomp.cz">Zdravim,
<br>
<br>
mam problem s implementaci subj, pouziva HAL, vse
nakonfigurovano pokusne v prazdnem projektu. <br>
<br>
Aplikace pouze odesila data po pripojeni klienta, prenosova
rychlost je zoufala, asi 1kB/s.... Netusi nekdo, v cem muze
byt problem? Asi malo nejakych bufferu? Ale experimenty nikam
nevedly. <br>
<br>
Pres switch to chodi asi 3x rychleji nez primo pripojene k PC,
asi to servisni komunikace nejak zahlti? Nebo delam neco
spatne? <br>
<br>
Sledovana komunikace ale vypada plynula bez komplikaci, .123
je PC, .9 STM, viz priloha <br>
<br>
<br>
Vypis dulezite casti programu: <br>
<br>
/* USER CODE BEGIN 4 */ <br>
static err_t echo_accept(void *arg, struct tcp_pcb *pcb, err_t
err); <br>
static err_t echo_recvd(void * arg, struct tcp_pcb * tpcb,
struct pbuf * p, err_t err); <br>
static err_t echo_sent(void * arg, struct tcp_pcb * tpcb,
u16_t len); <br>
static void echo_err(void * arg, err_t err); <br>
<br>
static struct tcp_pcb *pcbListened = NULL; <br>
static struct tcp_pcb *pcbAccepted = NULL; <br>
static int connCount; <br>
static osSemaphoreId transferSemphHandle = NULL; <br>
<br>
static err_t echo_accept(void *arg, struct tcp_pcb *pcb, err_t
err) <br>
{ <br>
LWIP_UNUSED_ARG(arg); <br>
LWIP_UNUSED_ARG(err); <br>
if (pcbListened == NULL) return ERR_ARG; <br>
if (connCount >= 1) <br>
{ <br>
tcp_abort(pcb); <br>
return ERR_ABRT; <br>
} <br>
connCount++; <br>
tcp_arg(pcb, NULL); <br>
tcp_recv(pcb, echo_recvd); <br>
tcp_sent(pcb, echo_sent); <br>
tcp_err(pcb, echo_err); <br>
// tcp_setprio(pcb, TCP_PRIO_MIN); <br>
tcp_accepted(pcbListened); <br>
pcbAccepted = pcb; <br>
return ERR_OK; <br>
} <br>
<br>
<br>
static err_t echo_recvd(void * arg, struct tcp_pcb * tpcb,
struct pbuf * p, err_t err) <br>
{ <br>
if (p == NULL) <br>
{ // EOF signal, connection closed <br>
tcp_close(tpcb); <br>
pcbAccepted = NULL; <br>
connCount--; <br>
if (arg != NULL) <br>
{ <br>
// mbsDescFree((MBS_Descriptor *)arg);
<br>
} <br>
} <br>
else <br>
{ <br>
tcp_recved(tpcb, p->tot_len); <br>
// DBGUSART_Format("MBS-> Received %08x, %d
B"DBGSTRNL, (uint32_t)tpcb, p->tot_len); <br>
uint8_t *pd = (uint8_t *)p->payload; <br>
uint16_t len = p->len; <br>
uint8_t exc = 0; <br>
<br>
if (p != NULL) pbuf_free(p); <br>
} <br>
return ERR_OK; <br>
} <br>
<br>
uint8_t bufSend[1024]; <br>
uint8_t sendPcs = 0; <br>
<br>
static err_t echo_sent(void * arg, struct tcp_pcb * tpcb,
u16_t len) <br>
{ <br>
osSemaphoreRelease(transferSemphHandle); <br>
//TerminalFormatNl("MBS-> Sent %08x, %d B",
(uint32_t)tpcb, (uint32_t)len); <br>
//osMutexRelease(transferMutexHandle); <br>
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_RESET);
<br>
return ERR_OK; <br>
} <br>
<br>
static void echo_err(void * arg, err_t err) <br>
{ <br>
<br>
} <br>
<br>
<br>
<br>
/* USER CODE END 4 */ <br>
<br>
/* StartDefaultTask function */ <br>
void StartDefaultTask(void const * argument) <br>
{ <br>
/* init code for LWIP */ <br>
MX_LWIP_Init(); <br>
<br>
/* USER CODE BEGIN 5 */ <br>
osSemaphoreDef(transferSemph); <br>
transferSemphHandle =
osSemaphoreCreate(osSemaphore(transferSemph), 1); <br>
<br>
struct tcp_pcb *pcb = tcp_new(); <br>
if (pcb == NULL) Error_Handler(); <br>
err_t err = tcp_bind(pcb, IP_ADDR_ANY, 52222); <br>
if (err != ERR_OK) Error_Handler(); <br>
pcb = tcp_listen(pcb); <br>
if (pcb == NULL) Error_Handler(); <br>
tcp_accept(pcb, echo_accept); <br>
pcbListened = pcb; <br>
<br>
uint32_t tckLed = 0; <br>
<br>
/* Infinite loop */ <br>
for(;;) <br>
{ <br>
uint32_t tck = osKernelSysTick(); <br>
if (tck-tckLed>250) <br>
{ <br>
tckLed = tck; <br>
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin); <br>
} <br>
osSemaphoreWait(transferSemphHandle, 50); <br>
if (connCount != 0) <br>
{ <br>
err_t e = tcp_write(pcbAccepted, bufSend,
sizeof(bufSend), TCP_WRITE_FLAG_MORE); <br>
if (e == ERR_OK) <br>
{ <br>
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin,
GPIO_PIN_SET); <br>
} <br>
else <br>
{ <br>
<br>
} <br>
} <br>
} <br>
/* USER CODE END 5 */ <br>
} <br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
HW-list mailing list - sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz" moz-do-not-send="true">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz" moz-do-not-send="true">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
</blockquote>
<p><br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
HW-list mailing list - sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz" moz-do-not-send="true">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz" moz-do-not-send="true">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
</blockquote>
<p><br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
HW-list mailing list - sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
</blockquote>
<br>
</body>
</html>