Skip to main content

A Network Protocol Framework

Project description

Netcore

JOSS Paper PyPI - Version License: MIT

English | 简体中文

Netcore is a lightweight communication framework specifically designed for concurrent message transmission within a single connection. Through innovative message chunking and scheduling mechanisms, it enables simultaneous processing of multiple message streams without establishing multiple connections, significantly improving communication efficiency in resource-constrained scenarios.

Core Features

🚀 Concurrent Transmission Engine

Single-connection multiplexing: Implements logically concurrent message streams on a single physical connection • Intelligent chunk scheduling: Automatically splits large messages into chunks for interleaved transmission, maximizing bandwidth utilization • Non-blocking I/O: Decouples message transmission from business processing to ensure system responsiveness

📦 Protocol & Transport

Adaptive protocol layer: • Supports binary/JSON/raw data formats • Configurable chunk size (default 4KB) • Hybrid memory-file storage mode • Transport abstraction interface: • Compatible with any I/O devices (serial/TCP/Bluetooth/etc.) • Provides dual-mode synchronous/asynchronous APIs • Thread-safe message queue management

🧩 Enterprise-grade Capabilities

Blueprint system: • Modular routing groups (supports prefixes and nesting) • Blueprint-level middleware and error handling • Hot-swappable component registration • Event hub: • Publish-subscribe pattern • One-time event binding • System lifecycle event monitoring (startup/shutdown/error) • Task scheduler: • Millisecond-level timing tasks • Adaptive priority queues • Failed task retry mechanism • Smart caching: • LRU memory cache • TTL auto-expiration • Cache penetration protection • Thread-safe access

Installation

pip install netcore

System Requirements: • Python ≥ 3.8 • No external dependencies (pure standard library implementation)

Quick Start

Basic Example: Serial Communication

from netcore import Endpoint, Pipe
import serial

# Initialize serial device
ser = serial.Serial('/dev/ttyUSB0', 115200)

# Create communication pipe (only requires read/write functions)
pipe = Pipe(ser.read, ser.write)
endpoint = Endpoint(pipe)

# Register message handler
@endpoint.request('sensor_data')
def handle_sensor():
    return Response('sensor_ack', {"status": "OK"})

# Start service (default 4 worker threads)
endpoint.start()

Architecture Overview

  1. Application Layer (Endpoint)
    • Routing system: Handles message routing and blueprint registration • Event system: Implements publish-subscribe event hub • Task system: Manages scheduled tasks and priority queues • Cache system: Provides thread-safe LRU caching

  2. Transport Layer (Pipe)
    • Send queue: Implements priority task queue management • Receive pool: Maintains temporary and complete message storage • Thread locks: Ensures thread-safe access to shared resources • Protocol integration: Deep integration with LsoProtocol for chunked transmission

  3. Protocol Layer (LsoProtocol)
    • Intelligent chunking: Auto-selects memory/file storage based on data type • Metadata management: Maintains extended headers and message integrity checks • Hybrid storage: Enables seamless switching between memory buffers and persistent files

  4. Concurrency Model
    • Main thread: Handles I/O monitoring and request queuing • Worker thread pool: Processes requests independently from queue • Thread isolation: Achieves request context isolation through thread-local storage

  5. Data Flow
    • Bidirectional channel: Demonstrates complete loop from application layer to physical devices • Protocol transparency: Completely hides serialization/deserialization from upper layers • Asynchronous processing: Decouples non-blocking transmission from business logic

Documentation & Support

📚 Full Documentation | 💬 Community Discussions | 🐛 Issue Tracker

Documentation includes: • API Reference Manual • Architecture White Paper • Best Practice Guide • Performance Optimization Tips

Contribution Guide

We welcome contributions through:

  1. Code improvements via Pull Requests
  2. Documentation enhancements or translations
  3. Test case submissions
  4. Security vulnerability reports

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netcore-0.1.2.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netcore-0.1.2-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file netcore-0.1.2.tar.gz.

File metadata

  • Download URL: netcore-0.1.2.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for netcore-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e970608c4180ad3e18bec1358469ea8c4cc94cb518662e8bde5b8f209bdb24f6
MD5 244ca17d5d72c7c989b9468b241fdbc5
BLAKE2b-256 e2fac407badc60d32a39a16a88f183f84fd628fa407f4b4044c306e112e53740

See more details on using hashes here.

File details

Details for the file netcore-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: netcore-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for netcore-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2c48e7a47a86a812d1ec78c3e6a73a180fb56ab1bc6c4a35e602bdcf04addcf6
MD5 4c70132e338ba7c451c7ffe39af78500
BLAKE2b-256 e48c19a4cb51687c926daf9068b5d7f33a1c906e8cc6e0709518259948cf197a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page