Keil Logo

MDK MIDDLEWARE: TCP-ERR:Socket #, Out of range segment received

Information in this knowledgebase article applies to:

  • Network Component v7


After MDK MIDDLEWARE: How to enable the network debugging in µVision, the Event Recorder shows the following error:

| Event |  Time(sec) | Component   | Event Property      | Value   |
|    10 | 1.23456778 | Net_TCP     | OutOfRangeSegment   | sock=1  |

Earlier versions of the Network Component and TCPnet could report similar error messages via Debug STDIO (ITM or USART):

TCP-ERR:Socket #, Out of range SEQ number received
TCP ERR: Out of range sequence number received


A packet is lost, at some point in the network.

Then a sender transmits the next (unexpected) segment number. The receiver detects this, and informs the sender of the expected number, by replying with a duplicate ACK. This ACK is based off the last segment that was handled. Recovery steps are implemented, by the Network Component, according to RFC 5681, TCP Congestion Control.

Although packet loss is common, when this error message is repeated continuously or associated with other error messages, it can indicate a larger problem, with either a sender or a receiver on the network.


There can be several different causes for packet loss, so multiple resolutions exist. To determine which node in the network causes the issue, the users can use third party tools, such as Wireshark, to help isolate the problem. For example, a router can dump packets if its receive buffer is overloaded. From the microcontroller side, you may try the following:

  • If you suspect the receive buffer is being overwhelmed on the microcontroller, you can increase the Receive Window Size, in the file "NET_Config_TCP.h". Also, check if the system core clock is configured correctly, and if the clock speed can be raised.
  • Lowering the receive Maximum Segment Size (MSS) on the microcontroller, in "NET_Config_TCP.h". The range is between 536 and 1460 bytes, inclusive. This value is part of network discovery, and can lower the size of a packet sent to the device. Some types of networks may require a lower MSS, overall. If the change reduces the number of re-transmissions, you may also see improved network responsiveness.
  • In general, upgrade to the latest version of the Network Component and Ethernet CMSIS drivers. Improvements and fixes related to both receiving packets and recovering lost packets can be added over time.
  • If the issue persists, or if the out-of-range error is followed by other types of error messages, users with support agreements may contact Keil tech support, who can assist with troubleshooting and answer questions about the Network Component.




Last Reviewed: Wednesday, November 21, 2018

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.