# 交互协议
# Flag
端到端、服务到服务、端到服务之间的交互协议规范
- https://github.com/schemaorg (opens new window)
- OpenAPI规范 https://github.com/OAI (opens new window)
- https://github.com/graphql (opens new window)
- https://graphql.org (opens new window)
- https://github.com/chentsulin/awesome-graphql (opens new window)
- https://github.com/apollographql (opens new window)
- https://github.com/dotansimha/graphql-yoga (opens new window)
- https://github.com/n1ru4l/envelop (opens new window)
- https://github.com/zhnd/query-box (opens new window)
- C# https://github.com/dotnet/wcf (opens new window)
- Java https://github.com/apache/cxf (opens new window)
- https://axis.apache.org (opens new window)
一维码/二维码
usps智能邮件条形码(Intelligent Mail 条形码)、Japanpost(Japanese Postal Code)、Koreapost、RoyalMail(RM4SCC)、RoyalMailMailmark(Royal Mail 4-State Mailmark)、DeutschePostIdentCode、DeutshePostLeitCode、LOGMARS、Telepen、TelepenNumeric、Databar、DatabarLimited、DatabarOmniStacked、DatabarStacked、DatabarTruncated、UKPlessey、KIX、VINCode、Pharmacode、Pharmacode2Track、Planet、MSIPlessey、SSCC18、Flattermarken、PostNet、Code11、ChannelCode、ITF14、GS128、Code39码(标准39码)、Codabar码(库德巴码)、Code25码(标准25码)、ITF25码(交叉25码)、Matrix25码(矩阵25码)、UPC-A码、UPC-E码、EAN-13码(EAN-13国际商品条码)、EAN-8码(EAN-8国际商品条码)、中国邮政码(矩阵25码的一种变体)、Code-A/B/C码、MSI码、Code11码、Code93码、ISBN码、ISSN码、Code128码(Code128码,包括EAN128码)、Code39EMS(EMS专用的39码)
MicroQRCode、UPNQR、PDF417Truncated、MicroPDF417、PDF417、Data Matrix、AZTEC、AztecRunes、Code16K、CodablockF、Code49、CodeOne、DotCode、GridMatrix、MaxiCode、QR Code、Vericode、Ultracode、Code 49、Code 16K、Code One、GS1 DataBar、DataBar、GS1 DataBar Expanded、GS1 DataBar Limited、Grid Matrix、Maxi、Han Xin Code(汉信码)、CP、Codablock F、Semacode、DataGlyphs
- 矩阵式二维码
- 堆叠式/行排式
# 数据传输模型
该模型用于帮助人们解决应用程序与服务器传递数据的问题
- API架构风格对比:SOAP vs REST vs GraphQL vs RPC (opens new window)
- REST 和 gRPC 的详细比较 (opens new window)
- JMS Java消息服务(Java Message Service) (opens new window)
- 技术概念大揭秘-RPC/Restful/HTTP/SOAP/WebService傻傻分不清楚? (opens new window)
- 既然有 HTTP 请求,为什么还要用 RPC 调用? (opens new window)
- Web Services 模型 (opens new window)(理念/领域)
- SOAP(Simple Object Access Protocol,简单对象访问协议) (opens new window) https://www.w3.org/TR/soap
- WSDL (Web Services Description Language) https://www.w3.org/TR/wsdl20 描述服务接口
- SOAP over HTTP
- SOAP over TCP
- SOAPover Message Queues
- RSS Syndication Services
- WS-Discovery
- WS-Addressing 提供消息寻址功能
- WS-AtomicTransaction 支持分布式事务
- WS-ReliableMessaging 确保消息的可靠传输
- WS-Security 用于消息级的安全,包括加密、签名和身份验证
- JAX-WS(Java API for XML-based Web services)
- UDDI (Universal Description, Discovery and Integration) (opens new window)
- RPC(Remote Procedure Call)模型(面向方法)https://en.wikipedia.org/wiki/Remote_procedure_call#General (opens new window)
- XML-RPC (opens new window) SOAP 本质上是 XML-RPC 的升级版
- JSON-RPC (opens new window) https://www.jsonrpc.org (opens new window)
- JAX-RPC
- gRPC (Google Remote Procedure Call)
- REST(Representational State Transfer) 模型(面向资源)(现代 Web API 风格)
- REST API
- RestFul API/RESTful Web Service
- GraphQL
- Windows Communication Foundation (WCF),以前称为Indigo
- SOAP(Simple Object Access Protocol,简单对象访问协议) (opens new window) https://www.w3.org/TR/soap
- SOA(Service Oriented Architecture)面向服务的架构
- RCON (opens new window)
- CORBA (Common Object Request Broker Architecture) 分布式对象技术规范
- IDL (Interface Definition Language)
- IIOP (Internet Inter-ORB Protocol, TCP)
- RPC(remote procedure call,远程过程调用):一种通过网络从远程计算机程序上跨语言跨平台的请求服务。主要是分布式式系统中应用。
- RPC按通信协议,可以分为:基于HTTP的、基于TCP等;
- 按报文协议可以分为:基于XML文本的、基于JSON文本的,二进制的;
- 按照是否跨平台语言,可以分为:平台专用的,平台中立的
- SOAP(Simple Object Access Protocol,简单对象访问协议):基于 HTTP或 SMTP等多种网络标准规约,它是向网络上的其他计算机传送 XML文档而定义标准Package结构的通信规约息。
- WSDL (WebServices Description Language):WEB服务描述语言,它是Web Service服务端使用说明书,说明服务端接口、方法、参数和返回值,随服务发布自动生成
- RMI(remote method invocation,面向对象的远程方法调用)
- REST(representational state transfer,表达性状态转移)
- Restful:一种接口规范,符合这套规范编写的接口就是restful 接口
- JMS(Java Messaging Service)Java 消息服务
- EJB(enterprise java bean)
- JNDI(Java naming and Directory Interface)
- JRMP(Java Remote Method Protocol)
- Webservice RPC风格 SOAP,REST风格 各之间的对比 (opens new window)
- 什么是 RESTful ?到底 REST 和 SOAP、RPC 有何区别? (opens new window)
- 正确甄别API & REST API & RESTful API & Web Service之间的差异与联系 (opens new window)
- 远程通信的几种选择(RPC,Webservice,RMI,JMS的区别) (opens new window)
- SOAP webserivce 和 RESTful webservice 对比及区别 (opens new window)
- 如何通俗易懂地解释什么是SOA? (opens new window)
- RESTful API设计参考文献列表 https://github.com/aisuhua/restful-api-design-references (opens new window)
- https://zh.wikipedia.org/wiki/HATEOAS (opens new window)
- RESTful API设计规范 https://github.com/godruoyi/restful-api-specification (opens new window)
- RESTful API设计规范 (opens new window)
- RESTful跟WebService的区别 (opens new window)
# 网络通信协议
- HTTP状态码 https://github.com/leonlarsson/http-raccoons (opens new window)
- https://evertpot.com/http (opens new window)
应用层
Gopher -> HTTP -> Gemini
- WebDav/CalDav/CardDav/WebCal/iCalendar (opens new window)
- WebDAV (opens new window)
- https://github.com/JackJiang2011/MobileIMSDK (opens new window)
- Server-Sent Events (SSE) 只支持服务端->客户端的单向通讯 Server-Sent Events 详解及实战 (opens new window)
- WebSocket(SignalR)支持服务端<->客户端的双向实时通讯
- HTTP(Hypertext Transfer Protocol)超文本传输协议,显示网页,只支持客户端->服务端的单向通讯
- Gemini https://gemini.circumlunar.space (opens new window)
- DNS(Domain Name System)
- FTP(File Transfer Protocol)
- SFTP(SSH File Transfer Protocol)和FTP不一样
- SCP(Secure copy)基于SSH
- ASCII
- Xmodem
- Ymodem
- Zmodem
- Kermit
- SSH (Secure Shell)
- SMTP(Simple Mail Transfer Protocol)
- SNMP(simple Network Management Protocol)
- Socket (opens new window) 是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口。
- 在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏在Socket接口后面
- AMQP(Advanced Message Queuing Protocol,高级消息队列协议)
- XMPP(Extensible Messaging and Presence Protocol,Jabber)
- OTR(Off-the-Record Messaging,不留记录即时通讯协议) https://hardenedlinux.github.io/cryptography/2018/02/01/pidgin_xmpp_otr_debian.html
- OMEMO
- IMPP(Instant Messaging and Presence Protocol,即时消息和在线状态协议)
- STOMP(Streaming Text Oriented Messaging Protocol,流文本定向消息协议)
- MQTT(Message Queuing Telemetry Transport,消息队列遥测传输):是一种基于发布/订阅(publish/subscribe)模式的"轻量级"通讯协议
通信层
- TCP(Transmission Control Protocol)三次握手传输协议
- UDP(User Datagram Protocol)用户数据报协议
- mKCP
- gRPC
- QUIC
- meek
- TCP、Socket、WebSocket、HTTP (opens new window)
- 网络编程 socket详解 TCP socket和UDP socket (opens new window)
- 【Socket学习】1. TCP与UDP (opens new window)
- socket通信 tcp协议和udp协议 C++ (opens new window)
- UDP 和 TCP 的 socket 分别一般用在什么地方? (opens new window)
- https://wicg.github.io/direct-sockets (opens new window)
- https://github.com/NetAsmCom/Socketify (opens new window)
网络层
- IP(Internet Protocol)
- ICMP(Internet Control Message Protocol,主要用于路由发送错误报告)
- IGMP
链接层
- MAC(media access control)
- ARP
- RARP
Proxy代理协议
- VMess
- VLESS
- VLite
- Trojan
- Shadowsocks
- Socks
- HTTP
- Freedom
- Dokodemo
- Blockhole
- DNS
- Loopback
# HTTP
- https://github.com/topics/server (opens new window)
- https://github.com/topics/http-server (opens new window)
- https://github.com/topics/http-client (opens new window)
- https://github.com/search?q=WebSocket (opens new window)
- https://github.com/topics/websockets (opens new window)
- 互联网号码分配机构(IANA)官方MIME类型列表 (opens new window)
- 常用对照表 (opens new window)
- https://www.runoob.com/http/http-tutorial.html (opens new window)
- https://developer.mozilla.org/zh-CN/docs/Web/HTTP (opens new window)
- https://github.com/httpcats/http.cat (opens new window)
- HTTPS的工作原理 https://stephanietang.github.io/2020/04/19/how-https-works (opens new window)
- 图解QUIC连接 https://cangsdarm.github.io/illustrate/quic (opens new window)
- 谈谈HTTP协议中的短轮询、长轮询、长连接和短连接 (opens new window)
- SSL为何改名为TLS (opens new window)
Content-Type只会存在于POST、PATCH、PUT等有请求数据实体时指定数据类型和数据字符集编码, 而GET、DELETE、HEAD、OPTIONS、TRACE等没有请求数据实体
Content-Length则视Content-Type而定,如text/html、text/javascript等请求数据没有Content-Length
- HTTP协议中的Accept与Content-Type的区别 (opens new window)
- https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Accept (opens new window)
- HTTP传输编码增加了传输量,只为解决这一个问题 | 实用 HTTP (opens new window)
- https://zh.wikipedia.org/wiki/分块传输编码 (opens new window)
POST、PATCH、PUT等请求有请求数据实体的数据为表单参数,GET、DELETE、HEAD、OPTIONS、TRACE等没有请求数据实体的查询参数拼接在URL?后面
# 无中心客户端发现(Peer Discovery)
| 网络环境 | 方案 | 原理 | 优点 | 缺点 | 适用场景 |
|---|---|---|---|---|---|
| 局域网 (LAN) | UDP 广播 (Broadcast) / 组播 (Multicast) | 客户端向广播地址(如 255.255.255.255)或特定组播地址发送 UDP 数据包,其他客户端监听特定端口接收并回复,完成握手和发现 | 实现极其简单,零依赖,局域网即插即用 | 不跨网段;广播风暴可能影响网络性能;部分路由器或安全策略会拦截广播包 | 同一局域网内少量客户端 |
| 局域网 (LAN) | mDNS (多播 DNS) 与 DNS-SD (DNS 服务发现) | 利用局域网多播机制发送 DNS 查询请求(如查询 _chat._tcp.local),提供服务的设备自动响应自己的 IP 和端口 | 行业标准,操作系统原生支持(Bonjour/Avahi),跨平台 | 不跨网段;服务名冲突需处理 | 局域网内服务自发现(AirPlay、打印机、文件共享) |
| 局域网 (LAN) | SSDP (简单服务发现协议) | UPnP 协议栈的一部分,基于 HTTP over UDP 组播。设备向组播地址(239.255.255.250:1900)发送 NOTIFY 消息,或发送 M-SEARCH 主动搜索服务 | 与现有智能家居/UPnP 生态兼容,标准化程度高 | 仅限局域网;安全性较弱,易被恶意利用 | 智能家居设备发现、DLNA 流媒体服务发现 |
| 广域网 (WAN) | P2P DHT (分布式哈希表 - Distributed Hash Table) (Kademlia / Chord) | 将网络视为巨大哈希环,每个节点维护与自己 ID 逻辑距离相近的一小部分路由信息;查找时逐跳向"更接近目标"的节点查询,最终定位目标 | 可扩展,查找效率高 O(logN),完全去中心化 | 实现复杂;存在"冷启动"悖论,必须依赖引导节点(Bootstrap)才能首次入网 | BitTorrent 磁力链接、IPFS、以太坊节点发现 |
| 广域网 (WAN) | Gossip Protocol(八卦/流言协议) | 每个节点周期性地随机挑选几个已知节点,交换彼此掌握的节点列表;经过有限次交换,全网节点信息达到最终一致性 | 极度去中心化,容错率极高,单个节点宕机不影响整体网络;可跨网段 | 收敛有延迟;持续的流量开销;需种子节点启动 | 分布式数据库集群(Redis Cluster、Cassandra)、Consul 状态同步 |
| 广域网 (WAN) | PEX (Peer Exchange) | 已建立连接的节点互相交换"自己已经确认存活的其他节点名单",从而快速扩展已知节点集合 | 发现新节点效率最高(前提是已连上活跃节点) | 不能独立工作,必须配合 DHT 或其他发现机制作为补充 | BitTorrent 网络(作为 DHT 的高效补充) |
| 广域网 (WAN) | 区块链 / 智能合约 | 将公链(如以太坊)作为去中心化注册中心;客户端上线时向智能合约写入自己的 IP/端口,其他客户端读取合约获取节点列表 | 完全去中心化,数据公开透明且不可篡改 | 写入需消耗时间和手续费(Gas);仅适合慢速、低频的长期节点注册 | 长期节点注册、低频更新的去中心化场景 |
| 物理近场 | BLE 广播 / Beacon | 设备利用蓝牙模块持续发送 Advertisement Data(广播包),周围设备无需配对,开启蓝牙扫描即可捕获并发现对方 | 无需配对,低功耗,完全不依赖外部网络基础设施 | 传输距离极短(通常 < 100m);传输速率低;需用户开启蓝牙 | AirDrop 发现阶段、近场联系人追踪(如 Exposure Notifications) |
| 物理近场 | Wi-Fi Direct / Wi-Fi Aware (NAN) | 设备本身充当微型 Wi-Fi 热点,通过特定管理帧广播自己的存在;发现后直接建立点对点高速连接 | 传输速率高,无需路由器,可传输大文件 | 功耗较高;距离受限;设备兼容性参差不齐 | 无网络环境下的近场大数据传输、设备直连 |
| 基础设施 | Redis 发布/订阅 | 以 Redis 作为消息中间件,客户端通过发布/订阅频道进行节点信息交换 | 简单可靠,跨网段,支持持久化 | Redis 本身是中心节点(但极轻量) | 已有 Redis 基础设施的环境 |
| 基础设施 | ZooKeeper / Etcd | 分布式协调服务,利用临时节点实现注册与发现;支持 Watch 机制实时通知节点变化 | 强一致性,Watch 机制实时通知,可靠性高 | 运维成本高,本身是中心依赖,存在单点集群压力 | 需要强一致性的集群服务发现 |
- https://github.com/topics/gossip-protocol (opens new window)
- https://github.com/topics/swim-protocol (opens new window)
- https://github.com/scalecube/scalecube-cluster (opens new window)
- https://github.com/belaban/JGroups (opens new window)
- https://github.com/jmdns/jmdns (opens new window)
- https://github.com/dnsjava/dnsjava (opens new window)
- https://github.com/ECF (opens new window)
- https://github.com/posicks/mdnsjava (opens new window)
- https://github.com/fflewddur/hola (opens new window)
- https://github.com/petretiandrea/mDNSResponder (opens new window)
- https://github.com/anroidArchtict/avahi4j (opens new window)
- https://github.com/mstipanov/waiter (opens new window)
- https://github.com/4ntoine/ServiceDiscovery-java (opens new window)
- https://github.com/discord/RxDNSSD (opens new window)
- https://github.com/openslp-org/openslp (opens new window)