ICMP Internet Control Message Protocol

Functions

SOCKET * install_icmp_socket (uint16_t size)
 Install an ICMP socket for ping and messages. More...
 

Detailed Description

ICMP/Ping

One of the most commonly used mechanism to solve network communication problems is a "Ping". Ping is based on the ICMP protocol and usually available on all TCP/IP implementations. To have the D.SignT TCP/IP stack answer a Ping request you need to install the protocol by calling function

install_icmp_socket()

To save program and data memory, it is not necessary to install the ICMP protocol for proper TCP or UDP communication. In some cases a ping may be helpful to fix communication problems, so having this diagnostic tool available may be a good idea at least during the development process.

Function Documentation

SOCKET * install_icmp_socket ( uint16_t  size)
Parameters
size- maximum size of ICMP message to be processed
Returns
  • pointer to socket
  • NULL if socket cannot be created
Note
This function actually calls socket_open with predefined parameters for ICMP
Library:
net.lib
Prototype:
net.h

The D.SignT TCP/IP stack does not implement the full ICMP protocol (Internet Control Message Protocol). Only "ping" requests are answered, which allows a remote host to "ping" the DSP to verify accessibility.

A "ping" will send random data to the DSP, which, in turn, echoes this data back to the sender. To enable ICMP, i.e. to enable the DSP to be "ping-ed", use function install_icmp_socket().

Parameter size defines the maximum ping data size which can be handled. Internally this buffer is increased to hold the ICMP header and a DSP specific structure alignment too. Thus a ping request of data sizes larger than the specified size may be possible and will not cause buffer overflows.

This buffer, and the associated socket data structure, is allocated from the system heap. It is not freed until the DSP is restarted.

//****************************************************************************
//
// @brief Initialize MAC, sockets and protocols
// @param -
// @return 0 - success or >0 - error occurred
//
//****************************************************************************
{
//**************************************************************************
// locals
//**************************************************************************
...
//**************************************************************************
// init sockets
// 1. parameter: own IP address or own HOST_NAME
// 2. parameter: subnet mask
// 3. parameter: gateway address
// 4. parameter NULL - own IP address is valid
// DHCP_ENABLE - IP comes from a DHCP Server
// own HOST_NAME is valid
// 5. parameter DNS Server IP or NULL
// 6. parameter DNS_ENABLE or NULL
//**************************************************************************
if ( !net_init (dsp_ip_addr, dsp_subnet_mask, gateway_ip, dhcp_setting, dns_server_ip, dns_setting))
{
prg_exit ("net_init() failed"); // out of memory, try to increase heap
}
//**************************************************************************
// install icmp socket (for ping)
// The parameter specifies the available space (taken from heap) for
// ping-data. For 'normal' pings, the space should be between 64 and 100
// bytes. If you want to check IP-fragmentation (only useful for UDP over
// hub or router), increase the required size. The maximum data size is
// limited to 65500.
//**************************************************************************
{
prg_exit ("ICMP socket error"); // possibly insufficient heap
}
//**************************************************************************
// success
//**************************************************************************
return (0);
}
Examples:
BoardSpecific.c.