Compute 16-bit One's Complement Sum
Date: 03/20/2002 at 13:54:13
From: John
Subject: How to compute 16-bit one's complement sum
I would like to know how to compute one's complement sum. In my TCP/IP
book it says, "to compute the IP checksum for outgoing datagram, the
value of checksum field is set to zero, then the 16-bit one's
complement sum of the header is calculated (i.e. the entire header is
considered a sequence of 16-bit words)" - but I do not know how to
compute the one's complement sum. Please help.
Date: 03/21/2002 at 01:27:19
From: Doctor Twe
Subject: Re: How to compute 16-bit one's complement sum
Hi John - thanks for writing to Dr. Math.
What that means is:
1. Add the 16-bit values up. Each time a carry-out (17th bit) is
produced, swing that bit around and add it back into the LSb (one's
digit). This is somewhat erroneously referred to as "one's complement
addition."
2. Once all the values are added in this manner, invert all the bits
in the result. A binary value that has all the bits of another binary
value inverted is called its "one's complement," or simply its
"complement."
For example, suppose our header has the following data. I separate the
data into groups of 4 bits only for readability. (I know that headers
are really longer than 8 bytes, but this will demonstrate the
process):
1000 0110 0101 1110
1010 1100 0110 0000
0111 0001 0010 1010
1000 0001 1011 0101
First, we add the 16-bit values 2 at a time:
1000 0110 0101 1110 First 16-bit value
+ 1010 1100 0110 0000 Second 16-bit value
---------------------
1 0011 0010 1011 1110 Produced a carry-out, which gets added
+ \----------------> 1 back into LBb
---------------------
0011 0010 1011 1111
+ 0111 0001 0010 1010 Third 16-bit value
---------------------
0 1010 0011 1110 1001 No carry to swing around (**)
+ 1000 0001 1011 0101 Fourth 16-bit value
---------------------
1 0010 0101 1001 1110 Produced a carry-out, which gets added
+ \----------------> 1 back into LBb
---------------------
0010 0101 1001 1111 Our "one's complement sum"
(**) Note that we could "swing around" the carry-out of 0, but adding
0 back into the LSb has no affect on the sum. (But technically, that's
what the checksum generator does.)
Of course, we'd continue to add the rest of the header data in 16-bit
segments until all data were included.
Then we have to take the one's complement of the sum. We do this by
simply inverting all the bits in the final result from above:
0010 0101 1001 1111 Our "one's complement sum"
1101 1010 0110 0000 The "one's complement"
So the checksum stored in the header would be 1101 1010 0110 0000.
I hope this helps. If you have any more questions, write back.
分享到:
相关推荐
《FusionCompute_Installer-8.0.0.zip:深入了解华为FusionCompute虚拟化平台》 华为FusionCompute是一款强大的企业级虚拟化平台,旨在提供高效、可靠的云计算基础设施服务。在给定的压缩包文件“FusionCompute_...
OpenStack Compute,通常被称为Nova,是OpenStack云平台的核心组件之一,主要负责处理虚拟机(VM)生命周期管理,包括创建、调度、启动、停止、迁移等任务。Nova使用分布式架构,设计目标是提供大规模的计算资源管理...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
FusionCompute-LinuxInstaller-8.0.1.2-X86_64.zip --------- Linux安装工具 FusionComputeUpdateTool_8.0.1.2.zip ------------- FusionCompute8.0.1升级工具 FusionCompute_GpuCompiler-8.0.1-X86_64.zip --------...
这里的"google-api-services-compute-v1-rev100-1.21.0.zip"文件,包含了Compute Engine API的特定版本,使得开发者能够轻松地在自己的应用中集成Google Compute Engine的功能。 Google API Services的Compute ...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
nsight family系列产品之一,结合Nsight System等工具用于GPU并行代码的性能分析,为程序优化提供指导,由于在Nvidia官网下载缓慢故将现在下载好的安装包上传(2022年3月12日)
《PyPI上的mypy-boto3-compute-optimizer-1.18.64:一个提升AWS Compute Optimizer效率的Python库》 在Python的世界中,PyPI(Python Package Index)是众多开发者获取和分享软件包的主要平台。今天我们要探讨的是...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
NVIDIA Nsight Compute 调试工具 - a CUDA kernel profiler supporting Volta and new GPUs。 nsight-compute-mac-2020.2.0.18-28964561.dmg版本。
2. **关键位预计算存储CIM阵列(Critical-bit Pre-compute-and-store CIM Array):** 这一特性允许预先计算并存储关键位,从而在执行特定计算时减少不必要的操作,进一步降低了功耗。 3. **周期性交替调度加法树...
**PyPI 官网下载 | mypy-boto3-compute-optimizer-1.12.14.0.tar.gz** 这个资源是 Python 开发者在 PyPI(Python Package Index)官网上可以找到的一个软件包,名为 `mypy-boto3-compute-optimizer-1.12.14.0.tar....
《PyPI上的mypy-boto3-compute-optimizer-1.10.47.0:优化Python AWS Compute资源的工具》 PyPI(Python Package Index)是Python开发者的重要资源库,它为全球的Python开发者提供了无数的第三方库,使得开发工作...
标题 "451.67-desktop-win8-win7-64bit-international-whql.7z" 提供的信息表明这是一款英伟达(NVIDIA)显卡驱动程序,具体版本号为451.67,它适用于Windows 8和Windows 7操作系统,且是64位版本。"WHQL"代表...
collections-of-the-basis-of-compute-system-2nd.bin
《jclouds-compute-service-archetype-1.6.0.zip:开源项目与SLF4J静默日志配置》 在IT行业中,开源项目是推动技术创新和发展的重要力量,它们为开发者提供了丰富的资源和工具。"jclouds-compute-service-archetype...
art计算棒_win10_Ubuntu16.04_Neural-Compute-Stick-NCS-
《Python库mypy-boto3-compute-optimizer详解与应用》 在当今的软件开发领域,Python因其简洁的语法和强大的库支持而备受青睐。在众多的Python库中,mypy-boto3-compute-optimizer是针对AWS Compute Optimizer服务...
1. **阿里云服务器ECS**:Elastic Compute Service(弹性计算服务)是阿里云提供的云计算服务,它允许用户按需获取和释放计算资源,以应对业务变化和负载需求。 2. **Ubuntu 16.04 64位**:Ubuntu是一个流行的开源...