Constructing a TCP packet with libnet

Using Transmission Control Protocol (TCP), a device sends packets to other devices on an IP network. TCP is designed to provide a reliable, ordered, and error-checked delivery of packets between applications. This does add additional overheads as compared to UDP, so applications that do not require reliability should use UDP instead.

When a device wants to communicate with another device using TCP, a three-way handshake must occur. The first device begins by sending a TCP packet with the SYN flag set. This is like saying, "Hi Joe. Can we talk?" The remote device is supposed to respond with a packet that has the SYN/ACK (synchronize/acknowledge) flags set, which is like Joe saying, "Sure, we can talk. What's ...

Get iOS and OS X Network Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.