Python TCP/IP libraries: A Review

The Internet's core is TCP/IP, which stands for Transmission Control Protocol/Internet Protocol. It connects network devices on the internet via communication protocols. Python has several TCP/IP packages due to its popularity and flexibility. This paper describes the most popular Python libraries for TCP/IP protocol implementation, including socket, asyncio, Twisted, and Scapy. To help developers choose a library, we compare its benefits, cons, and areas of use, including criteria other than speed and memory utilization. When making web apps, choose wisely.


Introduction
TCP and higher-level protocols are executed on the host system.Major computers will use network software and TCP and Internet protocols to add some computer systems to the network.If both the host computer and the main computer employ the correct protocol for communication, the TCP standard may work for the main computer (FOROUZAN, 2002).
For working with TCP/IP protocols, there are many Python tools to choose from.Here are four famous choices and some things to think about when choosing between them.A socket library is a low-level tool that lets sockets be made and managed.It works with both TCP and UDP protocols and can be used for both client and server applications.But programming a socket can be hard and error-prone, especially when it comes to contacts that happen at different times.Reference (https://docs.python.org/3/library/socket.html).
Twisted is an event-driven networking framework that lets you build network apps with a highlevel API.It works with many different protocols, like TCP, UDP, HTTP, and SMTP.It also has features like asynchronous I/O and SSL/TLS protection.The learning curve is steep, though, so it might not be the best choice for simple (https://twisted.org/).
Asyncio is a Python library that is built-in and provides a structure for writing programs that run in parallel.It works with both TCP and UDP protocols and can be used for both client and server applications.It's perfect for apps that need to handle a lot of contacts at once, but it might be too much for simpler projects (https://docs.python.org/3/library/asyncio.html).
Scapy is a Python tool that lets you change and analyze packets.It makes it possible to make custom TCP/IP packets, simulate network attacks, and look at network data.But it might not be the best way to make full-fledged network applications (https://scapy.net/).The goal of this paper is to show the main features of each Python library that supports TCP/IP protocols.Think about which protocols you require and how effectively they work when choosing one of these libraries.
Structure of the paper: Section 2: Related Work, Section 3: Libraries Overview andComparison, and Section 4: Conclusion.

Related work
Several systems have been developed based on the TCP/IP protocol using Python and its library.Some examples are: In 2018, Sandia assessed a remote grid-monitoring gateway and communication-enabled PV inverter for cyber security.The goal was to inform the solar sector, grid operators, and government about present hazards and provide community-based remedies.The team detected some security flaws and some well-designed features.These findings led to security recommendations for DER devices (Carter et al., 2018) In 2020, Using Python 3.7, a team studied distributed networks, specifically blockchain networks, and created a peer-to-peer electricity trading system.This blockchain network needs RSA encryption, several master nodes, multiple client nodes, and conflict resolution (ARNAO et al., 2020).
In 2020, BEDI, Punam, and DUAs Arti presented a local area network covert channel employing the Overflow field of the Timestamp option of Internet Protocol, version 4. This storage-based network steganography uses timestamps for network debugging and measurement.They used genuine overflow field values, making clandestine communication difficult to detect (BEDI 2020).
In 2021, Using a TCP-based Python library and a server, a team published a paper on how to develop a chat application.This chat application is useful even if several clients are connected because parallel programming uses threads to transmit and receive messages in real time (SALIHU, 2021).HTNEN, Seppo, et al. discussed the main obstacles to seamless multi-connectivity in the same year.MULTI, a session-layer solution, can handle some of this problem's important subproblems.MULTI's TCP overhead was less than 5% compared to the native asyncio Python module (HÄTÖNEN, 2021).
In 2022, A team created a Python client for the Isabelle server, allowing researchers and students to interface with the server over TCP using Python scripts.This avoids the difficulties of combining the Python script with Isabelle's development languages (ML and Scala).They also described additional features since the client's first release a year ago with Isabelle's ML and Scala development languages.They also described additional features that have appeared since the client's first version was announced a year ago (SHMINKE, 2021).

Libraries Overview andComparison
The Python library or module that supports TCP/IP protocols are: -

Socket
Python provides good coverage of low-level networking interfaces.It all starts with the BSD socket interface.Python has a socket module that provides the functionality needed to use the socket interface.Network programming in any programming language can start with sockets Sockets are the most popular form of inter-process communication, especially for crossplatform communication.They were invented by Berkeley and are part of BSD Unix.By combining sockets with INET, communication between machines is made very easy.

Twisted
Twisted is an event-based web application framework that supports Python 3.6+.It contains modules for many different purposes.Twisted is a library that allows you to easily create web applications in Python.While Twisted manages to abstract most of the low-level networking details, at least having a broad understanding of network I/O is very helpful.When you connect two processes at a very simple level using mechanisms that allow them to exchange data, you network them.It helps to imagine two physical machines connected by a single wire.Once the two machines are connected with a single cable, they can use it.A machine can write data at one end of its line, and some time later it reaches the other end of the line.Additionally, data can arrive at the same end of the line at all times ( Fettig, 2005). .

Asyncio
The asyncio standard library module is new in Python 3.4 and attempts to bring some standardization of asynchronous I/O into the standard library.The Asyncio library uses a coroutine-based programming style.It provides a powerful loop class to which our program can send prepared tasks (called coroutines) to run asynchronously.The event loop is responsible for scheduling tasks and optimizing performance around blocking I/O calls.It has built-in support for socket-based networking, making building a basic server an easy task (Sarker, 2015).

Scapy
Scapy is a library supported by both Python2 and Python3.It is used to interact with packets on the network.It has several functions that allow us to easily forge and manipulate bags.Using Scapy modules, we can create various network tools such as ARP spoofers, network scanners, packet dumpers, etc.This module can be used to create more advanced cybersecurity and ethical hacking tools.
A network scan is all about scanning the entire network we are connected to and finding out which clients are connected to our network.We can identify each customer based on their IP and MAC address.Through ARP ping, we can find out the active systems in the network (Rohith et al., 2018). 1 is ( Lubanovic, 2022;Soni, 2021;Fettig, 2005;Thaker, 2020, Hattingh, 2020;Rohith et al., 2018).Developers may take longer to master it than Socket.• Asyncio facilitates concurrent network application development.

Comparative analysis of libraries The primary comparison displayed in Table
Routines facilitate network request processing.Mastering async and asynchronous code structures takes time.• Scapy's robust interface helps network engineers and developers build and control network packets.As a non-networking library, network connectivity and protocol implementation may be less beneficial.

Easy of Programming
• The simplest library, Socket, offers few functionalities.
• Twisted and Asyncio provide more complicated abstractions and capabilities but a steeper learning curve.

Conclusion
TCP/IP protocols govern computer communication, routing, and network connections.
Research institutions, universities, governments, and businesses use it to communicate online.TCP/IP makes a machine an Internet host that can connect to others.Python is an objectoriented, dynamically semantic programming language with built-in high-level data structures, dynamic typing, and dynamic binding.Python has many system development libraries.This page recommends TCP/IP libraries depending on developer needs and efficiency.Internet communication is based on TCP/IP.Python has several TCP/IP libraries due to its flexibility and popularity.This paper discusses socket, asyncio, Twisted, and Scapy, the most popular Python TCP/IP libraries.We help developers choose a library based on benefits, constraints, and applications (memory use, availability, speed, and more).Web app development requires smart choices.All the libraries are used for network testing, monitoring, and forensics.It depends on the use case and features.Asyncio and Scapy are more popular due to their performance and usability.

Table 1 .
Comparative analysis of libraries

•
Socket simplifies TCP/IP.Networking is simple.As networking needs rise, socket requires developers to control low-level properties like buffering and flow management, making it harder to utilize.• Twisted's extensive API allows for complicated networking activities.

•
For advanced network research, the most difficult library, Scapy, manipulates packets.

•
Socket programming is easier with low-level libraries.For simple networking tasks, it's memory-efficient.•Networking library asynchronous High-level socket programming with Asyncio Coroutines and event loops consume more memory than asynchronous programming.• Asyncio faces Twisted.Networking engine.Libraries with higher-level functionality require additional RAM.• Custom network packets are sent by Scapy.RAM handles packet parsing and complex functions.