How node-ntrip/caster works
1. This repository is a TypeScript library, not a full app. Its main job is to implement an NTRIP caster that can also act as an NTRIP client/server bridge and speak multiple transport protocols around RTCM/NMEA data.
2. The center of the design is the Caster domain layer (src/caster.ts) with supporting models like Connection, Mountpoint, Sourcetable, and Auth. These pieces represent the runtime registry of streams, connected clients/sources, and access control decisions.
3. src/auth.ts defines the authentication boundary. The README shows authentication is user-supplied through an authManager.authenticate(...) callback, so auth is intentionally pluggable rather than hardcoded.
4. Transport handling is abstracted under src/transport/. This is the main architectural boundary between the caster core and the outside world: transports adapt external I/O into a common internal flow of connections and stream data.
5. The server-side NTRIP entry point is src/transport/server/ntrip.ts, backed by src/transport/server/socket.ts. This layer listens on a port, handles TLS if configured, and negotiates HTTP/RTSP/RTP plus NTRIP V1/V2 behavior.
6. The push/pull bridge lives in src/transport/client/ntrip-push-pull.ts. It connects this caster to another caster in either push or pull mode, mapping a local mountpoint to a remote mountpoint and handling remote credentials and protocol selection.
7. Additional client/server transports extend the same model for non-NTRIP I/O:
- serial.ts for serial port input/output
- socket-client.ts for raw TCP/IP client connections
- file.ts and stream.ts for file and stream-based reading/writing
These are alternative ingress/egress paths into the same caster/core stream pipeline.
8. Utility code in src/util/ supports protocol and metadata handling:
- ntrip-http-parser.ts parses NTRIP-style HTTP requests
- rtp.ts handles RTP-related framing/processing
- auto-source-entry.ts likely builds sourcetable/source metadata automatically
- simple-logger.ts provides lightweight internal logging
9. src/sourcetable.ts is the metadata publication layer. In NTRIP, sourcetables describe available mountpoints and streams, so this module is the outward-facing catalog generated from the caster’s internal state and transport configuration.
10. src/index.ts is the public API surface that re-exports the library’s main entry points. For an architecture diagram, this is the boundary consumers use to create a Caster and attach one or more transports.
11. The repository includes a local type declaration under src/@types/ecef-projector, which suggests some geometry/coordinate-projection functionality is used indirectly for source metadata or related calculations, even though it is not a primary subsystem.
12. Tests are narrowly scoped around protocol parsing, with src/__tests__/util/ntrip-http-parser.ts covering the HTTP/NTRIP parser. That indicates the most critical logic is in request interpretation and transport negotiation rather than in business workflows.
13. A useful way to diagram the runtime flow is:
external client/source → transport adapter → auth gate → connection/mountpoint handling in the caster → sourcetable/stream distribution → other clients or downstream transports.
The push/pull bridge is the main feedback loop, because it can act as both sink and source between two casters.
14. In short, the architecture is a protocol/transport adapter layer around a central caster core, with pluggable authentication and multiple I/O backends feeding a shared mountpoint/sourcetable model.
Main entry points: caster.ts Caster · index.ts Transport API · ntrip.ts NTRIP Server · sourcetable.ts Sourcetable
Components 20
Public API
Library entry points used by consumers
- Index · Re-exports the library surface for consumers
src/index.ts
Caster core
Runtime registry, access control, and metadata model
- Caster · Central runtime that manages mountpoints, connections, and stream flow
src/caster.ts - Auth · Pluggable authentication and authorization decisions
src/auth.ts - Connection · Represents a connected source or client
src/connection.ts - Mountpoint · Named stream endpoint managed by the caster
src/mountpoint.ts - Sourcetable · Publishes available mountpoints and stream metadata
src/sourcetable.ts
Transports
Adapters that connect external I/O to the caster
- Transport API · Shared transport abstractions and wiring
src/transport/index.ts - Transport · Base transport interface and common transport behavior
src/transport/transport.ts - NTRIP Server · Listens for NTRIP clients and negotiates protocol variants
src/transport/server/ntrip.ts - Socket Server · Socket and TLS support for server-side transports
src/transport/server/socket.ts - Push/Pull · Connects this caster to another caster as push or pull
src/transport/client/ntrip-push-pull.ts - Serial · Serial port ingress and egress
src/transport/client/serial.ts - Socket Client · Raw TCP/IP client connections
src/transport/client/socket-client.ts - File · File-based reading and writing
src/transport/misc/file.ts - Stream · Generic stream-based reading and writing
src/transport/misc/stream.ts
Utilities
Protocol parsing, framing, and support helpers
- HTTP Parser · Parses NTRIP-style HTTP requests
src/util/ntrip-http-parser.ts - RTP · Handles RTP-related framing and processing
src/util/rtp.ts - Auto Source · Builds sourcetable source entries automatically
src/util/auto-source-entry.ts - Logger · Lightweight internal logging helper
src/util/simple-logger.ts - ECEF Types · Local type declarations for coordinate/projection support
src/@types/ecef-projector/index.d.ts
Connections 27
- Index → Caster: exports · Public API exposes the central caster
- Index → Transport API: exports · Public API exposes transport entry points
- Caster → Auth: uses · Caster delegates access decisions to pluggable auth
- Caster → Connection: tracks · Caster maintains active source/client connections
- Caster → Mountpoint: routes · Caster binds traffic to named mountpoints
- Caster → Sourcetable: publishes · Caster state feeds sourcetable generation
- Transport API → Transport: defines · Transport layer exposes the shared adapter contract
- Transport API → NTRIP Server: includes · Server-side NTRIP transport is a main adapter
- Transport API → Push/Pull: includes · Push/pull bridge is a main adapter
- Transport API → Serial: includes · Serial transport is a supported adapter
- Transport API → Socket Client: includes · Raw socket client transport is supported
- Transport API → File: includes · File transport participates in the shared model
- Transport API → Stream: includes · Stream transport participates in the shared model
- NTRIP Server → Socket Server: uses · NTRIP server relies on socket/TLS handling
- NTRIP Server → HTTP Parser: parses · Server negotiates requests through the NTRIP HTTP parser
- NTRIP Server → RTP: frames · Server handles RTP-related data handling
- Push/Pull → HTTP Parser: negotiates · Bridge mode selects and interprets remote protocol behavior
- Push/Pull → Caster: bridges · Bridge connects local mountpoints to remote caster flow
- Serial → Caster: feeds · Serial I/O feeds the caster stream pipeline
- Socket Client → Caster: feeds · Socket client I/O feeds the caster stream pipeline
- File → Caster: feeds · File I/O is adapted into the caster pipeline
- Stream → Caster: feeds · Stream I/O is adapted into the caster pipeline
- Sourcetable → Mountpoint: describes · Sourcetable catalogs mountpoints and stream metadata
- Sourcetable → Auto Source: generates · Auto source entry utility helps build metadata
- Auto Source → ECEF Types: types · Metadata generation may depend on ambient coordinate types
- NTRIP Server → Logger: logs · Server transport uses internal logging
- Caster → Logger: logs · Core runtime emits operational logs