stm32plus::net LLIP module
Link Local IP Addresses (LLIP) are a range of IP addresses within the 169.254/16 prefix that are designed only for communication on a single network segment. The addresses assigned by the LLIP module are non-routable, that is they will never be transmitted beyond your local LAN. LLIP can be useful in an environment where DHCP is not available and static assignment of routable addresses is not possible or desirable.
stm32plus::net implements the LLIP auto-discovery and monitoring protocol defined in RFC 3927. You can include LLIP in your stack like this:
typedef ApplicationLayer<MyTransportLayer,LinkLocalIp> MyApplicationLayer;
Note that this application layer only shows the
LinkLocalIp module in the application layer. In practice you may have more than one module.
If another station comes online while we are running and tries to claim our IP address then the LLIP module will detect that and automatically start probing again for a new address.
An error event with provider name
ERROR_PROVIDER_NET_LINK_LOCAL_IP and code
E_ADDRESS_CLASH is raised the moment the clash is detected and then probing for a new address starts immediately. During the time period between the error event and the announcement of the new address the network stack is unusable from the network layer upwards and all activity should be suspended.
The following parameters are made available in the stack’s configuration object for customisation:
// true to start search from random address, false to use the fixed address as a start. default is true. bool llip_randomStart; // if llip_randomStart is false then this is where the search starts IpAddress llip_fixedStart; // total number of tries for different addresses. Default is 30 (about 180 seconds) uint16_t llip_tries;
LLIP works by selecting an IP address from the defined range of link-local addresses and using ARP to probe the network segment for other devices that may have already claimed that address. If no device responds to the probe then the LLIP module claims that address as its own and raises an event to the stack to announce its address and subnet mask.
The RFC recommends starting the search for an address at a random position within the possible range and so we offer that as the default strategy through the
If you know better and you’d prefer to start the search at a fixed address then set
llip_randomStart to false and set
llip_fixedStart to the address where you want to start searching.
If the address being probed clashes with another on the network then this module will bump up the address by one and try again.
llip_tries defines the number of times that this will happen before it gives up and raises an error event.
Events raised by the LLIP module
The LLIP module raises a number of events to inform you of progress:
|purpose||IP address assigned|
|purpose||Subnet mask assigned|
These two events are raised when a non-clashing IP address has been discovered and claimed. See the documentation for the DHCP module for details. Note that the subnet mask is always
255.255.0.0 because the LLIP address range is a class B network.