Skip to main content

Package for fetching network interface information

Project description

NIC Speedy Module

OS Status
Linux Build Status
OsX Build Status

This repository was created for demonstrating of problem which appears in systems with a lots of NICs. Lets say you have a system with 1000 NIC. If you will use ethtool or netifaces, then you will get results after several minutes. Why does it take too much time? Because this packages do not have simple function for fetching all network`s interface information at the same time.

In /module_tests are created tests which measure total time of getting info about system NICs. You can see that this module is faster then other, because it has one function which fetchs all information at the same time. You can measure that on your own.

About module

This module was created for simple reading informtion about network interface. In the results of module function you may see ,,magic" numbers like flags or family. I would like you show you how to ,,read" these magic numbers on example samples below. Below you can also see examples how you may use module functions.

Which information does this module return?

NicSpeedyModule uses system library getifaddrs.h. Results from the libary are transformed to pyObject which you may use later. This module returns:

Name Type Example
name String eth0, lo0, ipsec
family Integer 2(AF_INET), 30(AF_INET6)
up Boolean True/False
flags Integer 32841
addr String 127.0.0.1, ::1
addr_netmask String 255.255.255.0,
ffff:ffff:ffff:ffff::

Transform family to AddrFamily type

Because value family is integer type, so it looks like a magic number, but its not. This number represent Address Family type. Here is simple example how you can get from magic number Addres Family type.

import nicSpeedyModule as nic
import socket

results = nic.get_them_all()
interface = results["lo0"][0] # Take first result from list

addr_family_type = socket.AddressFamily(interface["family"])
print(addr_family_type)

Flags description

This module allows to access to interface flags, which could be used for determining whether is interface up or whether support multicast etc...

Device flags
IFF_UP            Interface is running.
IFF_BROADCAST     Valid broadcast address set.
IFF_DEBUG         Internal debugging flag.
IFF_LOOPBACK      Interface is a loopback interface.
IFF_POINTOPOINT   Interface is a point-to-point link.
IFF_RUNNING       Resources allocated.
IFF_NOARP         No arp protocol, L2 destination address not set.
IFF_PROMISC       Interface is in promiscuous mode.
IFF_NOTRAILERS    Avoid use of trailers.
IFF_ALLMULTI      Receive all multicast packets.
IFF_MASTER        Master of a load balancing bundle.
IFF_SLAVE         Slave of a load balancing bundle.
IFF_MULTICAST     Supports multicast
IFF_PORTSEL       Is able to select media type via ifmap.
IFF_AUTOMEDIA     Auto media selection active.
IFF_DYNAMIC       The addresses are lost when the interface goes down.
IFF_LOWER_UP      Driver signals L1 up (since Linux 2.6.17)
IFF_DORMANT       Driver signals dormant (since Linux 2.6.17)
IFF_ECHO          Echo sent packets (since Linux 2.6.25)

(Taken from https://man7.org/linux/man-pages/man7/netdevice.7.html)

Here is a simple example how to determine whether is it loopback interface.

import nicSpeedyModule as nic
results = nic.get_them_all()
interface = results["lo0"][0] # Take first result from list


is_loopback = (interface["flags"] & nic.IFF_LOOPBACK) != 0
print(is_loopback)

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

NicSpeedyModule-1.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

NicSpeedyModule-1.1.1-cp39-cp39-macosx_10_9_x86_64.whl (7.7 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file NicSpeedyModule-1.1.1.tar.gz.

File metadata

  • Download URL: NicSpeedyModule-1.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

File hashes

Hashes for NicSpeedyModule-1.1.1.tar.gz
Algorithm Hash digest
SHA256 dab2d6b3f0015537de90e4ed6ca9dc8ae3e934b863c48b709d07ae43b3390c20
MD5 b15fe102bae0f928c348473f77d5a174
BLAKE2b-256 751dabb8337936ea72eedb9b06ff9e15a21ce40f631f0ea68dd820adf6c9f538

See more details on using hashes here.

File details

Details for the file NicSpeedyModule-1.1.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: NicSpeedyModule-1.1.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

File hashes

Hashes for NicSpeedyModule-1.1.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dd963dc07cc466ffd9bac9bde57f568b903da2d17aeaf317e589b372bbe12f0e
MD5 dee708f794940a1c386064f99940f533
BLAKE2b-256 fe53947f82b744815f74128802c9dd9ddb5f33df03d9b794252849bef138a463

See more details on using hashes here.

Supported by

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