Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-05 Thread Sergio R. Caprile
Yes, "ethernetif" is sort of the generic name used in the skeleton,
internals for a netif belong to the developer (that's the reason for my
'driveroutputfunction' comment on that line).
Well, if I'm not missing something important, it looks like you have a
problem on the driver/wire side. Try to find a good old Ethernet hub or
a modern switch with monitor capabilities to sniff what is going on in
the wire, if anything.

PS: Yes, I do have a couple spare hubs I did save for this reason...


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-05 Thread Inderjit Singh
Yeah, the procedure is exactly as you descript with address setting, netifadd, 
etc...

IP4_ADDR(, 192, 168, 100, 250);
IP4_ADDR(, 255, 255, 255, 0);
IP4_ADDR(, 192, 168, 100, 1);
if (NULL == netif_add(_netif, , , , NULL,
ethernetif_init, ethernet_input)) {
LWIP_ASSERT("NULL == netif_add", 0);
}

netif_set_default(_netif);
netif_set_status_callback(_netif, eth_cb_netif_status);
netif_set_up(_netif);

And both output low level functions are being called (catched by breakpoint). I 
presume you do mean (in my case):
ethernetif_output() -> etharp_output
ethernetif_linkoutput -> gmac_low_level_output
as they are set in netif:
netif->output = etharp_output;
netif->linkoutput = gmac_low_level_output;



From: lwip-users [lwip-users-bounces+inderjit.singh=evidente...@nongnu.org] on 
behalf of Sergio R. Caprile [scapr...@gmail.com]
Sent: 04 June 2018 18:18
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] tcp_connection (no SYN packet on server side)

OK, so it seems you are correctly calling lwIP in the loop, and your
networking parameters look good.
However, I failed to ask how do you setup your netif. You don't tell.
You should do something like this before actually calling tcp_connect():

IP4_ADDR(, 192,168,100,1);
IP4_ADDR(, 192,168,100,250);
IP4_ADDR(, 255,255,255,0);

lwip_init();
netif_add(, , , , perhaps NULL,
ethernetif_init, ethernet_input);
netif_set_default();

Where your ethernetif_init() will properly init stuff...
netif->output = etharp_output;
netif->linkoutput = ethernetif_linkoutput;//driveroutputfunction

Can you fire a breakpoint at your ethernetif_output() and
ethernetif_linkoutput?

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Sergio R. Caprile
OK, so it seems you are correctly calling lwIP in the loop, and your
networking parameters look good.
However, I failed to ask how do you setup your netif. You don't tell.
You should do something like this before actually calling tcp_connect():

  IP4_ADDR(, 192,168,100,1);
  IP4_ADDR(, 192,168,100,250);
  IP4_ADDR(, 255,255,255,0);

  lwip_init();
  netif_add(, , , , perhaps NULL,
ethernetif_init, ethernet_input);
  netif_set_default();

Where your ethernetif_init() will properly init stuff...
netif->output = etharp_output;
netif->linkoutput = ethernetif_linkoutput;//driveroutputfunction

Can you fire a breakpoint at your ethernetif_output() and
ethernetif_linkoutput?

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Inderjit Singh
OK. i'll try that.


..
Inderjit Singh Senior Embedded Engineer, MSc

Evidente ES East AB
Warfvinges väg 34 SE-112 51 Stockholm Sweden

Mobile:  +46 (0)70 912 42 69
E-mail:   inderjit.si...@evidente.se<mailto:inderjit.si...@evidente.se>

<http://www.evidente.se/>
www.evidente.se<http://www.evidente.se/>

From: lwip-users [lwip-users-bounces+inderjit.singh=evidente...@nongnu.org] on 
behalf of Sarp Daltaban [sarpdalta...@gmail.com]
Sent: 04 June 2018 16:16
To: Mailing list for lwIP users
Subject: Re: [lwip-users] tcp_connection (no SYN packet on server side)

Do not delay, or make it lower as 3-5 ms.

2018-06-04 16:50 GMT+03:00 Inderjit Singh 
mailto:inderjit.si...@evidente.se>>:
Hi Sergio, thanks for the reply!

Bind I can remove, fair enough.

IP addressing is client (this development side):
   ip: 192.168.100.120
   netmask: 255.255.255.0
   gw: 192.168.100.1

The server (raspberry pi without any implementation, just monitoring packets)
   ip: 192.168.100.155
   netmask: 255.255.255.0
   gw: 192.168.100.1

Setting goes trough without any error (I have put assert after every setting)

The main loop is this:

while (1) {
udp_cb_called = tcp_cb_called = false;

IP4_ADDR(, ETH_CONF_IPADDR0, ETH_CONF_IPADDR1, ETH_CONF_IPADDR2, 155);
err = tcp_connect(pcb_tcp, , ETH_TCP_PORT_REM, tcp_connected_cb);
if (err != 0) {
LWIP_ASSERT("err != 0", 0);
}

while(udp_cb_called == false && tcp_cb_called == false) {
ethernetif_input(_netif);
sys_check_timeouts();
delay_ms(100);
}
}

Once the callback is called, I set the flags to true to redo the connect. Note, 
this is just for testing not for any other purpose. Once I can see SYN packet 
then I know I can start implementing properly...

..
Inderjit Singh Senior Embedded Engineer, MSc

Evidente ES East AB
Warfvinges väg 34 SE-112 51 Stockholm Sweden

Mobile: +46 (0)70 912 42 69
E-mail: inderjit.si...@evidente.se<mailto:inderjit.si...@evidente.se>

www.evidente.se<http://www.evidente.se>


From: lwip-users 
[lwip-users-bounces+inderjit.singh=evidente...@nongnu.org<mailto:evidente...@nongnu.org>]
 on behalf of Sergio R. Caprile [scapr...@gmail.com<mailto:scapr...@gmail.com>]
Sent: 04 June 2018 14:59
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: Re: [lwip-users] tcp_connection (no SYN packet on server side)


No need to bind(), you are a client, you connect().
What is the value returned by tcp_connect() ? It should be ERR_OK
What do you do after that ? Do you properly call sys_check_timeouts() on
the main loop or you just sit waiting things to magically happen ?
TCP is a state machine, you just instructed it to start a several steps
process.

PS: I assume your IP addressing is fine...


___
lwip-users mailing list
lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
https://lists.nongnu.org/mailman/listinfo/lwip-users

___
lwip-users mailing list
lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
https://lists.nongnu.org/mailman/listinfo/lwip-users

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Inderjit Singh
delay_ms is used throughout our bare metal implementation I can guarantee it's 
not blocking.
tcp_cb_called is called to the registered callback function yes. And sure, main 
loop as you suggest is functional as well yes. 
However I fail see why LWIP layer marks SYN_SENT state in pcb but I cannot see 
the packet's being transmitted/received on the datalink itself? LWIP doesn't 
signal any failures has been made during the process except the abort at error 
callback when the timeout is reached. 


From: lwip-users [lwip-users-bounces+inderjit.singh=evidente...@nongnu.org] on 
behalf of Sergio R. Caprile [scapr...@gmail.com]
Sent: 04 June 2018 16:58
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] tcp_connection (no SYN packet on server side)

That may or may not work depending on what your _magic function_
"delay_ms" does. If it is blocking, you are busted.

A main loop is a main loop, you need to rx and you need to check
timeouts. Your accept callback will be called after the SYN is SYNACKed
and the SYNACK is ACKed back. For that, you need to have the stack
running, otherwise no one can send anything, and that is done by calling
sys_check_timeouts() as frequently as you can. And you need to rx for
the SYNACK, which is done by calling ethernetif_input() frequently
enough in order not to lose frames. That can't happen if you are blocking.

If you really want to sequentially check for whatever reason, you can do
this:

udp_cb_called = tcp_cb_called = false;

IP4_ADDR(, ETH_CONF_IPADDR0, ETH_CONF_IPADDR1, ETH_CONF_IPADDR2, 155);
err = tcp_connect(pcb_tcp, , ETH_TCP_PORT_REM, tcp_connected_cb);
if (err != ERR_OK) {
// Oops
}

while(udp_cb_called == false && tcp_cb_called == false) {
ethernetif_input(_netif);
sys_check_timeouts();
}

Your second attempt to call connect will fail as your pcb is being used,
so that won't work inside a loop (and a bit involved to explain in one
line). And I guess you'll set tcp_cb_called to "true" somewhere in your
tcp_connected_cb()

However, that is not much different from a real main loop:

while(1) {
ethernetif_input(_netif);
if(whatiamexpectinghashappened)
; // bingo!
sys_check_timeouts();
world_save();
stuff_do();
morestuff_moredo();
}


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Sergio R. Caprile
That may or may not work depending on what your _magic function_
"delay_ms" does. If it is blocking, you are busted.

A main loop is a main loop, you need to rx and you need to check
timeouts. Your accept callback will be called after the SYN is SYNACKed
and the SYNACK is ACKed back. For that, you need to have the stack
running, otherwise no one can send anything, and that is done by calling
sys_check_timeouts() as frequently as you can. And you need to rx for
the SYNACK, which is done by calling ethernetif_input() frequently
enough in order not to lose frames. That can't happen if you are blocking.

If you really want to sequentially check for whatever reason, you can do
this:

udp_cb_called = tcp_cb_called = false;

IP4_ADDR(, ETH_CONF_IPADDR0, ETH_CONF_IPADDR1, ETH_CONF_IPADDR2, 155);
err = tcp_connect(pcb_tcp, , ETH_TCP_PORT_REM, tcp_connected_cb);
if (err != ERR_OK) {
// Oops
}

while(udp_cb_called == false && tcp_cb_called == false) {
ethernetif_input(_netif);
sys_check_timeouts();
}

Your second attempt to call connect will fail as your pcb is being used,
so that won't work inside a loop (and a bit involved to explain in one
line). And I guess you'll set tcp_cb_called to "true" somewhere in your
tcp_connected_cb()

However, that is not much different from a real main loop:

while(1) {
ethernetif_input(_netif);
if(whatiamexpectinghashappened)
; // bingo!
sys_check_timeouts();
world_save();
stuff_do();
morestuff_moredo();
}


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Sarp Daltaban
Do not delay, or make it lower as 3-5 ms.

2018-06-04 16:50 GMT+03:00 Inderjit Singh :

> Hi Sergio, thanks for the reply!
>
> Bind I can remove, fair enough.
>
> IP addressing is client (this development side):
>ip: 192.168.100.120
>netmask: 255.255.255.0
>gw: 192.168.100.1
>
> The server (raspberry pi without any implementation, just monitoring
> packets)
>ip: 192.168.100.155
>netmask: 255.255.255.0
>gw: 192.168.100.1
>
> Setting goes trough without any error (I have put assert after every
> setting)
>
> The main loop is this:
>
> while (1) {
>
> udp_cb_called = tcp_cb_called = false;
>
> IP4_ADDR(, ETH_CONF_IPADDR0, ETH_CONF_IPADDR1, ETH_CONF_IPADDR2, 155);
> err = tcp_connect(pcb_tcp, , ETH_TCP_PORT_REM, tcp_connected_cb);
> if (err != 0) {
> LWIP_ASSERT("err != 0", 0);
> }
>
> while(udp_cb_called == false && tcp_cb_called == false) {
> ethernetif_input(_netif);
> sys_check_timeouts();
> delay_ms(100);
> }
>
> }
>
> Once the callback is called, I set the flags to true to redo the connect.
> Note, this is just for testing not for any other purpose. Once I can see
> SYN packet then I know I can start implementing properly...
>
> 
> ..
> Inderjit Singh Senior Embedded Engineer, MSc
>
> Evidente ES East AB
> Warfvinges väg 34 SE-112 51 Stockholm Sweden
>
> Mobile: +46 (0)70 912 42 69
> E-mail: inderjit.si...@evidente.se
>
> www.evidente.se
>
> 
> From: lwip-users [lwip-users-bounces+inderjit.singh=evidente...@nongnu.org]
> on behalf of Sergio R. Caprile [scapr...@gmail.com]
> Sent: 04 June 2018 14:59
> To: lwip-users@nongnu.org
> Subject: Re: [lwip-users] tcp_connection (no SYN packet on server side)
>
>
> No need to bind(), you are a client, you connect().
> What is the value returned by tcp_connect() ? It should be ERR_OK
> What do you do after that ? Do you properly call sys_check_timeouts() on
> the main loop or you just sit waiting things to magically happen ?
> TCP is a state machine, you just instructed it to start a several steps
> process.
>
> PS: I assume your IP addressing is fine...
>
>
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Inderjit Singh
Hi Sergio, thanks for the reply!

Bind I can remove, fair enough.

IP addressing is client (this development side):
   ip: 192.168.100.120
   netmask: 255.255.255.0
   gw: 192.168.100.1

The server (raspberry pi without any implementation, just monitoring packets)
   ip: 192.168.100.155
   netmask: 255.255.255.0
   gw: 192.168.100.1

Setting goes trough without any error (I have put assert after every setting)

The main loop is this:

while (1) {
udp_cb_called = tcp_cb_called = false;

IP4_ADDR(, ETH_CONF_IPADDR0, ETH_CONF_IPADDR1, ETH_CONF_IPADDR2, 155);
err = tcp_connect(pcb_tcp, , ETH_TCP_PORT_REM, tcp_connected_cb);
if (err != 0) {
LWIP_ASSERT("err != 0", 0);
}

while(udp_cb_called == false && tcp_cb_called == false) {
ethernetif_input(_netif);
sys_check_timeouts();
delay_ms(100);
}
}

Once the callback is called, I set the flags to true to redo the connect. Note, 
this is just for testing not for any other purpose. Once I can see SYN packet 
then I know I can start implementing properly...

..
Inderjit Singh Senior Embedded Engineer, MSc

Evidente ES East AB
Warfvinges väg 34 SE-112 51 Stockholm Sweden

Mobile: +46 (0)70 912 42 69
E-mail: inderjit.si...@evidente.se

www.evidente.se


From: lwip-users [lwip-users-bounces+inderjit.singh=evidente...@nongnu.org] on 
behalf of Sergio R. Caprile [scapr...@gmail.com]
Sent: 04 June 2018 14:59
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] tcp_connection (no SYN packet on server side)

No need to bind(), you are a client, you connect().
What is the value returned by tcp_connect() ? It should be ERR_OK
What do you do after that ? Do you properly call sys_check_timeouts() on
the main loop or you just sit waiting things to magically happen ?
TCP is a state machine, you just instructed it to start a several steps
process.

PS: I assume your IP addressing is fine...


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Sarp Daltaban
What if we are using FreeRTOS? I mean, what if NO_SYS = 0, we cannot
call sys_check_timeouts(),
what should we do then?

2018-06-04 15:59 GMT+03:00 Sergio R. Caprile :

> No need to bind(), you are a client, you connect().
> What is the value returned by tcp_connect() ? It should be ERR_OK
> What do you do after that ? Do you properly call sys_check_timeouts() on
> the main loop or you just sit waiting things to magically happen ?
> TCP is a state machine, you just instructed it to start a several steps
> process.
>
> PS: I assume your IP addressing is fine...
>
>
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] tcp_connection (no SYN packet on server side)

2018-06-04 Thread Sergio R. Caprile
No need to bind(), you are a client, you connect().
What is the value returned by tcp_connect() ? It should be ERR_OK
What do you do after that ? Do you properly call sys_check_timeouts() on
the main loop or you just sit waiting things to magically happen ?
TCP is a state machine, you just instructed it to start a several steps
process.

PS: I assume your IP addressing is fine...


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users