Socket Options Jari Kellokoski. Introduction So far we have discovered some basic usage of socket With socket options we control sockets more suitable.

Slides:



Advertisements
Similar presentations
Nonblocking I/O Blocking vs. non-blocking I/O
Advertisements

Multicasting© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
Socket Options. abstraction Introduction getsockopt and setsockopt function socket state Generic socket option IPv4 socket option ICMPv6 socket option.
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Programming with UDP – I Covered Subjects: IPv4 Socket Address Structure Byte Ordering Functions Address Access/Conversion Functions Functions: 1.socket()
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?
Out-of-Band Data© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
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.
CSCI 4550/8556 Computer Networks Comer, Chapter 23: An Error Reporting Mechanism (ICMP)
Elementary TCP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
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.
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.
Multimedia Networking Sockets. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Sockets IMGD Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Multicasting Jari Kellokoski Introduction When a unicast address identifies a sigle IP interface Then a broadcast address identifies all IP.
1 I/O Multiplexing Computer Network Programming. 2 Input from multiple sources Process keyboard sockets file A process may have multiple sources of input.
Chapter 23 Advanced SCTP Sockets. SCTP Sockets, recall ● Stream Control Transmission Protocol ● Multi-homed ● Association, instead of connection ● IPV4.
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 option Getsockopt ou setsockopt fcntl ioctl.
Gursharan Singh Tatla Transport Layer 16-May
Sockets CIS 370 Fall 2009, UMassD. Introduction  Sockets provide a simple programming interface which is consistent for processes on the same machine.
1 Introduction to Raw Sockets 2 IP address Port address MAC address TCP/IP Stack 67 Bootp DHCP OSPF protocol frame type UDP Port # TCP Port.
ECE 4110 – Internetwork Programming Client-Server Model.
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.
Signal-Driven I/O Concepts and steps for using signal-driven I/O
6.1. Transport Control Protocol (TCP) It is the most widely used transport protocol in the world. Provides reliable end to end connection between two hosts.
Transport Layer: TCP and UDP. Overview of TCP/IP protocols Comparing TCP and UDP TCP connection: establishment, data transfer, and termination Allocation.
More on Socket API. How to Place Timeouts on Sockets (1)  Using SIGALRM signal Connection timeout 기간의 축소 Response timeout advio/dgclitimeo3.clib/connect_timeo.c.
Programming with TCP – III 1. Zombie Processes 2. Cleaning Zombie Processes 3. Concurrent Servers Using Threads  pthread Library Functions 4. TCP Socket.
Nonblocking I/O Blocking vs. non-blocking I/O Nonblocking input, output, accept, and connect Readings –UNP Ch16 1.
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.
Network Programming Eddie Aronovich mail:
7.9 TCP Socket Options 7.10 SCTP Socket Options 7.11 fcntl Function 7.12 Summary 報告者 : 梁凱鈞.
More on Socket API. More on Socket I/O Functions  Scatter read and gather write.
Netprog: Advanced Sockets Programming1 Advanced Sockets Programming Ref: Chapter 7,11,21,22.
Advanced Sockets API-II Vinayak Jagtap
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
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.
DoS Suite and Raw Socket Programming Group 16 Thomas Losier Paul Obame Group 16 Thomas Losier Paul Obame.
Socket options: a summary –Tcp options, ip options and general socket options can be examined and sometimes modified. getsockopt, setsockopt routines Some.
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,
IP Configuration API. Network Interface Configuration NAIfconfigIsDeviceUp() NAIfconfigDeviceFromInterface() NAIfconfigBringDeviceUp() NAIfconfigSetIpAddress()
Guide to TCP/IP Fourth Edition
UDP : User Datagram Protocol 백 일 우
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
Computer Networks 1000-Transport layer, TCP Gergely Windisch v spring.
Client/Server Design Issues Based on Java Network Programming and Distributed Computing, Chapter 6 Also Online Java Tutorial, Sun.
IPv4 socket option Level => IPPROTO_IP
Socket Option.
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Network Programming CSC- 341
Chapter 07. Socket Options.
Advanced Network Programming spring 2007
Advanced Sockets Programming
Socket options: a summary
Advanced UNIX programming
Presentation transcript:

Socket Options Jari Kellokoski

Introduction So far we have discovered some basic usage of socket With socket options we control sockets more suitable way for our purposes (e.g. closing the socket) Covers: –Getsocketopt & setsocketopt –Socket Options like: Generic Options IPv4 IPv6 TCP SCTP

getsockopt & setsockopt int getsocketopt( int sockfd, int level, int optname, void *optval, socketlnet_t *oplen) int setsocketopt( int sockfd, int level, int optname, const void *optval, socklen_t oplen) where –sckfd – open socket descriptor –level – code in the system that interprets the option –optval – pointer to a variable into which the current value of the option is stored by getsocketopt or which the new value of the option is fetched by setsocketopt –oplen – size of optval as a value-result for getsocketopt or as a value for setsockopt

getsockopt & setsockopt Idea with options: –Some features can be enabled or disabled –Values can be set or read

Level, Optname, Flag Level: SOL_SOCKET, IPPROTO_IP, IPPROTO_ICMPv6… optname: SO_BROADCAST, IP_OPTIONS, MCAST_JOIN_GROUP… get: value can be read set: value can be set Flag: on/off Datatype: int, struct…

Generic Socket Options SO_BROADCAST SO_ERROR SO_KEEPALIVE SO_LINGER SO_RECVBUF & SO_NDBUF SO_REUSEADDR & REUSEPORT

Generic Socket Options SO_BROADCAST –enable/disable to send broadcast messages –of course this is only possible on networks supporting broadcast – like Ethernet – but not with point-to-point links –Applications must set this – wise since failed use can be problematic - flooding

Generic Socket Options SO_ERROR –Pending error for socket – standard Exxx values filled on failures –If blocked call – socket returns condition on readability or write ability –If signal-driven – SIGIO signal is generated

Generic Socket Options SO_KEEPALIVE –TCP will keep the connection alive even no actual communication data is not transferred –Scenarios to keepalive: Response with ACK – everything is ok Response with RST – crash or reboot in peer host No response – retransmissions – eventually ETIMEOUT or EHOSTUNREACH

Generic Socket Options SO_LINGER –How the close function is operating –struct linger with int l_onoff and l_linger –Where: l-onoff is 0 – close returns immediately l_onoff is nonzero and l_linger is 0 – TCP aborts the connection when it is closed – data is discarded from buffer – RST to the peer l_onoff is nonzero and l_linger is nonzero – kernel will linger when socket is closed. Remaining data is tried to be send or linger time expires

Generic Socket Options SO_RECVBUF & SO_NDBUF –Send and receive buffers –SO_RCVBUF must be set before calling connect –Buffer sizes should be at least four times the MSS –File transfer in one direction – send buffer in sending side and receiving buffer in receiving side –Bi-directional transfer – both buffer on both ends

Generic Socket Options SO_REUSEADDR & SO_REUSEPORT –Allows a listening server to bind well-know port even previously established connections exist (child was spawned) –Allows a new server to be stared on the same port as an existing server (different local IP address – IP aliasing) –Single process to bind same port to multiple sockets (UDP based server) –Completely duplicate binding – same port and IP – UDP multicasting

IPv4 Socket Options IP_HDRINCL – for building own IP header IP_TOS – (legendary) type of service field IP_TTL – setting/getting(default) time-to- live

IPv6 Socket Options IPv6_CHECKSUM – tells where to look checksum field IPv6_DONTFRAG – disables the automatic fragment header (for UDP and raw sockets) IPv6_UNICAST_HOPS – similar to IPv4 TTL – specifies the default hop limit for outgoing datagrams sent on the socket (or default hop limit that kernel uses) IPv6_PATHMTU – retrieves current MTU returned by path-MTU discovery

TCP Socket Options TCP_MAXSEG – fetching/setting MSS for connection – however we can always send less then announced MSS TCP_NODELAY – disables Nagle algorithm –Reasons for that: small packets used in communications (telnet) –small packet – packet smaller then MSS –Nagle algorithm reduces these ”small” packets however in some cases this is creating outstanding delays or making communication almost impossible –delayed ACK – the TCP ACK is delayed for piggyback reasons

SCTP Socket Options SCTP_ASSOCINFO – get information about existing association, change parameters of existing association, set defaults for future associations SCTP_AUTOCLOSE – autoclose time for SCTP endpoint SCTP_EVENTS – fetch, enable, disable various SCTP notifications SCTP_INITMSG – get or set initial parameters with INIT message SCTP_MAXBUST – max burst size – no more than this can be sent at once – avoids flooding SCTP_STATUS – current status of SCTP association (data amounts, number of streams, primary addresses and state)

fcntl File control – meaning control operations for descriptor –set to nonblocking I/O –set to signal-driven I/O –SIGIO and SIGURG signal based control for socket owner socket owner – only from listening socket – the socket owner is inherited from the listening socket by the connected socket

Summary Good to understand – SO_ERROR, SO_KEEPALIVE, SO_REUSEADDR, SO_LINGER SO_ERROR - Pending error for socket – standard Exxx values filled on failures SO_KEEPALIVE – TCP (SCTP) will keep the connection alive even no actual communication data is not transferred SO_REUSEADDR – different scenarios of address/port reusage SO_LINGER - How the close function is operating