1 Socket Options Ref: Chapter 7. 2 Socket Options Various attributes that are used to determine the behavior of sockets.Various attributes that are used.

Slides:



Advertisements
Similar presentations
Socket Options. abstraction Introduction getsockopt and setsockopt function socket state Generic socket option IPv4 socket option ICMPv6 socket option.
Advertisements

Guide to TCP/IP, Third Edition
Review: –What functionality is supported by IP? –What IP does not do? –How many classes of IP addresses? –Explain fields in an IP header? –How subnet works?
Netprog Advanced Sockets Programming1 Advanced Sockets Programming Ref: Chapter 7,11,21,22.
I/O Models Satish Krishnan. I/O Models Blocking I/O Non-blocking I/O I/O Multiplexing Signal driven I/O Asynchronous I/O.
Elementary TCP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
Lecture 6 TCP Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Multicasting - Part II© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
Sockets CS 3516 – Computer Networks. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Distributed Computing Systems Sockets. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Lecture 19 Advanced Sockets Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Networks: TCP/IP Socket Calls1 Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Computer Networks Sockets.
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
TDC561 Network Programming Camelia Zlatea, PhD Week 5: Client/Server Programming Aspects  Client side:
Multimedia Networking Sockets. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
TDC561 Network Programming Camelia Zlatea, PhD Week 8: Multicasting; Socket Options;
Sockets IMGD Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Socket Options Jari Kellokoski. Introduction So far we have discovered some basic usage of socket With socket options we control sockets more suitable.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
Computer Networks Sockets. Outline F Socket basics F Socket details.
Computer Network Architecture and Programming
Operating Systems Sockets. Outline F Socket basics F TCP sockets F Socket details F Socket options F Final notes F Project 3.
Socket options A way for network applications to ‘tweak’ the processing done at lower-levels of the TCP/IP stack.
Socket option Getsockopt ou setsockopt fcntl ioctl.
Sockets CIS 370 Fall 2009, UMassD. Introduction  Sockets provide a simple programming interface which is consistent for processes on the same machine.
Basic Socket Programming TCP/IP overview. TCP interface Reference: –UNIX Network Programming, by Richard Stevens. –UNIX man page.
ECE 4110 – Internetwork Programming Client-Server Model.
Sockets and intro to IO multiplexing. Goals We are going to study sockets programming as means to introduce IO multiplexing problem. We will revisit socket.
Elementary TCP Sockets
University of Calgary – CPSC 441.  UDP stands for User Datagram Protocol.  A protocol for the Transport Layer in the protocol Stack.  Alternative to.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
 Wind River Systems, Inc Chapter - 13 Network Programming.
More on Socket API. How to Place Timeouts on Sockets (1)  Using SIGALRM signal Connection timeout 기간의 축소 Response timeout advio/dgclitimeo3.clib/connect_timeo.c.
Review: How to create a TCP end point? What is the right format for sin_port and sin_addr in the sockaddr_in data structure? How many different ways we.
Chapter 2 Applications and Layered Architectures Sockets.
7.9 TCP Socket Options 7.10 SCTP Socket Options 7.11 fcntl Function 7.12 Summary 報告者 : 梁凱鈞.
Remote Shell CS230 Project #4 Assigned : Due date :
More on Socket API. More on Socket I/O Functions  Scatter read and gather write.
Sockets For Clients Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Netprog: Advanced Sockets Programming1 Advanced Sockets Programming Ref: Chapter 7,11,21,22.
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
Distributed Computing A Programmer’s Perspective.
Socket options: a summary –Tcp options, ip options and general socket options can be examined and sometimes modified. getsockopt, setsockopt routines Some.
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
I/O Multiplexing. What is I/O multiplexing? When an application needs to handle multiple I/O descriptors at the same time –E.g. file and socket descriptors,
TELE 402 Lecture 12: Signal-Driven I/O & Raw Socket 1 Overview Last Lecture –Advanced UDP sockets and threads –Source: Chapters 22&26 of Stevens’ book.
Today’s topic: UDP Reliable communication over UDP.
1 Socket Options getsockopt and setsockopt functions Check options and obtain default values Generic socket options IPv4 socket options IPv6 socket options.
CMPT 471 Networking II Network Programming © Janice Regan,
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
UNIX Sockets Outline UNIX sockets CS 640.
Cisco I Introduction to Networks Semester 1 Chapter 7 JEOPADY.
Client/Server Design Issues Based on Java Network Programming and Distributed Computing, Chapter 6 Also Online Java Tutorial, Sun.
1 K. Salah Application Layer Module K. Salah Network layer duties.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
IPv4 socket option Level => IPPROTO_IP
Socket Option.
Operating Systems Sockets ENCE 360.
Sockets and Beginning Network Programming
Transport Layer.
Socket Programming in C
Network Programming CSC- 341
Chapter 07. Socket Options.
Socket Programming in C
Advanced Network Programming spring 2007
Advanced Sockets Programming
Socket options: a summary
Advanced UNIX programming
Presentation transcript:

1 Socket Options Ref: Chapter 7

2 Socket Options Various attributes that are used to determine the behavior of sockets.Various attributes that are used to determine the behavior of sockets. Setting options tells the OS/Protocol Stack the behavior we want.Setting options tells the OS/Protocol Stack the behavior we want. Support for generic options (apply to all sockets) and protocol specific options.Support for generic options (apply to all sockets) and protocol specific options.

3 Option types Many socket options are boolean flags indicating whether some feature is enabled (1) or disabled (0).Many socket options are boolean flags indicating whether some feature is enabled (1) or disabled (0). Other options are associated with more complex types including int, timeval, in_addr, sockaddr, etc.Other options are associated with more complex types including int, timeval, in_addr, sockaddr, etc. Some options are readable only (we can’t set the value).Some options are readable only (we can’t set the value).

4 Setting and Getting option values getsockopt() gets the current value of a socket option. setsockopt() is used to set the value of a socket option.

5 int getsockopt( int sockfd, int level, int level, int optname, int optname, void *opval, void *opval, socklen_t *optlen); socklen_t *optlen); level specifies whether the option is a general option or a protocol specific option (what level of code should interpret the option).

6 int setsockopt( int sockfd, int level, int level, int optname, int optname, const void *opval, const void *opval, socklen_t optlen); socklen_t optlen); level specifies whether the option is a general option or a protocol specific option (what level of code should interpret the option).

7 General Options Protocol independent options.Protocol independent options. Handled by the generic socket system code.Handled by the generic socket system code. Some options are supported only by specific types of sockets (SOCK_DGRAM, SOCK_STREAM).Some options are supported only by specific types of sockets (SOCK_DGRAM, SOCK_STREAM).

8 Some Generic Options SO_BROADCASTSO_DONTROUTESO_ERRORSO_KEEPALIVESO_LINGERSO_RCVBUF,SO_SNDBUFSO_REUSEADDR

9 SO_BROADCAST Boolean option: enables/disables sending of broadcast messages.Boolean option: enables/disables sending of broadcast messages. Underlying DL layer must support broadcasting!Underlying DL layer must support broadcasting! Applies only to SOCK_DGRAM sockets.Applies only to SOCK_DGRAM sockets. Prevents applications from inadvertently sending broadcasts (OS looks for this flag when broadcast address is specified).Prevents applications from inadvertently sending broadcasts (OS looks for this flag when broadcast address is specified).

10 SO_DONTROUTE Boolean option: enables bypassing of normal routing.Boolean option: enables bypassing of normal routing. Used by routing daemons.Used by routing daemons.

11 SO_ERROR Integer value option.Integer value option. Value is an error indicator value as used by errno.Value is an error indicator value as used by errno. Readable (get’able) only!Readable (get’able) only! Reading (by calling getsockopt() ) clears any pending error.Reading (by calling getsockopt() ) clears any pending error.

12 SO_KEEPALIVE Boolen option: enabled means that STREAM sockets should send a probe to peer if no data flow for a “long time”.Boolen option: enabled means that STREAM sockets should send a probe to peer if no data flow for a “long time”. Used by TCP - allows a process to determine whether peer process/host has crashed.Used by TCP - allows a process to determine whether peer process/host has crashed. Consider what would happen to an open telnet connection without keepalive.Consider what would happen to an open telnet connection without keepalive.

13 SO_LINGER Value is:Value is: struct linger { int l_onoff; /* 0 = off */ int l_linger; /* time in seconds */ }; Used to control whether and how long a call to close will wait for pending ACKS.Used to control whether and how long a call to close will wait for pending ACKS. connection-oriented sockets only.connection-oriented sockets only.

14 SO_LINGER By default, calling close() on a TCP socket will return immediately.By default, calling close() on a TCP socket will return immediately. The closing process has no way of knowing whether or not the peer received all data.The closing process has no way of knowing whether or not the peer received all data. Setting SO_LINGER means the closing process can determine that the peer machine has received the data (but not that the data has been read() !).Setting SO_LINGER means the closing process can determine that the peer machine has received the data (but not that the data has been read() !).

15 SO_RCVBUF SO_SNDBUF Integer values options - change the receive and send buffer sizes.Integer values options - change the receive and send buffer sizes. Can be used with STREAM and DGRAM sockets.Can be used with STREAM and DGRAM sockets. With TCP, this option effects the window size used for flow control - must be established before connection is made.With TCP, this option effects the window size used for flow control - must be established before connection is made.

16 SO_REUSEADDR Boolean option: enables binding to an address (port) that is already in use.Boolean option: enables binding to an address (port) that is already in use. Used by servers that are transient - allows binding a passive socket to a port currently in use (with active sockets) by other processes.Used by servers that are transient - allows binding a passive socket to a port currently in use (with active sockets) by other processes. Can be used to establish separate servers for the same service on different interfaces (or different IP addresses on the same interface)Can be used to establish separate servers for the same service on different interfaces (or different IP addresses on the same interface)

17 IP Options (IPv4) IP_HDRINCL: used on raw IP sockets when we want to build the IP header ourselves.IP_HDRINCL: used on raw IP sockets when we want to build the IP header ourselves. IP_TOS: allows us to set the “Type-of- service” field in an IP header.IP_TOS: allows us to set the “Type-of- service” field in an IP header. IP_TTL: allows us to set the “Time-to-live” field in an IP header.IP_TTL: allows us to set the “Time-to-live” field in an IP header.

18 TCP socket options TCP_KEEPALIVE: set the idle time used when SO_KEEPALIVE is enabled.TCP_KEEPALIVE: set the idle time used when SO_KEEPALIVE is enabled. TCP_MAXSEG: set the maximum segment size sent by a TCP socket.TCP_MAXSEG: set the maximum segment size sent by a TCP socket. TCP_NODELAY: can disable TCP’s Nagle algorithm that delays sending small packets if there is unACK’d data pending.TCP_NODELAY: can disable TCP’s Nagle algorithm that delays sending small packets if there is unACK’d data pending.

19 This was just an overviewThis was just an overview –there are many details associated with the options described. –There are many options that haven’t been described.