Reputation: 782
Is it possible to set the fields of a TCP header from a user program? The man page for tcp(7) does not list any fields which can be controlled using setsockopt(2). For IP, we can control the MTU, TTL fields using the setsockopt(2).
int sockfd = socket (AF_INET, SOCK_STREAM, 0);
/* set the TCP fields now */
...
...
Upvotes: 3
Views: 351
Reputation: 3819
Yes you can use raw sockets to set the TCP/UDP headers from a user program
int fd = socket (PF_INET, SOCK_RAW, IPPROTO_TCP);
More info on the link http://csis.bits-pilani.ac.in/faculty/dk_tyagi/Study_stuffs/raw.html
Search for RAW sockets and you will find more
One more good reference is the Unix network programming by Richard stevenson
Upvotes: 4