开发者

Hex values in Protocol headers

开发者 https://www.devze.com 2023-02-04 16:30 出处:网络
Why are the protocol headers like TCP or UDP normally using Hex representation while filling the particular fields in the protocol header ? Is there any specific advantag开发者_如何学编程e ?Depending

Why are the protocol headers like TCP or UDP normally using Hex representation while filling the particular fields in the protocol header ? Is there any specific advantag开发者_如何学编程e ?


Depending upon the fields in question (flags, such as SYN FIN ACK RST URG PSH ..) it is easiest to set the fields using bitshifting arithmetic (0x1 < TCP_OFFSET_SYN) and OR | or AND & the results with the existing field. Bitshifts just go easier with hexadecimal than decimal, and is often more convenient to read than octal.

It boils down to, whoever wrote the code you're reading probably thought hex was more understandable than decimal in that instance, but this is obviously subjective. Your opinion may vary. :)


well that's for convenience in reality, if you inspect the actual packet, they are all binary data, which for sake of readability is shown as hex

0

精彩评论

暂无评论...
验证码 换一张
取 消