lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Pulling data from a server using HTTP with lwIP


From: Robert Wood
Subject: Re: [lwip-users] Pulling data from a server using HTTP with lwIP
Date: Thu, 13 Nov 2014 10:49:36 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

Hmmmm. I seem to be wrong, It *does* send out the ACK. I took out these lines:

strcpy(GetString,"GET /index.html HTTP/1.1\r\n");

netconn_write(xNetConn,GetString,sizeof(GetString),NETCONN_NOCOPY);

Which immediately followed:

rc2 = netconn_connect ( xNetConn, &remote_ip, 80 );

And it now does do the three way handshake.

Previously, what was happening was that it send out the HTTP GET request, but the Apache server was sending a timeout message, I assume, because it didn't get the third part of the initial handshake.

So, I suppose my question changes to:

Do I have to wait, in my code, for something in the lwIP stack to inform me that the ACK went out and I can send data to the established connection? If so, how do I do that?

If not, what I am doing wrong?

Thanks again.


On 13/11/14 09:54, Robert Wood wrote:
I'm getting started with lwIP; I have the SAM7X FreeRTOS demo running
and it is serving its demo file just fine.

However, what I really need to do is pull a file *from* a server. So,
I've created a new thread and done the following:

xNetConn = netconn_new ( NETCONN_TCP );

IP4_ADDR(&local_ip,emacIPADDR0,emacIPADDR1,emacIPADDR2,emacIPADDR3);
rc1 = netconn_bind ( xNetConn, &local_ip, 0 );
IP4_ADDR(&remote_ip,192,168,0,87);
rc2 = netconn_connect ( xNetConn, &remote_ip, 80 );

local_ip is the fixed address of my board, 192.168.0.87 is my desktop.

I've hooked up Wireshark to look at what's going on and I get two
packets (*): the lwIP SAM7X board sending out the initial request for a
connection with the SYN flag set and my desktop, which is running an
Apache server, replying with SYN & ACK flags set.

Now, I would expect the lwIP stack to then automatically return the
third packet in the handshake with just ACK flag set.

When the desktop sends out its SYN/ACK packet, I can see it goes through
a number of functions. It goes into ip_input(), you can see that the IP
addresses match and it calls tcp_input() which is happy that the ports
are correct and match. It clearly sees the flags are set to 0x12, which
is exactly what Wireshark says it is.

It ends up going into tcp_process(), in the switch statement for
pcb->state is goes into the SYN_SENT case, seems to increment the
sequence number correctly (I can see that number in the Wireshark data
and that gets incremented by one. Eventually, it goes into tcp_ack(),
which calls tcp_output(). pcb->flags is set to 0x01 which doesn't seem
right, but what is less right is that no packet gets sent out.

So, what vital step am I missing here? Is this something to do with
needing to specify a callback function and me sending out the
appropriate message? It looked to me like there was one set up; maybe it
was,  just set-up and queued but not sent?

I only have a tenuous grasp callback functions, so it may be that I'm
missing something vital.

I have plenty of FreeRTOS experience, but this is my first foray into
lwIP. In truth, a lot of this is new; I talk about these flags like SYN
and ACK as if I know what I'm on about, but this is all new to me in the
past few days!

Many thanks. :~)

Rob

* Actually I get a few more - my desktop resending its last packet!

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users




reply via email to

[Prev in Thread] Current Thread [Next in Thread]