当前位置:网站首页>[network protocol] | [01] network byte order big end and small end
[network protocol] | [01] network byte order big end and small end
2022-06-09 02:24:00 【Jxiepc】
List of articles
1、 Byte order
Is the byte order or sequence of digital data in computer memory , It can also be used to describe the order in which bits are transmitted over a communication channel ;
- big-endian( Big end ): Store the most significant byte of a word in the smallest memory address , The least significant byte is stored in the largest memory address ;
- little-endian( The small end ): Store the least significant byte at the least address ;
big-endian Is the most important sequence in network protocols ;
little-endian Is the main sequence of the processor architecture and its associated memory ;
The importance of byte order storage 

Large end to small end conversion
template<class T>
typename std::enable_if<sizeof(T) == sizeof(uint64_t), T>::type
byteswap(T val) {
return (T)bswap_64((uint64_t)val);
}
template<class T>
typename std::enable_if<sizeof(T) == sizeof(uint32_t), T>::type
byteswap(T val) {
return (T)bswap_32((uint32_t)val);
}
template<class T>
typename std::enable_if<sizeof(T) == sizeof(uint16_t), T>::type
byteswap(T val) {
return (T)bswap_16((uint16_t)val);
}
void test() {
uint64_t x = 0x12345678;
printf("%X\n", x);
printf("%lx\n", byteswap(x));
}
边栏推荐
- One article will help you understand SSR
- How Bi makes SaaS products have a "sense of security" and "sensitivity" (Part I)
- Thread synchronization, process synchronization, mutex, semaphore, condition variable, etc
- Buffett's alpha -- part of the code
- Diffusion model has been very popular in the field of image generation recently. How do you think its popularity has begun to surpass Gan?
- Security analysis and demonstration of contract private data leakage
- Basic usage of flask sqlalmy
- 杰理之关于 SPI 主机配置参数的几个说明篇】
- Mp4 structure
- 基于 Selenium 的 UESTC Daily Report 实现
猜你喜欢

Security analysis and demonstration of contract private data leakage

Navicat tool batch imports JSON format data to Doris
![[unity destroys objects or components when the inspector panel modifies values]](/img/46/732b52041dd320744494850691f046.png)
[unity destroys objects or components when the inspector panel modifies values]

【Unity在Inspector面板修改值时销毁物体或组件】

大四学长谈程序员

From the ECS SSRF vulnerability to taking over your alicloud console
![[1037. effective boomerang]](/img/e2/ccac2e7df2db316da4e88bdc709e6e.png)
[1037. effective boomerang]

Redis集群搭建

Golang of knowledge sharing -- a function based on whether a folder exists and whether a file exists
![[coding streaming] installation and use of SRS streaming media server](/img/8a/e3462db8425377d32ec2ef22c1ccf3.png)
[coding streaming] installation and use of SRS streaming media server
随机推荐
Basic principle of digital circuit adder (I)
C language student course management system
数据库表无法添加内容显示修改无法保存提示1452错误
badlyserialize
Calculate distance according to longitude and latitude
技术负责人如何搞垮一个团队?
杰理最后io_key 双按键如何使用?【篇】
Sectigo证书价格
C language guessing numbers game
S系列·向文本文件新增数据并且不添加重复值
Blue Bridge Cup_ N-ary linear equations_ Gauss elimination
Write cycle condition task
C#关于缓存区和数据流的问题
Security analysis and demonstration of contract private data leakage
Gunicorn 20.0.4 request smuggling vulnerability
杰理之关于 SPI 主机配置参数的几个说明:【篇】
CVE-2020-3187
[FBCTF2019]RCEService
FRP construction
S series · several postures for deleting folders