I am trying to send a ethernet packet containing an IPv4 packet and a TCP packet using Python raw socket. The SYN flag in the TCP packet is set to 1. The packet is addressed to the apache web server running on my local machine. My goal is to send a SYN packet and get a SYN/ACK packet in response.But the Apache server is not replying with the SYN/ACK packet.There is nothing wrong with the Apache server.I have created the ethernet header, IPv4 header as well as the TCP header. When I send the packet it shows on my Wireshark captures. I have checked the checksum of both IPv4 header and TCP header in wireshark, and same are correct.I have tried to solve the issue with removing and adding TCP options from the TCP header, still not getting any positive result.Since the packet displayed in Wireshark captures, it is sent over the network. But the apache server is not replying to my SYN packet.I have created a simple server using python and tried the entire process, but failed to get the SYN/ACK packet.Attached here the snapshot of the Wireshark capture.My aim is to achieve the entire TCP handshake using RAW socket programming.
socket is created as shown below...
senderSocker = socket.socket
(
family=socket.AF_PACKET,
type=socket.SOCK_RAW,
proto=socket.htons(0x0003),
fileno=None
)
Packet is sent as follows...
senderSocket.send(ethernetHeader + IPv4Header + TCPHeader + data)
Thanks