34、IP 传输协议:UDP 与 TCP 详解

IP 传输协议:UDP 与 TCP 详解

1. 用户数据报协议(UDP)

1.1 UDP 概述

UDP 是一种简单的传输协议,在传输过程中,若接收到的数据包校验和出错,该数据包会被丢弃,且 UDP 无法将这种丢弃情况报告给发送方,因为难以确定损坏数据包的预期接收方。应用层协议有责任验证数据是否实际送达。

1.2 UDP 校验和

  • IPv6 下的伪首部 :当使用 IPv6 传输 UDP 数据报时,伪首部使用 IPv6 地址构建。并且根据 IPv6 规范(RFC 2460),使用 IPv6 时必须使用校验和。
  • 校验和算法 :UDP 校验和采用标准的校验和算法,即对整个消息的二进制反码求和后再取反得到 16 位校验和。若消息长度不是 2 字节的倍数,会在末尾填充一个零字节,但该填充字节不传输,也不增加数据报的长度。若校验和计算结果为零,校验和字段会填充为全 1(0xff),以区别于表示不使用校验和的零值。

1.3 选择 UDP 而非原始 IP 的原因

  • 功能共享 :应用选择 UDP 是为了利用其提供的功能。由于不同应用可能需要相同的功能,使用 UDP 可以共享其代码和服务。例如,TFTP 和 BOOTP 等应用常部署在无盘网络设备上,使用 UDP 可以减少设备芯片所需的代码量。
  • 端口支持 :UDP 通过端口能够同时支持众多服务和应用。而原始 IP 仅靠 1 字节长的“Next Pr

相关推荐

数据包分析——传输层(TCP和UDP)

TCP传输控制协议 tcp主要是建立连接,然后从应用层程序中接收数据并进行传输。 报头结构 00H~0DH:DLC包头0EH~21H:IP包头22H~23H:源主机端口号(33594 (833aH))24H~25H:目的主机端口号(80 (0050H))26H~29H:序号,指明段在即将传输的段序列中的位置2AH~2DH:确认号,作为收

秋天的原野 2409

34、网络通信协议:IP、TCP 与 UDP 详解

本文详细介绍了网络通信中的核心协议IP、TCP和UDP,包括IPv4和IPv6的工作原理及区别,TCP和UDP的可靠性机制及应用场景。文章还比较了不同协议的特点,分析了它们在网络分层架构中的位置和交互过程,并展望了协议的未来发展趋势,帮助读者更好地理解网络通信的基础和实际应用。

fanta的博客 70

IPV6实现UDP报文

IPV6实现UDP报文发送小Demo,附tpipv6头文件,在vc6.0环境下通过测试。

安卓 实现灯光闪过效果

有个小需求,给按钮加一个灯光划过的效果,这样的需求一般有UI,肯定就找UI了要个gif图不就完事了,可是这次没有,好久自己做一个嘛。Web端的大佬实现很快,到安卓这边呢,百度一搜发现诶?怎么没有,好吧自己来一个 一切动效相关的不给图看都是耍流氓 所以俺不能这么干啊,OK!直接上效果图,再来解释下怎么实现的 效果就是这样子,怎么实现呢? 从图分析下,就是一个光写着重左边移动要右边循环嘛,这有啥难的?? 来看一看我的第一版,第二版 这是个什么?????一点都不像啊? 赶紧再问了问Web端大佬,噢,加了一个

SummerCloudXT的博客 1378

硬件设计--DC/DC电源芯片详解

本文参考:http://www.elecfans.com/article/83/116/2018/20180207631874.html https://blog.youkuaiyun.com/wangdapao12138/article/details/79763343 第一次写博客,不喜勿喷,谢谢!!! DC/DC电源指直流转换为直流的电源,从这个定义上看,LDO(低压差线性稳压器)芯片也应该属于D...

weixin_30794499的博客 7875

SiC MOSFET驱动设计实战:从特性解析到电路优化

本文深入解析SiC MOSFET的核心特性及其驱动电路设计要点,涵盖高温稳定性、快速开关能力等关键特性,并提供驱动电压配置、电流能力计算、布局优化等实用方案。特别针对第三代电力电子半导体SiC MOSFET的驱动要求,分享STGAP1AS等典型驱动方案的应用技巧,助力工程师解决高频应用中的EMI和热管理挑战。

weixin_29230865的博客 366

使用 FastAPI 和 LangGraph 构建生产级智能体 AI 系统

这是一本关于使用 FastAPI 和 LangGraph 构建生产级智能体 AI 系统的详细书籍,全文约 10 万字。《Production-Grade Agentic AI System Design and Implementation: Building Agentic AI Systems Using FastAPI and LangGraph》随着人工智能(AI)技术的迅猛发展,智能体(Agent)作为能够自主感知、推理、决策和行动的实体,正逐渐成为构建复杂智能系统的核心。从个性化推荐、客户服务到

AI天才研究院 348

深度强化学习在机器人控制中的应用

非常感谢您提供如此详细的任务要求和约束条件。作为一位世界级的人工智能专家和计算机领域大师,我将全身心投入到这篇技术博客的撰写中。 深度强化学习在机器人控制中的应用 1. 背景介绍 近年来,随着人工智能技术的飞速发展,深度学习和强化学习在各个领域都得到了广泛应用,尤其是在机器人

AI天才研究院 1324

多标签图像分类:标签依赖关系建模的最新论文解读与实战应用

多标签图像分类:标签依赖关系建模的最新论文解读与实战应用 ,人工智能,计算机视觉,大模型,AI,本文解读了最新相关论文,包括基于图神经网络(GCN)的ML-GCN方法,通过构建标签相关矩阵建模依赖关系;区域潜在语义依赖的RLSD模型,定位关键区域并利用RNN建模语义依赖;以及语义图表示学习的SSGRL框架,结合语义解耦与交互模块。通过实战应用,展示了基于PyTorch的ML-GCN模型实现,包括图像特征提取、标签依赖建模及训练评估流程,为多标签图像分类提供了有效解决方案。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 18万+

华为OD机试新系统真题【终端设备档位差异统计】

华为OD机试 新系统真题【终端设备档位差异统计】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【终端设备档位差异统计】多语言题解。

qq_45776114的博客 786

【WRF-Urban】URBPARM_LCZ.TBL 查找表解释及内容

URBPARM_LCZ.TBL 查找表解释及内容

WW、forever的博客 1754

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 1、光通信技术发展与PAM4调制在数据中心应用的研究
下一篇: 22、iPhone摄影与视频使用全攻略
time3
博客等级 码龄20年 55粉丝 1482原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值