Raw Socket
Raw Socket
Raw Socket
Overview!
! Last Lecture!
! Advanced UDP sockets and threads!
! Source: Chapters 22&26 of Stevens book!
! This Lecture!
! Signal-driven I/O, Raw sockets!
! Source: Chapters 25&28&29 of Stevens book!
! Next Lecture!
! WSN and revision!
Example!
Raw Sockets!
! Steps are:!
int sockfd;!
sockfd = socket(AF_INET, SOCK_RAW, protocol);!
const int on = 1;!
if (setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL,!
&on, sizeof(on)) < 0)!
error!
Ping!
! For a raw IPv6 socket, only the payload is passed to the socket!
Traceroute!
! How to make a traceroute program?!
ICMP Daemon 1!
ICMP Daemon 2!
ICMP Daemon 3!
ICMP Daemon 4!
Datalink Access!
! Datalink access provides the following
capabilities!
! The ability to watch the packets received by the
datalink layer, allowing programs such as
tcpdump to be run on normal computer systems!
! The ability to run certain programs as normal
applications instead of as part of the kernel, e.g.
RARP server.!
! Linux uses PF_PACKET as the domain for
sockets to support datalink access!
TELE 402 Lecture 13: Signal-Driven I/O & Raw Socket 21