Presentation is loading. Please wait.

Presentation is loading. Please wait.

FSU CIS 5930 Internet Protocols

Similar presentations


Presentation on theme: "FSU CIS 5930 Internet Protocols"— Presentation transcript:

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

2 FSU CIS 5930 Internet Protocols
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) Fall 2004 FSU CIS 5930 Internet Protocols

3 FSU CIS 5930 Internet Protocols
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 Fall 2004 FSU CIS 5930 Internet Protocols

4 FSU CIS 5930 Internet Protocols
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” Fall 2004 FSU CIS 5930 Internet Protocols

5 FSU CIS 5930 Internet Protocols
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 } Fall 2004 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() Create/initialize socket structure (sock_create) Allocate file descriptor (sock_map_fd()) Fall 2004 FSU CIS 5930 Internet Protocols

7 sock_create/sock_map_fd
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 Fall 2004 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() Fall 2004 FSU CIS 5930 Internet Protocols

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

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

11 FSU CIS 5930 Internet Protocols
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 Fall 2004 FSU CIS 5930 Internet Protocols


Download ppt "FSU CIS 5930 Internet Protocols"

Similar presentations


Ads by Google