Signed and unsigned integer processing in protocol resolution

Time:2020-3-12

1. Problem: the gateway parsing is correct. The reason for my. Net parsing error is that it was originally unsigned and I made it signed.

在这里插入图片描述

3. Word: unsigned double byte shaping

在这里插入图片描述

在这里插入图片描述

5. 0x800a to 32758

在这里插入图片描述

The reason is: the following two writing methods are equivalent. IPAddress. Networktohostorder() can’t receive uint16 type, so bitconverter.touint16 (arr, 0) is forced to be converted into int32 for reordering.

在这里插入图片描述

6. Write method 1: after “network sequence to host sequence”, take the absolute value, otherwise there will be problems. Write method 1 also has problems, so it’s better not to use it

在这里插入图片描述

As it turns out, there are problems in writing

在这里插入图片描述

7. Write method 2: “network sequence to host sequence”, and then convert to uint16 unsigned double byte shaping

在这里插入图片描述

Principle: int16 has more ffff than uint16 on the left, so this should be the symbol

在这里插入图片描述

在这里插入图片描述

The above is the whole content of this article. I hope it will help you in your study, and I hope you can support developepaer more.