Re: UDP checksum problem



r3gis wrote:
On Aug 20, 11:58 pm, Jack Snodgrass <jacks_temp_id_bf2...@xxxxxxxxxxx>
wrote:

On Mon, 20 Aug 2007 14:00:25 +0000, r3gis wrote:

Hi !
For some strange reason I cant get correct checksums when I am sending
packets through simple UDP socket.Can anyone tell me what I am doing
wrong ?

The code is following :

int sendUDP(char* buf,int size,char* ip_str,char* port_str) {

int sockfd, portno, ip;
struct sockaddr_in serv_addr;
sockfd = socket(PF_INET, SOCK_DGRAM,0); if (sockfd < 0)
error("ERROR opening socket");
memset((void*)&serv_addr,0,sizeof(struct sockaddr_in));
serv_addr.sin_family=PF_INET;
portno=atoi(port_str);
serv_addr.sin_port = htons(portno);
serv_addr.sin_addr.s_addr=inet_addr(ip_str);
if(serv_addr.sin_addr.s_addr==-1)
error("wrong ip");
int len=sendto(sockfd,buf,size,0,(struct
sockaddr*)&serv_addr,sizeof(serv_addr));
close(sockfd);

return len;
}

I didn't look at this too close.... just wanted to clarify
something first.... you don't have anything to do with the
CRC... that's a built-in feature... ( how ever you want to
phrase it ) are you 100% sure your getting a bad crc error...
where are you seeing this?

jack

--
D.A.M. - Mothers Against Dyslexia

seehttp://www.jacksnodgrass.comfor my contact info.

jack - Grapevine/Richardson


I have checked this in Wireshark and tcpdump. They both indicate bad
CRC for all UDP packets.Fortunately I have been able to solve this .
It appeared that is was caused by the inet_addr function O_o , when I
have changed it to inet_aton the CRC is calculated correctly .


If the bad checksum is indicated on datagrams sent by
the same computer running the libpcap application (tcpdump,
ethereal, wireshark ...), the most probable cause is that
the checksum calculation is off-loaded to the network
interface hardware. The checksums are not calculated yet
at the point of processing where the capture is done.

--

Tauno Voipio
tauno voipio (at) iki fi
.



Relevant Pages

  • Re: UDP checksum problem
    ... For some strange reason I cant get correct checksums when I am sending ... phrase it) are you 100% sure your getting a bad crc error... ... jack - Grapevine/Richardson ... CRC for all UDP packets.Fortunately I have been able to solve this. ...
    (comp.os.linux.networking)
  • Re: Opinions on 16-bit checksums.
    ... >> CRC as well. ... People keep _saying_ things like that, but nobody ever has any ... > proven that checksums aren't the best things. ... It probably isn't, but I'd like some real, statistical evidence ...
    (comp.arch.embedded)
  • Re: patch for IPSEC_NAT_T
    ... work NAT-T with Windows XP in the real situation. ... ESP transport with NAT-T may need NAT-OA support, ... L2TP is encapsulated in UDP datagrams. ... Looks like XP sets the checksums for UDP datagrams..... ...
    (freebsd-net)
  • Re: patch for IPSEC_NAT_T
    ... "tcpdump enc0" shows that traffic is decoded normaly, ... ESP transport with NAT-T may need NAT-OA support, ... L2TP is encapsulated in UDP datagrams. ... Looks like XP sets the checksums for UDP datagrams..... ...
    (freebsd-net)
  • Re: cyclic redundancy check 4-bit
    ... The Hamming code 7.4 or 8.4 is what you need. ... You don't want CRC, or checksums. ... You want an error correcting ...
    (comp.arch.embedded)