Skip to main content

Posts

Showing posts from November, 2023

How to Capture and Modify TCP Packets Using Npcap Library in C

email:  tcpfast@gmail.com  In this blog post, I will show you how to use the pcap library in C to capture and modify TCP packets on the fly. The pcap library is a powerful tool for network analysis and manipulation, which allows you to access raw packets from various network interfaces. You can use the pcap library to implement your own network applications, such as firewalls, proxies, sniffers, etc. The Code The code I will use as an example is as follows: # include <stdio.h> # include <stdlib.h> # include <pcap.h> # include <Packet32.h> # include <ntddndis.h> # define MAX_PACKET_SIZE 65536 # define KEYWORD "keyword1" # define IP1 "192.168.0.1" # define PORT1 12345 void packet_handler (u_char* user_data, const struct pcap_pkthdr* pkthdr, const u_char* packet) ; int main () { pcap_t * handle; char errbuf[PCAP_ERRBUF_SIZE]; // Open the network adapter handle = pcap_open_live( "\\Device\\...

An Introduction to TCP Flags & C++ Demo(Server & Client)

My email: tcpfast@gmail.com  If you are interested in my TCP software development, consulting or training services, please feel free to contact me.   TCP flags are a set of six bits in the header of the Transmission Control Protocol (TCP), which is used to indicate or control the state or behavior of a TCP connection. TCP flags have the following types: - SYN (Synchronization): Used to initiate a connection, establish a connection and set the initial sequence number. - ACK (Acknowledgement): Used to acknowledge the received packets, or to respond to connection or disconnection requests. - FIN (Finish): Used to request to terminate a connection, indicating that the sender has no more data to send. - RST (Reset): Used to forcibly terminate a connection, indicating that the connection is abnormal or not accepted. - URG (Urgent): Used to indicate that there is urgent data in the packet, which needs to be processed with priority. - PSH (Push): Used to request to send data imme...

Example: A TCP Socket Echo Server in Python

Introduction TCP (Transmission Control Protocol) is one of the most widely used protocols in the Internet. It provides reliable, ordered, and error-checked delivery of data between applications running on different devices. A TCP socket is an endpoint of a TCP connection, which is identified by an IP address and a port number. A TCP socket can send and receive data to and from another TCP socket over the network. In this article, I will show you how to write a simple TCP socket echo server in Python, which is a program that listens for incoming connections from TCP socket clients, and echoes back whatever data it receives from them. This program can be useful for testing the functionality and performance of TCP sockets, as well as learning the basics of socket programming in Python. Requirements To write and run this program, you will need the following: - A computer with Python 3 installed. You can download Python 3 from [here]. - A text editor or an IDE (Integrated Development Enviro...