[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,91 +2,180 @@
|
||||
id: wiki-2026-0508-protocols
|
||||
title: Protocols
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-PROT-001]
|
||||
aliases: [Communication Protocols, Network Protocols, Wire Protocols]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.96
|
||||
tags: [auto-reinforced, protocols, communication-standard, networking, rules, InterOperability]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [networking, protocols, systems, MCP]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: multi
|
||||
framework: HTTP-gRPC-MCP
|
||||
---
|
||||
|
||||
# [[Protocols|Protocols]]
|
||||
# Protocols
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "디지털 사회의 약속: 수많은 기기와 시스템이 서로 '외계어'를 주고받지 않고 정확히 소통할 수 있도록 만들어진 엄격한 대화의 규칙이자, 복잡한 네트워크를 지탱하는 질서의 뼈대."
|
||||
## 매 한 줄
|
||||
> **"매 communicating parties 가 매 따라야 하는 rules 의 명시"**. 매 syntax (frame format), 매 semantics (meaning of fields), 매 timing (sequencing) 의 3 axes 로 정의. 매 2026 의 hot stack: HTTP/3 (QUIC), gRPC, MCP (Model Context Protocol), WebSocket, MQTT 5.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
프로토콜(Protocols)은 컴퓨터나 기기 간의 데이터 통신을 위해 정의된 규약입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **3대 핵심 기능**:
|
||||
* **Addressing**: 누구에게 보낼 것인가? (정확한 수신처 식별).
|
||||
* **Handshaking**: 연결해도 되는가? (상호 연결 확인).
|
||||
* **Error Control**: 제대로 갔는가? (데이터 무결성 보장). ([[Fault-Tolerance|Fault-Tolerance]]와 연결)
|
||||
2. **왜 중요한가?**:
|
||||
* 프로토콜이 없다면 인터넷은 단 1초도 유지될 수 없으며, 서로 다른 명세의 지식이 섞이지 않도록 보장하는 지식 관리의 표준(Standard)이기 때문임. ([[Global-Standard|Global-Standard]]와 연결)
|
||||
### 매 protocol 의 layers
|
||||
- **Physical / Link**: Ethernet, Wi-Fi 7, 5G NR.
|
||||
- **Network**: IPv6 (default 2026), IPv4 legacy.
|
||||
- **Transport**: TCP, UDP, QUIC.
|
||||
- **Application**: HTTP/3, gRPC, MCP, MQTT, AMQP.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 고정된 기계적 규칙(TCP/IP 등) 정책이었으나, 현대 정책은 장치 간의 전력 상태나 데이터 중요도 정책에 따라 통신 방식을 바꾸는 '적응형 프로토콜 정책'으로 발전함(RL Update).
|
||||
- **정책 변화(RL Update)**: 본 시스템 내의 '지식 주입 프로토콜 정책(Batch-Loop)' 또한 에러 발생 시 재시도 정책이나 배치 크기 조절 정책을 포함하여, 지식 베이스 구축의 안정성 정책을 지키는 핵심 프로토콜 정책으로 작동 중임.
|
||||
### 매 design dimensions
|
||||
- **Stateful vs stateless**: 매 server-side state 보관 여부.
|
||||
- **Sync vs async**: 매 request-response vs publish-subscribe.
|
||||
- **Push vs pull**: 매 server-initiated vs client-initiated.
|
||||
- **Text vs binary**: 매 human-readable vs efficient.
|
||||
- **Versioning**: 매 backward / forward compatibility 의 strategy.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Fault-Tolerance|Fault-Tolerance]], [[Global-Standard|Global-Standard]], [[Technical-Architecture|Technical-Architecture]], [[Standard-Operating-Procedure|Standard-Operating-Procedure]], [[Hardware|Hardware]]
|
||||
- **Modern Tech/Tools**: HTTP/HTTPS, TCP/IP, MQTT, gRPC, WebSocket.
|
||||
---
|
||||
### 매 응용
|
||||
1. **Web**: HTTP/3 over QUIC — 매 default.
|
||||
2. **AI tools**: MCP (Anthropic 2024) 매 LLM ↔ tool 의 universal.
|
||||
3. **Microservices**: gRPC 매 internal RPC.
|
||||
4. **IoT**: MQTT 5 매 lightweight pub-sub.
|
||||
5. **Realtime**: WebSocket / WebTransport.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### MCP server (Anthropic, 2026 standard)
|
||||
```python
|
||||
from mcp.server import Server
|
||||
from mcp.types import Tool, TextContent
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
server = Server("knowledge-base")
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
@server.list_tools()
|
||||
async def tools():
|
||||
return [Tool(
|
||||
name="query",
|
||||
description="Query the KB",
|
||||
inputSchema={
|
||||
"type": "object",
|
||||
"properties": {"q": {"type": "string"}},
|
||||
"required": ["q"],
|
||||
},
|
||||
)]
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
@server.call_tool()
|
||||
async def call(name, args):
|
||||
return [TextContent(type="text", text=search(args["q"]))]
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### gRPC service (.proto + Python)
|
||||
```protobuf
|
||||
// kb.proto
|
||||
syntax = "proto3";
|
||||
service KB {
|
||||
rpc Query(QueryRequest) returns (stream QueryChunk);
|
||||
}
|
||||
message QueryRequest { string q = 1; }
|
||||
message QueryChunk { string text = 1; bool done = 2; }
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
```python
|
||||
# server.py
|
||||
import grpc, kb_pb2_grpc, kb_pb2
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
class KBServicer(kb_pb2_grpc.KBServicer):
|
||||
def Query(self, request, context):
|
||||
for chunk in stream_search(request.q):
|
||||
yield kb_pb2.QueryChunk(text=chunk, done=False)
|
||||
yield kb_pb2.QueryChunk(done=True)
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### HTTP/3 client (QUIC)
|
||||
```python
|
||||
# httpx + h2/h3
|
||||
import httpx
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
async with httpx.AsyncClient(http2=True, http3=True) as client:
|
||||
r = await client.get("https://api.example.com/v1/users")
|
||||
print(r.http_version) # "HTTP/3"
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### WebSocket realtime
|
||||
```python
|
||||
import asyncio
|
||||
import websockets
|
||||
|
||||
async def handler(ws):
|
||||
async for msg in ws:
|
||||
await ws.send(f"echo: {msg}")
|
||||
|
||||
async def main():
|
||||
async with websockets.serve(handler, "0.0.0.0", 8765):
|
||||
await asyncio.Future() # run forever
|
||||
```
|
||||
|
||||
### MQTT 5 pub-sub (IoT)
|
||||
```python
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
print(f"{msg.topic}: {msg.payload.decode()}")
|
||||
|
||||
client = mqtt.Client(protocol=mqtt.MQTTv5)
|
||||
client.on_message = on_message
|
||||
client.connect("broker.example.com", 1883)
|
||||
client.subscribe("sensors/+/temperature")
|
||||
client.loop_forever()
|
||||
```
|
||||
|
||||
### Protocol negotiation (capabilities handshake)
|
||||
```python
|
||||
# Common pattern: client sends supported versions, server picks highest mutual
|
||||
def negotiate(client_versions: set[str], server_versions: set[str]) -> str:
|
||||
common = client_versions & server_versions
|
||||
if not common:
|
||||
raise ProtocolError("no compatible version")
|
||||
return max(common, key=lambda v: tuple(map(int, v.split("."))))
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| Scenario | Protocol |
|
||||
|---|---|
|
||||
| 매 LLM ↔ tools | MCP |
|
||||
| 매 internal RPC, polyglot | gRPC over HTTP/2 |
|
||||
| 매 public web API | HTTP/3 + JSON / OpenAPI |
|
||||
| 매 realtime browser | WebSocket / WebTransport |
|
||||
| 매 IoT constrained | MQTT 5 / CoAP |
|
||||
| 매 message queue | AMQP 1.0 / Kafka |
|
||||
| 매 streaming chat | Server-Sent Events / WebSocket |
|
||||
|
||||
**기본값**: 매 public = HTTP/3 + JSON, 매 internal = gRPC, 매 LLM tools = MCP.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Networking]] · [[Distributed-Systems]]
|
||||
- 변형: [[HTTP]] · [[gRPC]] · [[MCP]] · [[WebSocket]]
|
||||
- 응용: [[API-Design]] · [[Microservices]] · [[IoT]]
|
||||
- Adjacent: [[Interoperability]] · [[Serialization]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 protocol selection, 매 wire format debugging, 매 backward-compat strategy review.
|
||||
**언제 X**: 매 single-process in-memory calls — 매 protocol 무용.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Custom snowflake protocol**: 매 in-house wire format 매 ecosystem 의 X.
|
||||
- **No version negotiation**: 매 deploy mismatch → cascade failure.
|
||||
- **Stateful with no session**: 매 load balancer 매 sticky session 강제 → scaling pain.
|
||||
- **Chatty protocols**: 매 N round trips 매 single op → latency.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (RFC 9114 HTTP/3, 9000 QUIC; gRPC.io; Anthropic MCP spec 2024; OASIS MQTT 5; OASIS AMQP 1.0).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — protocol layers + 2026 modern stack (MCP, HTTP/3, gRPC) |
|
||||
|
||||
Reference in New Issue
Block a user