1 / 11

Concept of sockets

Concept of sockets. Reading: Chapter 26. Sockets. Common interface network programming Underneath, there are lots of protocol specific sockets (protocol families) PF_INET (for Internet protocol family) PF_PACKET (for directly accessing network device)

briar
Download Presentation

Concept of sockets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Concept of sockets Reading: Chapter 26 FSU CIS 5930 Internet Protocols

  2. Sockets • Common interface network programming • Underneath, there are lots of protocol specific sockets (protocol families) • PF_INET (for Internet protocol family) • PF_PACKET (for directly accessing network device) • PF_NETLINK (not for transporting data, but rather for configuring Linux network kernel) FSU CIS 5930 Internet Protocols

  3. BSD sockets BSD Sockets PF_INET sockets PF_PACKET PF_NETLINK … SOCK_STREAM SOCK_DGRAM SOCK_RAW NETLINK_ROUTE NETLINK_SKIP NETLINK_USERSOCK NETLINK_FIREWALL NETLINK_ARPD NETLINK_ROUTE6 NETLINK_IP6_FW NETLINK_DNRTMSG NETLINK_TAPBASE TCP UDP IP Network device FSU CIS 5930 Internet Protocols

  4. sys_socketcall() • Linux kernel has only one socket-related system call • sys_socketcall(int call, unsigned long *args) • Parameter “call” specifies the desired call (function) • SYS_SOCKET, SYS_BIND, SYS_CONNECT … • sys_socketcall dispatch processing to different functions based on “call” FSU CIS 5930 Internet Protocols

  5. Socket structure Struct socket { socket_state state; unsigned long flags; struct proto_ops *ops; struct inode *inode; struct fasync_struct *fasync_list; struct file *file; struct sock *sk; wait_queue_head_t wait; short type; unsigned char passcred } FSU CIS 5930 Internet Protocols

  6. What happens when you call socket() • In socket programming library • socket() sys_socketcall(SYS_SOCKET, ) • In sys_socketcall(): • case SYS_SOCKET: • sys_socket() • sys_socket() • Create/initialize socket structure (sock_create) • Allocate file descriptor (sock_map_fd()) FSU CIS 5930 Internet Protocols

  7. sock_create/sock_map_fd • sock_create() • Some sanity checking • Allocating socket structure/inode (sock_alloc()) • Calling net_faimilies[family]->create() for family specific handling • sock_alloc() • Reserving an inode, allocating/initializing socket structure • Sock_map_fd() • Allocating file descriptor, filling in the file entry FSU CIS 5930 Internet Protocols

  8. Protocol specific create() • Filling other fields of socket structure • In particular, struct proto_ops *ops; • Protocol specific function processing, such bind, connect, etc. • Example of processing flow: sendto() socket call • sys_socketcall(SYS_SENDTO, ) • sys_sendto() • sock_sendmsg() • sock->ops->sendmsg() FSU CIS 5930 Internet Protocols

  9. Protocol specific sockets • Central structure of all protocol specific sockets • struct sock • PF_INET • PF_PACKET • PF_NETLINK FSU CIS 5930 Internet Protocols

  10. PF_INET sockets • inet_create() • Initializing sock structure • Filling in protocol specific ops • Filling in transport protocol specific functions, if desirable. FSU CIS 5930 Internet Protocols

  11. PF_PACKET • By passing transport and network layers • Packet_sendmsg() • It will directly access the network device • dev_queue_xmit() • Similarly, packets passed to application directly • packet_rcv() is installed for incoming packets FSU CIS 5930 Internet Protocols

More Related