Ping2.c example details
This Application initiates a ping request to address 192.168.168.111. Change line
send_ping_request ("192.168.168.111");
in main() to use another address. If the network setting and the connection is right, the pings should be answered and the DSP prints the reply time.
Since ICMP is a basic and very simple protocol, net_send() and net_recv() do not support this protocol level. Instead RAW-IP is used to send out the ICMP request. The ICMP checksum must be generated first:
chk = get_checksum (dp, 40);
dp[2] = chk & 0xff;
dp[3] = (chk>>8) & 0xff;
- See also
- ICMP Internet Control Message Protocol
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include <time.h>
#include <string.h>
#include "ICMP.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#pragma CODE_SECTION(main , ".commontext");
{
int main_loop = 1;
CPrintf (
" *** timer %d mapped to CPU int %d ***\r\n",
CPuts (
" network startup time [sec]: ");
"%"PRId32".%03"PRId32"\r\n"
CPuts (
"\r\n Entering main loop ...\r\n");
while ( main_loop )
{
{
{
send_ping_request (target_ip);
}
}
}
return (0);
}