lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] UDP and 1 byte payloads


From: Bill Auerbach
Subject: RE: [lwip-users] UDP and 1 byte payloads
Date: Thu, 18 Jun 2009 12:52:55 -0400

>> Shouldn’t the following work?
>>
>> p = pbuf_alloc(PBUF_TRANSPORT, 1, PBUF_POOL);
>> udp_sendto(pcb, p, ipAddr, port);
>>
>> Wireshare shows a mal-formed packet.  The following does work.
>>
>> p = pbuf_alloc(PBUF_TRANSPORT, 2, PBUF_POOL);
>> udp_sendto(pcb, p, ipAddr, port);
>
>They should both work.  The wireshark capture would be interesting.
>
>Kieran

Attached.  I could be wrong, but it looks like a WireShark bug (0.99.6a).  The 
1-byte "bad" packet has a payload of 0x11 which you see in the packet data.  
The 2-byte correct packet has 0x2222.  Also, I wasn't nice and sent a payload 
with 0 size and lwIP tried to send the packet.  Are 0 size payloads for UDP and 
TCP allowed?

>Bill, I think I remember you said you are using custom checksum routines
>or even -hardware. It would be interesting if that is the reason for the
>malformed packet or if it is still malformed when you use the default
>implementation.
>
>Simon

Good memory Simon! :-)  For now I'm still testing with CHECKSUM_GEN_UDP=0

I'll have results soon of my testing and things I've done to speed things up.

I'm working on other changes that will help the speed too - we spend a *lot* of 
time in the ARP code and it makes some redundant checks that add up.  We also 
look up the MAC address and copy it for every packet sent through the same PCB 
- I would think a connected PCB could store the MAC for its connected IP 
address (and the last IP address it used on a packet send) and use the 
associated MAC.  Then let etharp_input scan the PCB list updating MAC addresses 
for the IP address that has a MAC address change (which as Kieran says is 
rare).  This changes the data handling from checking for a change every time to 
only updating when the MAC address actually changes.

One of the bigger factors to the low turned out to be a compiler setting which 
is the default I think everyone is using.  It could be specific to GCC and/or 
my target (NIOS).  I'm 3-4 times faster now on top of other optimizations I'd 
already done, some of them I've submitted.  I will benchmark my final best 
versus CVS HEAD.  We're switching to our own reliable protocol over UDP 
(NAK-based instead of ACK-based) because the TCP protocol by its design 
effectively limits throughput to around 500-600MbS. It's too bad TCP wasn't 
designed to be able to configure the ACK ratio.

I did implement both TCP and UDP functions to pass in the payload checksum (I 
get the checksum for free since it's calculated as the hardware streams data to 
me).  It was trivial for TCP (tcp_enqueue_checksum adding a checksum parameter) 
and udp_sendto_if_checksum (ditto).  It requires checksum to be added to the 
pbuf struct which pbuf_alloc sets to -1.  These 2 functions set p->checksum to 
the argument passed to these 2 functions.  inet_checksum_pseudo simply uses 
p->checksum if it's not -1, else it generates it.  All this was less than 10 
lines of code.
 
Bill

Attachment: UDP_1_2_payload.pcap
Description: Binary data


reply via email to

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