1 / 7

Socket options: a summary Tcp options, ip options and general socket options can be examined and sometimes modified. get

trista
Download Presentation

Socket options: a summary Tcp options, ip options and general socket options can be examined and sometimes modified. get

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. Socket options: a summary Tcp options, ip options and general socket options can be examined and sometimes modified. getsockopt, setsockopt routines Some examples: Socket (TCP/UDP) send/receive buffer size Socket (TCP/UDP) send/receive low/high watermark UDP broadcasting TCP keep alive timer IP options: e.g. source routing IP Time to live (TTL) IP quality of service (TOS) IP multicast options

    2. #include <sys/socket.h> int getsockopt (int sockfd, int level, int optname, void *optval, socklen_t *optlen); Int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); Level includes general socket option (SOL_SOCKET) and protocol-specific option (IP, TCP, etc). Option value can be of different types : int, in_addr, timeval, … ---- that is why we use the void pointer.

    3. General socket options (level = SOL_SOCKET) Optnames: SO_BROADCAST(int): permit sending broadcast datagram SO_DEBUG: for debugging purpose SO_DONROUTE: used by routing daemon to make sure a packet goes through a certain interface. SO_ERROR: can only be got (not set), reset the error SO_KEEPALIVE: for TCP only, automatic send keepalive message when inactive for 2 hours (can be modified). SO_LINGER: for TCP only, determines the behavior when a close is called. SO_OOBINLINE: put out of band data in the normal input queue. SO_RCVBUF, SO_SNDBUF: send and receive buffer size.

    4. General socket options (level = SOL_SOCKET) Optnames: SO_RCVLOWAT, SO_SENDLOWAT: low watermark – affect the select system call SO_RCVTIMEO, SO_SNDTIMEO: inherent timeout time (disable by default) SO_REUSEADDR: Allows the port to be reused – all server should do this to restart immediately SO_TYPE: socket type? SOCK_STREAM and SOCK_DGRAM. SO_USELOOPBACK: sending socket gets a copy?

    5. IP options: Allows packets sent through a socket to have certain behavior, e.g source routing Level = IPPROTO_IP Example optnames: (manipulating IP header fields) IP_HDRINCL: who builds the IP header (raw socket). IP_OPTIONS: setting IP optional header fields IP_TOS IP_TTL

    6. IP options: Level = IPPROTO_IP Optnames: (IP MULTICAST related) IP_MULTICAST_IF IP_MULTICAST_TTL IP_MULTICAST_LOOP IP_ADD_MEMBERSHIP IP_DROP_MEMBERSHIP

    7. TCP options: Level = IPPROTO_TCP Optnames: TCP_KEEPALIVE: set the time TCP_MAXRT: maximum retransmission time TCP_MAXSEG: maximum segment size TCP_NODELAY: wait to ack or not (enable) See example3.c

More Related