lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] slip recvs corrupted packets (Was Re: tcp_connect is aborte


From: Chris Frost
Subject: [lwip-users] slip recvs corrupted packets (Was Re: tcp_connect is aborted)
Date: Tue, 14 Dec 2004 21:24:18 -0800
User-agent: Mutt/1.3.28i

A couple weeks back I mailed the list while I was trying to setup lwip
using the loopback driver. I've not been able to do this yet, so I've
moved to trying to setup slip, hoping the loopback problem was just local
to it.

I've implemented sio_open(), sio_recv(), and
sio_send(). sio_[recv|send]() essentially read from the serial port
and return the read data and write the given byte to the serial
port. sio_open() ensures the serial port has the correct setup. Just
in case I might have this wrong, is this their expected function?

For staring up lwip and configuring for slip I essentially do the same
procedure as when I was trying to use the loopback driver:
- init() for stats, mem, memp, pbuf, netif, ip, and tcp.
- set struct ip_addrs for the ipaddr, netmask, and gateway.
- netif_add these:
                nif_sl = netif_add(&netif_sl, &ipaddr, &netmask, &gateway, NULL,
                                                                                
                        slipif_init, ip_input);
- netif_set_up(nif_sl);
- netif_set_default(nif_sl);

- listen on a port (but even ping's packets are corrupted, so this probably
  isn't of concern)

- loop forever:

  - Call a modified version of slipif_loop(), that does one interation of
    what slipif_loop would do, every loop.
    My program is single threaded, slipf_loop() appears to be designed for
    multithread programs?

  - Call tcp_slowtmr() and tcp_fasttmr() very approximately every 200 & 500ms.


Are there anythings in the above that sound incorrect? Are there any
very likely errors one may make in doing the above?

Now for what I actually see in my test. I'm pining my os over slip like I said.
The os is actually running in the x86 emulator bochs and talking to the host
computer through two ptys. I'm able to boot debian linux inside bochs
and use this setup for internet access, so this half of the setup seems good.
However, when I ping my program using lwip, I get output like the following:
(I've written "// recieved ..." when sio_recv() reads data. I group this
read with all the others in my comments below if there was no other debug
output inbetween the recvs.)


slipif_input: alloc
pbuf_alloc(length=128)
pbuf_alloc: allocated pbuf 0x819fa0
pbuf_alloc(length=128) == 0x819fa0
// recevied 39 bytes over the serial port
pbuf_free(0x81a030)
pbuf_free: deallocating 0x81a030
slipif: Got packet
lwip_chksum(0x819fc0, 20)
inet: chksum: no odd byte
lwip_chksum(0x819fc0, 20)
inet: chksum: no odd byte
Checksum (0x5470) failed, IP packet dropped.
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        84     | (v, hl, tos, len)
+-------------------------------+
|        0      |010|       0   | (id, flags, offset)
+-------------------------------+
|   64  |    1  |    0xb555     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |   26  |   27  | (src)
+-------------------------------+
|   28  |   29  |   30  |   31  | (dest)
+-------------------------------+
pbuf_free(0x819fa0)
pbuf_free: deallocating 0x819fa0
// received one byte
slipif_input: alloc
pbuf_alloc(length=128)
pbuf_alloc: allocated pbuf 0x819fa0
pbuf_alloc(length=128) == 0x819fa0
tcp_slowtmr: no active pcbs
// received two bytes
slipif_input: alloc
pbuf_alloc(length=128)
pbuf_alloc: allocated pbuf 0x81a0c0
pbuf_alloc(length=128) == 0x81a0c0


The src addr should be 192.168.2.1 and the dest addr should be 192.168.2.2.
At other times ip_input() will accept a packet, but it won't make it much
further:

// received one byte
slipif_input: alloc
pbuf_alloc(length=128)
pbuf_alloc: allocated pbuf 0x81a1e0
pbuf_alloc(length=128) == 0x81a1e0
// received 69 bytes
pbuf_free(0x81a270)
pbuf_free: deallocating 0x81a270
slipif: Got packet
lwip_chksum(0x81a200, 20)
inet: chksum: no odd byte
ip_input: iphdr->dest 0x202a8c0 netif->ip_addr 0x202a8c0 (0x202a8c0, 0x202a8c0, 
0x0)
ip_input: packet accepted on interface sl
ip_input: 
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        84     | (v, hl, tos, len)
+-------------------------------+
|        3      |010|       0   | (id, flags, offset)
+-------------------------------+
|   64  |    1  |    0xb552     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    2  |    1  | (src)
+-------------------------------+
|  192  |  168  |    2  |    2  | (dest)
+-------------------------------+
ip_input: p->len 66 p->tot_len 66
pbuf_header: old 0x81a200 new 0x81a214 (-20)
lwip_chksum(0x81a214, 46)
inet: chksum: no odd byte
pbuf_free(0x81a1e0)
pbuf_free: deallocating 0x81a1e0


These two example ip headers probably don't say anything obvious, but I was
curious if they might?

I'm also new to serial communication. Both sides are setup for 8databits,
1 stop, and no parity. I'm able to send simple ascii text out and in from
my os. Is there more that might be good to investigate here?


thanks so much for any pointers/suggestions!
-- 
Chris Frost  |  <http://www.frostnet.net/chris/>
-------------+----------------------------------
Public PGP Key:
   Email address@hidden with the subject "retrieve pgp key"
   or visit <http://www.frostnet.net/chris/about/pgp_key.phtml>




reply via email to

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