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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nkosi-3.4.tar.gz
Algorithm Hash digest
SHA256 225f7c0b06a44c6a11b2b36913cdbdba503a35b6b42b05aa535fb8b11752f7a9
MD5 4b8bdf84f96a6f564bf7335af666ee95
BLAKE2b-256 c51b087fffa46b4c97ff50a544b2c7bf48cce421710e61a68ee3957018ee79e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nkosi-3.4-py3-none-any.whl
  • Upload date:
  • Size: 25.6 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f8ec06384f83422685af3fa888fe31d3f3f9acf6b5a710fd1565875cff43cdf4
MD5 d491e647a5357cec1b8b0002bac608ec
BLAKE2b-256 ff07001225ca55e3561da53cdb54c378db1c115f48abeeeb4fef14b7f0a4770c

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