Key Concept: DataChannels ≠ Media
En Arq. 3, node-datachannel no transporta audio ni vídeo. El vídeo va por go2rtc (MJPEG/HLS) y el audio por Mumble. node-datachannel se usa solo para datos P2P: chat, archivos, señalización.
| Tipo | Transporte | Componente |
| Vídeo | MJPEG/HLS HTTP | go2rtc → Oasis proxy |
| Audio | Mumble + HTTP OGG | murmurd → bridge |
| Texto/chat | DataChannel P2P | node-datachannel |
| Archivos | DataChannel P2P | node-datachannel |
| Señalización | SSB feed + DataChannel | node-datachannel / SSB |
Identidad
| Campo | Valor |
| npm | node-datachannel |
| Binding de | libdatachannel (C/C++) — Paul-Louis Ageneau |
| Licencia | MPL-2.0 + MIT |
| RAM | ~5–10 MB (dentro de Oasis Node.js) |
Señalización SDP via SSB
PEER A (SNH) PEER B
│ 1. createOffer() → SDP │
│ ──── SDP offer via SSB msg (privado) ────────▷│
│ 2. createAnswer() → SDP │
│◁──── SDP answer via SSB msg ──────────────────│
│ ◀═══ ICE candidates (trickle via SSB) ═══════▷│
│ ◀══════ DataChannel OPEN ═══════════════════▷ │
La señalización viaja por SSB feed messages privados. No hace falta signaling server WebSocket — SSB ya es el transporte.
API Quick-Ref
const ndc = require('node-datachannel');
const peer = new ndc.PeerConnection('SNH', {
iceServers: []
});
const dc = peer.createDataChannel('chat');
dc.onOpen(() => dc.sendMessage('hello'));
dc.onMessage((msg) => console.log(msg));
peer.onLocalDescription((sdp, type) => {
ssbClient.publish({
type: 'webrtc-sdp', sdpType: type,
sdp, recps: [peerBId]
});
});
File Transfer
Chunk en bloques de 16 KB (límite SCTP). Enviar file-meta JSON → N chunks binarios → file-end JSON.
dc.sendMessage(JSON.stringify({ type:'file-meta', name:'foto.jpg', size:48230 }));
for (let i=0; i<buf.length; i+=16384) dc.sendMessageBinary(buf.slice(i, i+16384));
dc.sendMessage(JSON.stringify({ type:'file-end' }));
Archivos grandes o persistentes → SSB blobs (inmutables). DataChannel para archivos pequeños/urgentes.
LAN vs Remoto — ICE
| Escenario | iceServers | Funciona |
| LAN directa | [] vacío | ✔ |
| Tras NAT | [STUN + TURN] | ⚠️ |
| Tor | — | ✘ (UDP bloqueado) |
DataChannels no funcionan sobre Tor. Para datos Tor → SSB replication (TCP). DataChannels solo para LAN/clearnet.
Formato de Mensajes
{ "type": "chat", "text": "hola", "ts": 1711612800 }
{ "type": "file-meta", "name": "foto.jpg", "size": 48230 }
{ "type": "file-end" }
{ "type": "ping" }
{ "type": "pong", "rtt": 12 }
{ "type": "status", "video": true, "audio": true }
DRY rule: siempre JSON con campo type. Extensible sin romper parsers existentes.
Keywords
DataChannel
SCTP
SDP
ICE
libdatachannel
SSB feed
recps
offer/answer
16 KB chunk
P2P