lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Data packets splitting on odd boundaries -> causes exce


From: Michael Anburaj
Subject: Re: [lwip-users] Data packets splitting on odd boundaries -> causes exception
Date: Thu, 20 Feb 2003 03:00:38 -0800 (PST)

Hi Jani,

After so many hours of debugging (managed with just
printf’s), I found a clue to this problem.

1st let me show the application code that’s of
interest to us:


/* This is the data for the actual web page.
Most compilers would place this in ROM. */
const static char indexdata[] =
"<html> \
<head><title>LwIP Test app over MIPS_UCOS-II -by
Michael Anburaj.</title></head> \
<BODY>\
<FONT FACE=\"Comic Sans MS\" SIZE=6
COLOR=\"#ff0000\"><P>This is the 1st line.....</P>\
<P>This is the 2nd line!!</P></FONT></BODY>\
</html>";

const static char http_html_hdr[] =
"HTTP/1.1 200 OK\r\n\
Content-Type: text/html\r\n\r\n";


/* This function processes an incomming connection. */
static void
process_connection(struct netconn *conn)
{
        struct netbuf *inbuf;
        char *rq;
        u16_t len;
        int i;

        /* Read data from the connection into the netbuf
inbuf.
        We assume that the full request is in the netbuf. */
        if((inbuf = netconn_recv(conn)) == NULL)
        {
                netconn_close(conn);
                return;
        }

        printf("#1 snd_buf = %d\n",(conn->pcb.tcp)->snd_buf);
                
        netbuf_data(inbuf, (void **)&rq, &len);

        printf("#2 snd_buf = %d\n",(conn->pcb.tcp)->snd_buf);

        /* Check if the request was an HTTP "GET /\r\n". */

        if(rq[0] == 'G' && rq[1] == 'E' &&
        rq[2] == 'T' && rq[3] == ' ' &&
        rq[4] == '/')
        {
                printf("#3 snd_buf =
%d\n",(conn->pcb.tcp)->snd_buf);

                /* Send the header. */
                if(netconn_write(conn, (void *)http_html_hdr,
sizeof(http_html_hdr), NETCONN_NOCOPY) != ERR_OK)
                        printf("***Write1Err***\n");

                printf("#4 snd_buf =
%d\n",(conn->pcb.tcp)->snd_buf);

                /* Send the actual web page. */
                if(netconn_write(conn, (void *)indexdata,
sizeof(indexdata), NETCONN_NOCOPY) != ERR_OK)
                        printf("***Write2Err***\n");




>From the TCP code I understood that the
‘conn->pcb.tcp)->snd_buf’ variable determines the
number of bytes of data that can be sent. Am I right?

In below lines SND_BUF represent
conn->pcb.tcp)->snd_buf.

The debug console window (printf’s) shows that the
value of SND_BUF before the netconn_write() calls is
256 (that is at #3).  The 1st netconn_write() call
sends the http header, which is of length = 45 (in
bytes). After this call the value of SND_BUF becomes
256-45 = 211. Now the second netconn_write() call is
executed with the actual web page string, which is of
size greater than 211 bytes. Due to SND_BUF value of
211, only 211 bytes are sent at the moment & then the
remaining & so on in a loop inside netconn_write().
The string ‘indexdata’ is well aligned by the compiler
<default option> at word (32bit) address boundary.
Since, only part of the compiler aligned sting
‘indexdata’ is sent & is part on a odd byte boundary,
the next time around the remaining string to be sent
will fail the alignment & due to this as mentioned in
the previous correspondence the processor aborts
(alignment fault).

Let me know where the problem is.

Thanks,
-Mike.


--- Jani Monoses <address@hidden> wrote:
> I don't know whether that example should still work
> with current
> lwIP. Do other apps trigger the same problem?
> You might want to tell the compiler to align all
> data you
> use in http to 4 bytes.
> 
> > Application: Adam_s example code (18.1 Using the
> API
> > from lwip.pdf
> 
> 
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://mail.nongnu.org/mailman/listinfo/lwip-users


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/




reply via email to

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