Hi all,

I have PING failure. ping from a DSLAM to gateway IP is failing.. Finally i found that ...

the code is hitting else if portion in the following snippet where receiving header type or header ID is mismatching with the sent packet.

FYI, this problem is seen only in the customer node and no where else this problem is neither reported nor observed.

That too PING fails after 3,4 weeks of deployment of image containing the following code...recently i got an update the problem disappeared again after two weeks..

I am very much confused with this strange behaviour... The following code that i am using is a legacy code which does not have any issues...

When i tried to capture the packets via packet analyser ..ICMP reply and request are packets are correct with correct ids and header types...

So please help me in this regards...An extra eye can catch the problem....

pingInfoPtr->printedRows_m++;
for (i = 0;
(i < groupLength) && (pingInfoPtr->sent_m < pingInfoPtr->trials_m);
i++, pingInfoPtr->sent_m++) {
int written;
unsigned long startTime;
unsigned long startSeconds;
unsigned long startMicroSeconds;
struct sockaddr_in destination;
T_icmphdr *headerPtr = (T_icmphdr*)pingInfoPtr->packetHeader_m;
found = true;
headerPtr->type = ICT_ECHORQ;
headerPtr->code = 0;
headerPtr->id = icmpId;
headerPtr->seq = pingInfoPtr->sent_m;
xtm_gettimestamp(&startSeconds, &startMicroSeconds);
if (pingInfoPtr->mtuSize_m >= 8) {
headerPtr->data[0] = htonl(startSeconds);
headerPtr->data[1] = htonl(startMicroSeconds);
}
destination.sin_family = AF_INET;
destination.sin_addr.s_addr = pingInfoPtr->ipAddress_m;
destination.sin_port = 0;

written = sendto(pingInfoPtr->socket_m,
(char *)headerPtr,
pingInfoPtr->realSize_m,
0,
(struct sockaddr *)&destination,
sizeof(destination));
if ((size_t)written != pingInfoPtr->realSize_m) {
M_CLI_ERROR_0(*(contextPtr), CLI_Error:sError_c,
"sending ping message failed");
break;
}
startTime = xtm_gettime();
while ((xtm_gettime() - startTime < 1000*pingInfoPtr->timeout_m)
&& (contextPtr->mayContinue())) {
struct sockaddr_in origin;
int originLength;
unsigned bytesRead;
originLength = sizeof(origin);
bytesRead = recvfrom(pingInfoPtr->socket_m,
(char *)headerPtr,
pingInfoPtr->realSize_m,
0,
(struct sockaddr *) &origin,
&originLength);
if ((int)bytesRead < 0) {
if (bytesRead != ETIMEDOUT) {
M_CLI_ERROR_0(*(contextPtr), CLI_Error:sError_c,
"receiving ping message failed");
break;
}
} else if ((headerPtr->type != ICT_ECHORP)
|| (headerPtr->id != icmpId)) {
// this was not the expected reply
} else {
unsigned long seconds;
unsigned long microSeconds;
unsigned long delay;
xtm_gettimestamp(&seconds, &microSeconds);
if (bytesRead >= ICMP_HEADER_LEN + 8) {
startSeconds = htonl(headerPtr->data[0]);
startMicroSeconds = htonl(headerPtr->data[1]);
}
delay = (seconds - startSeconds)*1000000
+ (microSeconds - startMicroSeconds);
delay /= 1000;
trc_def_printf ("\n delay = %d\r\n",delay);
totDelay += delay;
pingInfoPtr->received_m += 1;
trc_def_printf ("\n Received messages = %d\r\n",pingInfoPtr->received_m);
if (delay < minDelay) {
minDelay = delay;
}
if (delay > maxDelay) {
maxDelay = delay;
}
break;
}
}
}