Socket option Getsockopt ou setsockopt fcntl ioctl.

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.
Laboratório de Teleprocessamento e Redes1 Unix Network Programming Prof. Nelson Fonseca
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
Chapter 12 Transport protocols. Outline 12.1 introduction 12.2 TCP/IP protocol suite.
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.
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.
Computer Networks Sockets.
Internet Control Message Protocol (ICMP). Introduction The Internet Protocol (IP) is used for host-to-host datagram service in a system of interconnected.
Multimedia Networking Sockets. 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.
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.
CCNA Introduction to Networking 5.0 Rick Graziani Cabrillo College
Petrozavodsk State University, Alex Moschevikin, 2003NET TECHNOLOGIES Internet Control Message Protocol ICMP author -- J. Postel, September The purpose.
ICMP (Internet Control Message Protocol) Computer Networks By: Saeedeh Zahmatkesh spring.
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Network Layer ICMP and fragmentation.
Elementary UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
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.
University of Calgary – CPSC 441.  UDP stands for User Datagram Protocol.  A protocol for the Transport Layer in the protocol Stack.  Alternative to.
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.
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
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.
Chapter 12 Transmission Control Protocol (TCP)
1 Internet Control Message Protocol (ICMP) Used to send error and control messages. It is a necessary part of the TCP/IP suite. It is above the IP module.
CS4550 Computer Networks II IP : internet protocol, part 2 : packet formats, routing, routing tables, ICMP read feit chapter 6.
Chapter 2 Applications and Layered Architectures Sockets.
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.
TELE 402 Lecture 10: Unix domain … 1 Overview Last Lecture –Daemon processes and advanced I/O functions This Lecture –Unix domain protocols and non-blocking.
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.
CSCE 515: Computer Network Programming UDP Socket Wenyuan Xu Department of Computer Science and Engineering.
Socket options: a summary –Tcp options, ip options and general socket options can be examined and sometimes modified. getsockopt, setsockopt routines Some.
Understanding IPv6 Slide: 1 Lesson 12 IPv6 Mobility.
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.
1 Requirements for Internet Routers (Gateways) and Hosts Relates to Lab 3. (Supplement) Covers the compliance requirements of Internet routers and hosts.
Today’s topic: UDP Reliable communication over UDP.
ICMPv6 Error Message Types Informational Message Types.
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,
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
Computer Networking Project II question/answer session October 18, 2001.
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).
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
11 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
Client/Server Design Issues Based on Java Network Programming and Distributed Computing, Chapter 6 Also Online Java Tutorial, Sun.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
IPv4 socket option Level => IPPROTO_IP
Socket Option.
Internet Control Message Protocol (ICMP)
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
Transport Layer 9/22/2019.
Advanced UNIX programming
Presentation transcript:

Socket option Getsockopt ou setsockopt fcntl ioctl

Socket option #include 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); Both return: 0 if OK,–1 on error Level – code in the system to interpret the option Optval – pointer to a variable from which the new value of the option is fetched by setsocopt or into which the current value of the option is stored

Options

Socket options Options inherited by a connected TCP socket from the listening socket  SO_DEBUG;  SO_DONTROUTE;  SO_KEEPALIVE;  SO_LINGER;  SO_OOBINLINE;  SO_RCVBUF;  SO_SNDBUF.

SO_BROADCAST Enables/disable the ability to send broadcast messages Only for networks that allow broadcast Code EACCESS returned

SO_DEBUG Valid for TCP Keeps track of all segment sent and received by TCP, kept on a circular buffer which can be examined by the kernel using the trpt function

SO_DONTROUTE Used to bypass the routing mechanism For UDP sockets, can set flag MSG_DONTROUTE when using send, sento, sendmsg Used by routing daemons to ignore the content of routing tables

SO_ERROR Used to retrieve error code Blocked process is notified via a select or a signal driven I/O

SO_KEEPALIVE If option is set TCP send automatically a keepalive message every two hours without exchanging data across the socket. What can happen:  TCP peer sends an ACK. The applications is not notified;  TCP peer sends na RST. Socket is closed and the error message ECONNRESET is returned.  If no response is given, at most eight messages are sent, one every 75 seconds. After that an error code ETIMEDOUT is sent

SO_KEEPALIVE (cont.):  If an ICMP message “host unreachable” is recieved, it is passed to the application  The duration of the interval to send the keepalive message can be altered to all sockets  Used in servers

SO_KEEPALIVE

SO_LINGER By default, close send data in buffer and returns immediately. So-linger allows change this way of operation struct linger { int l_onoff; /* 0=off, nonzero=on */ int l_linger; /* linger time (seconds) */ }; l_onoff is zero, option is turned off close is called. Option is ignored l_onoff is nonzsero and l_linger = zero buffer content is discarded and connection is discarded, an RST is sent to the peer, avoids time-wait

SO_LINGER l_onoff non zero, l_linger non zero – process is put to sleep until all data in buffer is sent and acked or linger period expires The expiration of lingertime can be checked

SO_LINGER

 Application level ack  Client: char ack; Write(sockfd, data, nbytes); n = Read(sockfd, &ack, 1);  Server: nbytes = Read(sockfd, buff, sizeof(buff)); Write(sockfd, "", 1);

SO_LINGER

SO_OOBINLINE Out-of-band data is put in the normal buffer queue

SO_RCVBUF e SO_SNDBUF Set value for the size of send buffer and receive buffer Default values  TCP old versions: 4096 bytes  TCP current versions: 8192 a bytes  UDP send buffer 9000 bytes and UDP receive buffer 40000

SO_RCVBUF e SO_SNDBUF The size of the buffer needs to be set before connect is called at the client and before listen is called at the server in the server A atribuição do tamanho do buffer deve ser feita no cliente antes de chamar connect e no servidor antes de chamar listen At least 3 MSS is recommended

Bandwidth – delay product Bandwidth – Delay product – amount of byte in the pipe Transmission rate x RTT For instance: T1 ( bytes/sec) with an RTT of 60ms, bandwidth-delay product = 11,520 bytes If buffer is smaller than bandwidth-delay product TCP becomes the bottleneck Need larger buffers for high speed networks or networks with long propagation delays (satellite networks)

SO_RCVLOWAT e SO_SNDLOWAT Changes the low-water mark of the buffer Minimum amount of data required by select to consider data as either read or written

SO_REUSEADDR Allows server to perform bind on a port even if it is being used by another process (typically connected socket derived from a listening sockets) Allows multiple instances of the same server to be started on the same port as each instance binds a different local IP address

SO_REUSEADDR Allows a single process to bind the same port to multiple sockets, as long as each bind specifies a different local IP Allows completely duplicated bindings: a bind of an IP address and port when the same IP address and port are already bound to another socket. Useful for multicast when the socket option SO_REUSEPORT is not available

SO_REUSEPORT SO_REUSEADDR is equivalent to SO_REUSEPORT when multicast is used

SO_TYPE e SO_USELOOPBACK SO_TYPE: returns the socket type SO_USELOOPBACK: receives copy of all transmitted

IPv4 Options Level IPROTO_IP IP_HDRINCL – allows writing to IP header – used in RAW_SOCKET (ICMP) What cannot be attributed  Checksum  IP identification field  Output interface INADDR_V4  Implementation dependent option

IPv4 Options IP_options – allow setting of IP datagram fields IP_RECVDSTADDR – allow to return a UDP packet as ancillary data (control) by using recvmsg IP_TOS – allow setting field ToS

IPv4 Options IP_TTL – allow writing and reading to filed Time to Live (TTL). Default = 64

IPv6 Options LEVEL IPTPROTO_IPv6 IPv6_ADDRFOMR – allows converting an IPv4 socket to an IPv6 socket IPv6 checksum – computes and store checksum for outgoing packets and verify checksum for incoming packets. Parameter indicates where checksum field is located

IPv6 Options IPv6_DSTOPTS – specifies that any received IPv6 destination option are to be returned as ancillary data by recvmsg IPv6_HOPLIMIT – specifies that the received hop limit field to be returned as ancillary data by recvmsg IPv6_HOPOPTS – specifies that the option hop-by-hop has to be returned as ancillary by recvmsg IPv6_NEXTHOP – specifies the next hop a packet should go

IPv6 Options IPv6_PKTINFO – specifies that destination address and interface are to be returned as ancillary data IPv6_RTHDR – specifies that the routing fileds of the header should be returned as ancillary data by rcvmsg IPv6-UNICAST_HOPS – set thehop limit

ICMPv6 Level IPROTO_ICMPv6 ICMP6_FILTER – specifies which of the 256 ICMPv6 messages can be sent on a podem RAWSOCKET

Opções TCP TCP_KEEPALIVE – specifies the time interval in seconds that the connection should send keepalive messages TCP_MAXSEG – allows setting and retrieving value of MSS TCP_NODELAY – disable Nagle’s algorithm which prevents small packets to be sent. Small segments are sent in case there are pending acks

Opções TCP

TCP_STDURG – changes interpretation of the urgent pointer field