Hi,
I have used the the base SDK project, proj_lwiphttpsrv_bm, which configures the FRDM-K64 as a Web server and that all works fine, where my PC setup as specified IP address acts as the client with browser to GET the default index.html webpage on its browser. I have even modified the webpage to display something other than the default index.html.
Now as the subject line says, I have started programming the FRDM-K64 as a TCP client that will start a TCP raw "socket" by using tcp_new_ip_type() and then establish a connection to remote node using tcp_connect() to send SYN out to target "server" - by 3-way SYN-SYN/ACK-ACK handshake.
PROBLEM: the FRDM client is not getting any ACK or SYN/ACK reply to the SYN it sends out to the target IP address I specified on PCB and put as input argument to tcp_connect(). I see the SYN traveling over the ethernet line as captured on Wireshark from FRDM-K64 (IP: 192.168.0.102) sent to PC (IP: 192.168.0.100) but the PC just keeps sending out BROWSER and NBNS packets as multicast(?) IP: 192.168.0.255 but NO clearcut SYN-ACK to the FRDM's SYN.
OTHER ISSUES: I'm not sure I understand what I'm supposed to put in the function "tcp_connected()" callback function also specified as input argument to tcp_connect(). Based on readings, I deduced it will be called back only AFTER the SYN-SYNACK-ACK 3-way handshake is complete, when connection has been established, just as I have observed in Wireshark monitoring for server mode of the FRDM-K64.
QUESTIONS:
What am I missing to do in setting up FRDM-K64 as a client in RAW mode bare-metal?
I mean, I don't have to do any bind() or listen() or accept() operations, do I?
All I currently do for setup is to call tcp_new_ip_type(IPADDR_TYPE_V4) - should I use TYPE_ANY? - to get a new pcb and if successful, I call tcp_setprio() and setup callback function for connected.
Then pass the created pcb to tcp_connect() together with the target/remote IP address as this:
tcp_connect(pcb,netif_ip4_gw(netif), LWIP_IANA_PORT_HTTP,tcp_connected);
NOTE: I setup port as "http" = 80, webserver.
Basically, I let the FRDM-K64 initialize as regular web server mode, setup its ipaddr, mask, gw IP addresses in netif structure,... let it do all regular init function calls based on original SDK.
I don't right away do the tcp_connect right there. Instead, I let the network come-up, then inside ip4_input() I parse for incoming IP addresses. When I see the target address is the same as incoming source, that's when I do the tcp_connect() call.
And so, the SYN goes out and is received by the other side (PC) but how come the PC is not sending back ACK to the SYN? as I can see on Wireshark monitor.
So I figured maybe the switch will make a difference and hooked-up cables so all nodes are in a star networked via a switch. Nope.
So maybe because I don't have a PC app running as a server that is "listening" so I decided to connect to www.google.com, thinking that's a webserver somewhere there so I used google.com IP address. I see the SYN went out there in the www-land with IP address to google.com but still NO ACK from google.com. I would think google.com is ALWAYS running as a "server" listening for client connection to it. Why do these "servers" ignore my FRDM-K64's SYN to connect to their TCP layer at least and complete the 3-way handshake?
So what is wrong or is missing in my code?
Is it where I make the call to connect?
Do I have to broadcast/announce the FRDM-K64 node out there before trying out tcp_connect() so "listening" server can ACK to it?
Thanks for the help.
MI