lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Intermittent "UDP checksum or malformed pkt transmitted" pr


From: Steven Vacca
Subject: [lwip-users] Intermittent "UDP checksum or malformed pkt transmitted" problem
Date: Thu, 11 Mar 2004 11:41:53 -0500

Environment info:
lwIP version: 0.6.0RC1
Compiler:     Introl
Processor:    Motorola 68HC16

Problem:  Intermittently a UDP pkt payload is modified before transmit.

After booting my code up, I send multiple UDP pkts at a fairly
slow frequency. Each pkt's payload is a short, NULL-terminated ASCII
string. My Network Sniffer always shows the first UDP pkt as having
an incorrect checksum.  Then the next 10 or so pkts are fine, then
the 4th pkt or so after that will have either a checksum error or
be labeled as "malformed" by the Sniffer. The ones which have a
checksum error always show the correct UDP header and length, but the
payload is made up entirely of the same byte value.  It's as though
after the send_udp() is called, and the correct checksum is produced,
something happens to the payload.  The "malformed" pkts have correct
headers, also, but the payload is not correct. Again, this is very
intermittent, always occuring on the 1st pkt, and then sometimes on
the 10th pkt after that, then the 4th after that, and so on.

Here is the simple code sequence I use:


void  testFunc(void)
{
  char   smdrBuff[100];               //Buffer containing ASCII string
to send via UDP.
  char*  ptr8;
  char*  buffPtr;                     //Ptr to allocated buffer. 
  struct ip_addr   udpDestIpAddr;     //IP addr to send UDP pkt to.
  struct pbuf*     pbuf1;             //pbuf ptr.
  struct udp_pcb*  udpSkt;            //UDP socket.


  sprintf(smdrBuff,"This is a test string!!\r\n");  //Msg to send via
UDP.

  //S E N D   U D P   M S G.
  buffPtr = mem_malloc(100);                    //Allocate buff for UDP
pkt.
  memcpy(buffPtr,smdrBuff,50);
  
  pbuf1 = pbuf_alloc(PBUF_RAW,100,PBUF_RAM);    //Get a pbuf struct.
  pbuf1->payload = (void*) buffPtr;                     //Set ptr to UDP
msg.

  udpSkt = udp_new();                           //Get a UDP socket.

  ptr8 = (char*) &udpDestIpAddr;
  *ptr8     = 0xc0;                                     //Send UDP pkts
to 192.168.11.155 (smv PC).
  *(ptr8+1) = 0xa8;
  *(ptr8+2) = 0x0b;
  *(ptr8+3) = 0x9b;

  udp_connect(udpSkt,&udpDestIpAddr,514);       //Set-up socket with
dest IP and port.
  udp_send(udpSkt,pbuf1);                               //Send the UDP
msg.
  udp_remove(udpSkt);                                   //Delete the
socket.

  mem_free(buffPtr);                                    //Free the
allocated UDP pkt memory.
  pbuf_free(pbuf1);                                     //Free the pbuf
struct.
}


Thanks for anyone's help,

ShutEye Thinkin





reply via email to

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