Skip to main content

A network tool for device discovery and communication

Project description

Nkosi

Python Version License: MIT

Nkosi is a Python package for network device discovery and communication. It provides tools to:

  • Discover devices on your local network using ARP
  • Establish TCP/UDP communication channels
  • Create network servers and clients with minimal code
  • Send and receive messages between devices

Features

  • Device Discovery: Find all devices on your local network using ARP scanning
  • TCP Communication: Full-featured TCP server and client implementations
  • UDP Communication: UDP server and client with broadcast support
  • Easy to Use: Simple API for common networking tasks
  • Cross-platform: Works on Windows, macOS, and Linux

Installation

pip install nkosi

Quick Start

Discovering Devices on Your Network

from nkosi import discover_devices

devices = discover_devices()
for device in devices:
    print(f"IP: {device['ip']}, MAC: {device['mac']}, Hostname: {device['hostname']}")

Creating a TCP Server

from nkosi import TCPServer

def on_message_received(message, client_address):
    print(f"Received from {client_address}: {message}")

server = TCPServer(host='0.0.0.0', port=5000)
server.start(callback=on_message_received)

# Keep the server running
input("Press Enter to stop the server...")
server.stop()

Creating a TCP Client

from nkosi import TCPClient

def on_message_received(message):
    print(f"Received from server: {message}")

client = TCPClient(host='localhost', port=5000)
if client.connect(callback=on_message_received):
    client.send({"type": "greeting", "message": "Hello, server!"})
    
    # Keep the client running
    input("Press Enter to disconnect...")
    client.disconnect()

Creating a UDP Server

from nkosi import UDPServer

def on_message_received(message, client_address):
    print(f"Received from {client_address}: {message}")

server = UDPServer(host='0.0.0.0', port=5001)
server.start(callback=on_message_received)

# Keep the server running
input("Press Enter to stop the server...")
server.stop()

Creating a UDP Client

from nkosi import UDPClient

def on_message_received(message, sender_address):
    print(f"Received from {sender_address}: {message}")

client = UDPClient(host='localhost', port=5001)
if client.start(callback=on_message_received):
    client.send({"type": "greeting", "message": "Hello, server!"})
    
    # Keep the client running
    input("Press Enter to stop the client...")
    client.stop()

Command Line Interface

Nkosi also provides a simple command-line interface for common tasks.

Discover Devices

nkosi-discover

Send a Message

# Send a message to a TCP server
nkosi-send --host localhost --port 5000 --message "Hello, server!" --protocol tcp

# Send a message to a UDP server
nkosi-send --host localhost --port 5001 --message "Hello, server!" --protocol udp

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

nkosi-3.2.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

nkosi-3.2-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file nkosi-3.2.tar.gz.

File metadata

  • Download URL: nkosi-3.2.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.0

File hashes

Hashes for nkosi-3.2.tar.gz
Algorithm Hash digest
SHA256 c786da5678091e0e577b45c43103b6b30ff70418bee7043970d7b4467894e326
MD5 43e60d020bd1ad2004c89337df10aa95
BLAKE2b-256 97c8513a500acd46dff6b8d227235955df2fda7762bc6f753291861f8d42ae5b

See more details on using hashes here.

File details

Details for the file nkosi-3.2-py3-none-any.whl.

File metadata

  • Download URL: nkosi-3.2-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.0

File hashes

Hashes for nkosi-3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c16ff0470136654595b55a798eff4e2a8004011906726b4820fa84738f0b7ba
MD5 58901a909aa96e285a0190cf0ca69095
BLAKE2b-256 3755ebf523df78bd9c216e9251c58b9cecb795e2c9d5272b99982ff3468161a0

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