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.3.tar.gz (29.9 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.3-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: netcore-0.1.3.tar.gz
  • Upload date:
  • Size: 29.9 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.3.tar.gz
Algorithm Hash digest
SHA256 6a23f3ce6c468f2171a50c3f5db9d4c4f2377b88df13ee34a43bb3cc3bcb64d4
MD5 fc0ebd98476322a9a2726732893681c4
BLAKE2b-256 043647f38897e4feba4c9fd33ae36e07c8fba69b512bdb67d0b0a46fb42726a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: netcore-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 29.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ac26db864f65f36a0aea33d0ac2cf6a058301fbef0d9d6f996bf33684ad88d19
MD5 22cf2649726bf3aa67dd7d70ec482b34
BLAKE2b-256 4201ba7fbf7b5e425ebca2527e4846da0c286925ce78637b3922ed3b902c4b57

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