当前位置: 首页 > news >正文

现代网络基础设施中的 TCP 握手之下

TCP 3 次握手

在最简单的形式中,TCP 三次握手很容易理解,并且有 大量在线材料都在讨论这个问题。(如果你能读懂 Chinease,你可以看看我之前的一篇文章。

然而,在实际中理解、练习和解决 TCP 问题 世界是另一回事。随着容器平台开始主宰世界,随着 以及 service-mesh 成为底层的下一个重大转变 网络基础设施,这些平台中的现代网络功能使 TCP 相关问题更加复杂。在传统观点中,这些问题 可能看起来相当奇怪。

本文将介绍其中两种情况。你看到时有什么想法 下面两张图片?

方案 1 的 TCP 流有问题

方案 2 的有问题的 TCP 流

1. 场景 1

1.1 现象:SYN -> SYN+ACK -> RST

客户端发起了与服务器的连接,服务器立即确认 (SYN+ACK),但客户端在收到此数据包时重置了它,并继续等待 用于来自服务器的下一个 SYN+ACK。经过多次 retransmit 和 reset, 连接终于超时了。

1.2 捕获

tcpdump 输出:

<span style="color:#333333"><span style="background-color:#f8f8f8"><span style="background-color:#f6f8fa"><code>1 18:56:40.353352 IP 10.4.26.45.35582 <span style="color:#000000"><strong>></strong></span> 10.4.26.234.80: Flags <span style="color:#000000"><strong>[</strong></span>S],  <span style="color:#0086b3">seq </span>853654705, win 29200, length 0
2 18:56:40.353506 IP 10.4.26.11.80 <span style="color:#000000"><strong>></strong></span> 10.4.26.45.35582:  Flags <span style="color:#000000"><strong>[</strong></span>S.], <span style="color:#0086b3">seq </span>914414059, ack 853654706, win 28960, length 0
3 18:56:40.353521 IP 10.4.26.45.35582 <span style="color:#000000"><strong>></strong></span> 10.4.26.11.80:  Flags <span style="color:#000000"><strong>[</strong></span>R],  <span style="color:#0086b3">seq </span>853654706, win 0, length 0
4 18:56:41.395322 IP 10.4.26.45.35582 <span style="color:#000000"><strong>></strong></span> 10.4.26.234.80: Flags <span style="color:#000000"><strong>[</strong></span>S],  <span style="color:#0086b3">seq </span>853654705, win 29200, length 0
5 18:56:41.395441 IP 10.4.26.11.80 <span style="color:#000000"><strong>></strong></span> 10.4.26.45.35582:  Flags <span style="color:#000000"><strong>[</strong></span>S.], <span style="color:#0086b3">seq </span>930694343, ack 853654706, win 28960, length 0
6 18:56:41.395457 IP 10.4.26.45.35582 <span style="color:#000000"><strong>></strong></span> 10.4.26.11.80:  Flags <span style="color:#000000"><strong>[</strong></span>R],  <span style="color:#0086b3">seq </span>853654706, win 0, length 0
</code></span></span></span>

哪里

  • 客户:10.4.26.45
  • 服务器:,在端口提供 HTTP 服务10.4.26.23480

怎么了?在继续之前,请考虑一下这一点。

1.3 分析

让我们试着深入了解发生了什么:

  1. #1:客户端启动了与服务器的连接,使用src_port=35582,dst_port=80
  2. #2:服务器已确认 (SYN+ACK)
  3. #3:客户端重置服务器的 SYN+ACK 数据包
  4. #4:超时,客户端重传#1
  5. #5:服务器已确认(仍为 SYN+ACK)#4
  6. #6:客户端再次被拒绝 (, SYN+ACK)#5

此 TCP 流的时间序列在此处重新描述:

图 1.1 有问题的 TCP 流

乍一看,这似乎很奇怪,因为服务器确认了客户端的请求, 而 Client 端在收到后立即重置此数据包,然后一直等待 Next 来自服务器的 SYN+ACK(而不是关闭此连接尝试)。它 甚至在超时时重新传输第一个 SYN 数据包(注意到它使用与 do 相同的临时端口)。#4#1

1.4 根本原因

注意这一点:客户端假设服务器在 ,为什么 SYN+ACK 数据包 ( 和 ) 来自 ?通过一些调查, 我们发现:该服务器部署为 K8S ExternalIP Service,作为 VIP(ExternalIP)和 PodIP。10.4.26.234#2#410.4.26.1110.4.26.1110.4.26.234

1.4.1 简短的回答

客户端连接到服务器,目标 IP 为 server,但 server (实例)回复了其真实 IP (PodIP)。IP 不匹配使客户相信 SYN+ACK 数据包无效,因此拒绝了它们。

1.4.2 长答案

首先,我们位于 Cilium 驱动的 K8S 集群中。 Cilium 将生成 BPF 规则,以将流量负载均衡到此 VIP 添加到其所有后端 Pod 中。正常流量路径如图 1.1 所示:

图 1.2 客户端和服务器实例之间的正常数据流

  1. @Client:客户端向服务器发送流量VIP
  2. @ClientHost:Cilium 做 DNAT,把 VIP 改成它的 (backend 实例 IP)PodIP
  3. @ServerHost:路由到 IP 为PodIP
  4. @Server:服务器实例回复为自己的PodIP
  5. @ServerHost:将回复数据包路由到客户端主机
  6. @ClientHost:Cilium 进行 SNAT,将服务器的 schange 为 ,然后转发 到客户端实例的流量PodIPVIP
  7. @Client:客户端接收流量。从它自己的角度来看, received packet 只是前一个发送的 packet (两者都是 ),因此它接受该数据包。3 次握手完成。src_ipdst_ipVIP

客户端和服务器位于同一主机上时,会出现此问题,其中 的情况下,步骤 6 不是由 Cilium 实现的,如图 1.2 所示:

图 1.3 客户端和服务器位于同一主机上时的数据流

我们已经报告了这个问题,并确认了一个错误,请参阅此 问题了解更多详情。

2. 场景 2

2.1 现象:握手正常,传输数据时连接重置

客户端成功启动了与服务器的 TCP 连接(3 个数据包),但是,在 发送第一个数据包(总共第 4 个数据包),连接得到 由 Server 立即重置。

2.2 捕获

<span style="color:#333333"><span style="background-color:#f8f8f8"><span style="background-color:#f6f8fa"><code>1 12:10:30.083284 IP 10.6.2.2.51136 <span style="color:#000000"><strong>></strong></span> 10.7.3.3.8080: Flags <span style="color:#000000"><strong>[</strong></span>S],  <span style="color:#0086b3">seq </span>1658620893, win 29200, length 0
2 12:10:30.083513 IP 10.6.3.3.8080 <span style="color:#000000"><strong>></strong></span> 10.7.2.2.51136: Flags <span style="color:#000000"><strong>[</strong></span>S.], <span style="color:#0086b3">seq </span>2918345428, ack 1658620894, win 28960, length 0
3 12:10:30.083612 IP 10.6.2.2.51136 <span style="color:#000000"><strong>></strong></span> 10.7.3.3.8080: Flags <span style="color:#000000"><strong>[</strong></span>.],  ack 1, win 229, length 0
4 12:10:30.083899 IP 10.6.2.2.51136 <span style="color:#000000"><strong>></strong></span> 10.7.3.3.8080: Flags <span style="color:#000000"><strong>[</strong></span>P.], <span style="color:#0086b3">seq </span>1:107, ack 1, win 229, length 106
5 12:10:30.084038 IP 10.6.3.3.8080 <span style="color:#000000"><strong>></strong></span> 10.7.2.2.51136: Flags <span style="color:#000000"><strong>[</strong></span>.],  ack 107, win 227, length 0
6 12:10:30.084251 IP 10.6.3.3.8080 <span style="color:#000000"><strong>></strong></span> 10.7.2.2.51136: Flags <span style="color:#000000"><strong>[</strong></span>R.], <span style="color:#0086b3">seq </span>1, ack 107, win 227, length 0
</code></span></span></span>

同样,在继续之前考虑这一点是值得的。

2.3 分析

  1. #1:客户端启动了与服务器的连接,src_port=51136,dst_port=8080
  2. #2:服务器已确认 (SYN+ACK)
  3. #3: 客户端已确认服务器,TCP 连接成功建立
  4. #4:客户端发送了一个字节数据包106
  5. #5: 服务器已确认#4
  6. #6:服务器在之后立即重置此连接#5

此 TCP 流的时间序列在此处重新描述:

图 2.1 有问题的 TCP 流的时间序列

2.4 根本原因

客户端看到一个如图 2.1 所示的拓扑:

图 2.2 两侧的客户端视图

它发起了一个连接,该连接被服务器成功接受,即 3 次握手完成,没有任何错误。但是在传输数据时, 服务器立即拒绝了此连接。因此,问题必须存在于 服务器端。

深入研究服务器端,我们发现一个 sidecar(具体来说是 envoy) 已注入到服务器端容器。如果你不熟悉这个 word,请参考 Istio 的一些介绍性文档。 简而言之,sidecar 充当服务器容器和 外面的世界:

  • 在 Ingress 方向上,它会拦截到 Server 的所有 Ingress 流量,做一些 处理,然后将允许的流量转发到 Server
  • 在 egress 方向上,它会拦截来自服务器的所有 egress 流量,再次执行 some 处理,并将允许的流量转发到外部世界。

流量拦截是通过 Istio 中的 iptables 规则实现的。 详细实现的解释在本文的范围之外, 但如果您有兴趣,可以参考附录 A 中的图表。

这就是魔力所在:客户端和 server 直接访问,但拆分为 2 个单独的连接

  1. 客户端和 sidecar 之间的连接
  2. Sidecar 和 Server 之间的连接

这两个连接是独立的握手,因此即使后者 失败,前者仍然可以成功。

图 2.3 双方的实际视图:一个中间人坐在客户端和服务器之间

这就是确切发生的情况:由于某些内部原因,服务器无法启动 错误,但 Client 和 sidecar 之间的连接已建立。什么时候 客户端开始发送数据包,sidecar 先 ack 接收,然后 将此转发到(失败的)服务器,但被拒绝。然后它意识到 后端服务不可用,因此关闭 (RST) 了 自身和 Client 端。

图 2.4 sidecar 和服务器之间的连接未建立

3. 结束语

在现代,底层网络基础设施越来越强大 且灵活,但代价是堆栈深度更深,并且构成更多 开发人员和维护人员的故障排除挑战。这不可避免 需要更深入地了解网络基础设施、虚拟化 技术、内核堆栈等。

4. 附录 A:Istio Sidecar 拦截

图 4.1 使用 iptables 规则的 Istio sidecar 拦截(入站)

对应的 iptables 规则:

<span style="color:#333333"><span style="background-color:#f8f8f8"><span style="background-color:#f6f8fa"><code><span style="color:#999988"><em># get the Pod netns</em></span>
<span style="color:#008080">$ </span>docker inspect <Container ID or Name> | <span style="color:#0086b3">grep</span> <span style="color:#dd1144">\"</span>Pid<span style="color:#dd1144">\"</span><span style="color:#dd1144">"Pid"</span>: 82881,<span style="color:#999988"><em># show iptables rules in Pod netns</em></span>
<span style="color:#008080">$ </span>nsenter <span style="color:#000080">-t</span> 82881 <span style="color:#000080">-n</span> iptables <span style="color:#000080">-t</span> nat <span style="color:#000080">-nvL</span>
Chain PREROUTING <span style="color:#000000"><strong>(</strong></span>policy ACCEPT 1725 packets, 104K bytes<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destination2086  125K ISTIO_INBOUND  tcp  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0Chain INPUT <span style="color:#000000"><strong>(</strong></span>policy ACCEPT 2087 packets, 125K bytes<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destinationChain OUTPUT <span style="color:#000000"><strong>(</strong></span>policy ACCEPT 465 packets, 29339 bytes<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destination464 27840 ISTIO_OUTPUT  tcp  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0Chain POSTROUTING <span style="color:#000000"><strong>(</strong></span>policy ACCEPT 498 packets, 31319 bytes<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destinationChain ISTIO_INBOUND <span style="color:#000000"><strong>(</strong></span>1 references<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destination362 21720 ISTIO_IN_REDIRECT  tcp  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0            tcp dpt:8080Chain ISTIO_IN_REDIRECT <span style="color:#000000"><strong>(</strong></span>1 references<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destination362 21720 REDIRECT   tcp  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0            redir ports 15001Chain ISTIO_OUTPUT <span style="color:#000000"><strong>(</strong></span>1 references<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destination0     0 ISTIO_REDIRECT  all  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      lo      0.0.0.0/0           <span style="color:#000000"><strong>!</strong></span>127.0.0.1420 25200 RETURN     all  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0            owner UID match 13370     0 RETURN     all  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0            owner GID match 133711   660 RETURN     all  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            127.0.0.133  1980 ISTIO_REDIRECT  all  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0Chain ISTIO_REDIRECT <span style="color:#000000"><strong>(</strong></span>2 references<span style="color:#000000"><strong>)</strong></span>pkts bytes target     prot opt <span style="color:#000000"><strong>in     </strong></span>out     <span style="color:#0086b3">source               </span>destination33  1980 REDIRECT   tcp  <span style="color:#000080">--</span>  <span style="color:#000000"><strong>*</strong></span>      <span style="color:#000000"><strong>*</strong></span>       0.0.0.0/0            0.0.0.0/0            redir ports 15001</code></span></span></span>

相关文章:

现代网络基础设施中的 TCP 握手之下

TCP 3 次握手 在最简单的形式中&#xff0c;TCP 三次握手很容易理解&#xff0c;并且有 大量在线材料都在讨论这个问题。&#xff08;如果你能读懂 Chinease&#xff0c;你可以看看我之前的一篇文章。 然而&#xff0c;在实际中理解、练习和解决 TCP 问题 世界是另一回事。随…...

GRAPE——RLAIF微调VLA模型:通过偏好对齐提升机器人策略的泛化能力(含24年具身模型汇总)

前言 24年具身前沿模型大汇总 过去的这两年&#xff0c;工作之余&#xff0c;我狂写大模型与具身的文章&#xff0c;加之具身大火&#xff0c;每周都有各种朋友通过CSDN私我及我司「七月在线」寻求帮助/指导(当然&#xff0c;也欢迎各大开发团队与我司合作共同交付&#xff09…...

NeurIPS 2024 | 像素级LLM实现图像视频理解、生成、分割和编辑大统一(昆仑万维等)

Accepted by NeurIPS 2024 文章链接&#xff1a;https://arxiv.org/pdf/2412.19806 项目链接&#xff1a;https://vitron-llm.github.io/ Github链接&#xff1a;https://github.com/SkyworkAI/Vitron 亮点直击 首次提出了一种通用的视觉多模态大语言模型&#xff08;MLLM&…...

中药和西药的区别

中药和西药的区别 一、定义与来源 &#xff08;一&#xff09;中药 中药主要是在中国传统医学理论指导下用于预防、诊断、治疗疾病或调节人体机能的药物。它的来源广泛&#xff0c;包括植物药、动物药、矿物药等。植物药是中药的主要组成部分&#xff0c;例如人参&#xff0…...

Spring Security(maven项目) 3.0.2.4版本

前言&#xff1a; 通过实践而发现真理&#xff0c;又通过实践而证实真理和发展真理。从感性认识而能动地发展到理性认识&#xff0c;又从理性认识而能动地指导革命实践&#xff0c;改造主观世界和客观世界。实践、认识、再实践、再认识&#xff0c;这种形式&#xff0c;循环往…...

【Ubuntu】安装华为的MindSpore

目录 1 安装Anaconda 2 更换国内源 3 安装MindSpore 1 安装Anaconda 2 更换国内源 具体方法如下&#xff1a; 打开命令行 cmd 工具&#xff0c;输入以下命令。 ① Conda 换源 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ c…...

【模型】Qwen2-VL 服务端UI

1. 前言 最近在测试VLM模型&#xff0c;发现官方的网页demo&#xff0c;代码中视频与图片分辨率可能由于高并发设置的很小&#xff0c;导致达不到预期效果&#xff0c;于是自己研究了一下&#xff0c;搞了一个简单的前端部署&#xff0c;自己在服务器部署了下UI界面&#xff0…...

计算机网络•自顶向下方法:网络层介绍、路由器的组成

网络层介绍 网络层服务&#xff1a;网络层为传输层提供主机到主机的通信服务 每一台主机和路由器都运行网络层协议 发送终端&#xff1a;将传输层报文段封装到网络层分组中&#xff0c;发送给边缘路由器路由器&#xff1a;将分组从输入链路转发到输出链路接收终端&#xff1…...

安卓11 SysteUI添加按钮以及下拉状态栏的色温调节按钮

最近客户想要做一个台灯产品&#xff0c;需要实现 串口调节台灯功能 &#xff0c;其中包括 亮度调节 色温调节 开关 三个功能 话不多说&#xff0c;贴代码 diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml old mode 100644 new …...

多个线程处理不同的数据,等线程都完成后再进行下一步操作

现在有三个任务,三个任务之间没有关联关系,但是第四个任务要等前三个完成之后才能进行,于是使用多线程完成前三个任务节省时间 示例代码: public void saveDataByOnlineTimeNew(LocalDateTime startTime, LocalDateTime endTime) {Objects.requireNonNull(startTime, "开…...

聆听音乐 1.5.9 | 畅听全网音乐,支持无损音质下载

聆听音乐手机版是面向广大音乐爱好者的移动应用程序&#xff0c;用户可以随时随地通过手机享受丰富的音乐资源。它提供了多种魅力功能&#xff0c;让用户在手机上畅享更舒适的音乐体验&#xff0c;每位用户都能享受精彩纷呈的收听体验。此外&#xff0c;软件还支持无损音质音乐…...

Rust 基础入门指南

Rust 基础入门指南 1. Rust 语言概述 Rust 的历史与设计理念 Rust 是由 Mozilla 研究院的 Graydon Hoare 于2010年开始创建的系统编程语言。其设计目标是创建一种安全、并发、实用的编程语言&#xff0c;特别关注内存安全和并发性。 Rust 的核心设计理念包括&#xff1a; …...

青少年编程与数学 02-006 前端开发框架VUE 03课题、编写APP组件

青少年编程与数学 02-006 前端开发框架VUE 03课题、编写APP组件 一、组件二、VUE中的组件三、APP组件四、应用示例1. App.vue - 根组件2. HelloWorld.vue - 子组件3. main.js - 应用入口文件4. router/index.js - 路由配置文件5. index.html - HTML入口文件6. package.json - 项…...

基于Java的银行排号系统的设计与实现【源码+文档+部署讲解】

目 录 内容提要 1. 引言 2. 系统分析 2.1 系统初步调查 2.2 系统可行性分析 2.2.1 经济可行性 2.2.2 操作可行性 2.2.3 技术可行性 2.3 系统开发环境概述 2.3.1 硬件环境 2.3.2 软件环境 2.4 系统需求分析 2.4.1 业务流程分析 2.4.2 系统体系结构设计 2.4.3 系统逻辑模型 2.5 …...

linux-26 文件管理(四)install

说一个命令&#xff0c;叫install&#xff0c;man install&#xff0c;install是什么意思&#xff1f;安装&#xff0c;install表示安装的意思&#xff0c;那你猜install是用来干什么的&#xff1f;猜一猜干什么的&#xff1f;安装软件&#xff0c;安装第三方软件&#xff0c;错…...

VS2015中使用boost库函数时报错问题解决error C4996 ‘std::_Copy_impl‘

在VS2015中使用boost库函数buffer时遇到问题&#xff0c;其他函数定义均能执行&#xff0c;当加上bg::buffer(参数输入正确);语句后就报如下错误&#xff1a; 错误 C4996 std::_Copy_impl: Function call with parameters that may be unsafe - this call relies…...

pikachu靶场--目录遍历和敏感信息泄露

pikachu靶场—目录遍历和敏感信息泄露 目录遍历 概述 在web功能设计中,很多时候我们会要将需要访问的文件定义成变量&#xff0c;从而让前端的功能便的更加灵活。 当用户发起一个前端的请求时&#xff0c;便会将请求的这个文件的值(比如文件名称)传递到后台&#xff0c;后台再…...

植物大战僵尸杂交版3.0.2版本

更新内容 植物大战僵尸杂交版3.0.2版本的更新内容如下&#xff1a; • 修复BUG&#xff1a; • 游戏内贴图错乱的BUG。 • 无尽模式卡死的BUG。 • 卡牌模仿者的一系列BUG。 • 干扰车可能同时出现多辆的BUG。 • 冒险模式部分关卡无法过关的BUG。 • 新增内容&#xf…...

kafka怎么保证顺序消费?

kafka怎么保证顺序消费&#xff1f; 1. 分区内的顺序保证2. 并发消费3. 实现顺序消费的策略4. 注意事项 kafka创建 topic 的时候没有指定分区数量&#xff0c;那么默认只会有一个分区。如果你想要创建一个具有多个分区的 topic&#xff0c;你可以在创建 topic 的命令中指定 --p…...

Makefile 模板 --- 内核模块

内核模块模板 驱动源码同级目录下 #******************************************************************************* # xxx Co., Ltd. All Right Reserved. # Author : # Version : V1.0.0 2020.10.21 # Description : # Note : gaoyang3513163.co…...

仓库叉车高科技安全辅助设备——AI防碰撞系统N2024G-2

在当今这个高效运作、安全第一的物流时代&#xff0c;仓库作为供应链的中心地带&#xff0c;其安全与效率直接关系到企业的命脉。 随着科技的飞速发展&#xff0c;传统叉车作业模式正逐步向智能化、安全化转型&#xff0c;而在这场技术革新中&#xff0c;AI防碰撞系统N2024G-2…...

计算机视觉CV期末总复习

1.计算机视觉基础 数字图像表示 二值图像 仅包含黑白两种颜色的图像&#xff0c;只使用1个比特为&#xff08;0黑或1白&#xff09;表示 彩色图像&#xff1a;分不同的颜色空间 gray灰度图像 每个像素只有一个采样颜色&#xff0c;取值范围0--255&#xff0c;为8比特位&a…...

【微信小程序获取用户手机号

微信小程序获取用户手机号有2种,一种是前端自己解密,一种是获取后发给后端,后端去解密 重点:要在微信公众平台设置里面绑定微信开放平台账号,不然反解不出来用户手机号上代码: <button style"font-size: 16px;" open-type"getPhoneNumber" getphonenumb…...

WFP Listbox绑定数据后,数据变化的刷新

Listbox绑定数据通过ItemsSource来的&#xff0c;如果绑定的是普通的List<数据>&#xff0c;不会自己刷新。 使用ObservableCollection集合 解决问题的方法: 将数组替换为 ObservableCollection ObservableCollection 是专为绑定设计的集合类型&#xff0c;可以通知 W…...

Android Camera压力测试工具

背景描述&#xff1a; 随着系统的复杂化和业务的积累&#xff0c;日常的功能性测试已不足以满足我们对Android Camera相机系统的测试需求。为了确保Android Camera系统在高负载和多任务情况下的稳定性和性能优化&#xff0c;需要对Android Camera应用进行全面的压测。 对于压…...

【华为OD-E卷 - 最优资源分配 100分(python、java、c++、js、c)】

【华为OD-E卷 - 最优资源分配 100分&#xff08;python、java、c、js、c&#xff09;】 题目 某块业务芯片最小容量单位为1.25G&#xff0c;总容量为M*1.25G&#xff0c;对该芯片资源编号为1&#xff0c;2&#xff0c;…&#xff0c;M。该芯片支持3种不同的配置&#xff0c;分…...

字符串格式时间(HH-MM)添加间隔时间后转为HH-MM输出

转换时间代码如下所示 #include <iostream> #include <iomanip> #include <sstream>//添加时间转换为时间 std::string addMinutesToTime(const std::string& timeStr, int minutesToAdd) {int hours, minutes;char delimiter;//解析输入时间std::istri…...

SQL 基础教程 - SQL ORDER BY 关键字

SQL ORDER BY 关键字 ORDER BY 关键字用于对结果集进行排序。 SQL ORDER BY 关键字 ORDER BY 关键字用于对结果集按照一个列或者多个列进行排序。 ORDER BY 关键字默认按照升序对记录进行排序。如果需要按照降序对记录进行排序&#xff0c;您可以使用 DESC 关键字。 SQL ORD…...

STM32 软件I2C读写

单片机学习&#xff01; 目录 前言 一、软件I2C读写代码框架 二、I2C初始化 三、六个时序基本单元 3.1 引脚操作的封装和改名 3.2 起始条件执行逻辑 3.3 终止条件执行逻辑 3.4 发送一个字节 3.5 接收一个字节 3.5 发送应答&接收应答 3.5.1 发送应答 3.5.2 接…...

neo4j学习笔记

图数据库 图数据库是基于图论实现的一种NoSQL数据库&#xff0c;其数据存储结构和数据查询方式都是图论为基础的&#xff0c;图数据库主要用于存储更多的连接数据。 图论&#xff08;GraphTheory&#xff09;是数学的一个分支。图论以图为研究对象&#xff0c;图论的图是由若干…...