IPv4 socket option Level => IPPROTO_IP

Slides:



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

Chapter 17 Networking Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
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.
Guide to TCP/IP, Third Edition
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.
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
I/O Multiplexing Road Map: 1. Motivation 2. Description of I/O multiplexing 3. Scenarios to use I/O multiplexing 4. I/O Models  Blocking I/O  Non-blocking.
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.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 OSI Transport Layer Network Fundamentals – Chapter 4.
Computer Networks Sockets. Sockets and the OS F An end-point for Internet connection –What the application “plugs into” –OS provides Application Programming.
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
1 Application Presentation Session Transport Network Datalink Physical OSI model Application IPv4, IPv6 Device Driver Hardware TCPUDP Internet.
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.
Process-to-Process Delivery:
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Network Layer ICMP and fragmentation.
Internet Protocol (IP)
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
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.
CS4550 Computer Networks II IP : internet protocol, part 2 : packet formats, routing, routing tables, ICMP read feit chapter 6.
Network Programming Eddie Aronovich mail:
7.9 TCP Socket Options 7.10 SCTP Socket Options 7.11 fcntl Function 7.12 Summary 報告者 : 梁凱鈞.
Netprog: Advanced Sockets Programming1 Advanced Sockets Programming Ref: Chapter 7,11,21,22.
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.
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.
S305 – Network Infrastructure Chapter 5 Network and Transport Layers.
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,
COP 4930 Computer Network Projects Summer C 2004 Prof. Roy B. Levow Lecture 9.
IP Configuration API. Network Interface Configuration NAIfconfigIsDeviceUp() NAIfconfigDeviceFromInterface() NAIfconfigBringDeviceUp() NAIfconfigSetIpAddress()
Ioctl Operations. ioctl Function Interface Configuration  Netstat, ifconfig command 에서 사용.
UDP : User Datagram Protocol 백 일 우
Data Communications and Networks Chapter 6 – IP, UDP and TCP ICT-BVF8.1- Data Communications and Network Trainer: Dr. Abbes Sebihi.
Chapter 3 TCP and IP 1 Chapter 3 TCP and IP. Chapter 3 TCP and IP 2 Introduction Transmission Control Protocol (TCP) User Datagram Protocol (UDP) Internet.
Cisco I Introduction to Networks Semester 1 Chapter 7 JEOPADY.
IP Fragmentation. Network layer transport segment from sending to receiving host on sending side encapsulates segments into datagrams on rcving side,
Chapter 20 Network Layer: Internet Protocol Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Network Layer/IP Protocols 1. Outline IP Datagram (IPv4) NAT Connection less and connection oriented service 2.
Network Models. 2.1 what is the Protocol? A protocol defines the rules that both the sender and receiver and all intermediate devices need to follow,
Andrew Hanushevsky: Sendfile() First INFN International School on Architectures, tools and methodologies for developing efficient large scale scientific.
Chapter 5 Network and Transport Layers
Chapter 3 TCP and IP Chapter 3 TCP and IP.
Introduction to TCP/IP networking
Multiplexing.
Socket Option.
Transport Layer.
Process-to-Process Delivery
Net 431: ADVANCED COMPUTER NETWORKS
Internet Protocol (IP)
Process-to-Process Delivery:
Remote Procedure Call (RPC)
Chapter 07. Socket Options.
Advanced Sockets Programming
Process-to-Process Delivery: UDP, TCP
Socket options: a summary
Transport Layer 9/22/2019.
Advanced UNIX programming
Presentation transcript:

IPv4 socket option Level => IPPROTO_IP IP_HDRINCL => If this option is set for a raw IP socket, we must build our IP header for all the datagrams that we send on the raw socket.(chapter 26)

IP_OPTIONS=>allows us to set IP option in IPv4 header.(chapter 24) IP_RECVDSTADDR=>This socket option causes the destination IP address of a received UDP datagram to be returned as ancillary data by recvmsg.(chapter20)

IP_RECVIF Cause the index of the interface on which a UDP datagram is received to be returned as ancillary data by recvmsg.(chapter20)

IP_TOS lets us set the type-of-service(TOS) field in IP header for a TCP or UDP socket. If we call getsockopt for this option, the current value that would be placed into the TOS(type of service) field in the IP header is returned.(figure A.1)

IP_TTL We can set and fetch the default TTL(time to live field, figure A.1).

ICMPv6 socket option This socket option is processed by ICMPv6 and has a level of IPPROTO_ICMPV6. ICMP6_FILTER =>lets us fetch and set an icmp6_filter structure that specifies which of the 256possible ICMPv6 message types are passed to the process on a raw socket.(chapter 25)

IPv6 socket option This socket option is processed by IPv6 and have a level of IPPROTO_IPV6. IPV6_ADDRFORM=>allow a socket to be converted from IPv4 to IPv6 or vice versa.(chapter 10) IPV6_CHECKSUM=>specifies the byte offset into the user data of where the checksum field is located.

IPV6_DSTOPTS Specifies that any received IPv6 destination options are to be returned as ancillary data by recvmsg.

IPV6_HOPLIMIT Setting this option specifies that the received hop limit field be returned as ancillary data by recvmsg.(chapter 20) Default off.

IPV6_HOPOPTS Setting this option specifies that any received IPv6 hop-by-hop option are to be returned as ancillary data by recvmsg.(chapter 24)

IPV6_NEXTHOP This is not a socket option but the type of an ancillary data object that can be specified to sendmsg. This object specifies the next-hop address for a datagram as a socket address structure.(chapter20)

IPV6_PKTINFO Setting this option specifies that the following two pieces of infoemation about a received IPv6 datagram are to be returned as ancillary data by recvmsg:the destination IPv6 address and the arriving interface index.(chapter 20)

IPV6_PKTOPTIONS Most of the IPv6 socket options assume a UDP socket with the information being passed between the kernel and the application using ancillary data with recvmsg and sendmsg. A TCP socket fetch and store these values using IPV6_ PKTOPTIONS socket option.

IPV6_RTHDR Setting this option specifies that a received IPv6 routing header is to be returned as ancillary data by recvmsg.(chapter 24) Default off

IPV6_UNICAST_HOPS This is similar to the IPv4 IP_TTL. Specifies the default hop limit for outgoing datagram sent on the socket, while fetching the socket option returns the value for the hop limit that the kernel will use for the socket.

TCP socket option There are five socket option for TCP, but three are new with Posix.1g and not widely supported. Specify the level as IPPROTO_TCP.

TCP_KEEPALIVE This is new with Posix.1g It specifies the idle time in second for the connection before TCP starts sending keepalive probe. Default 2hours this option is effective only when the SO_KEEPALIVE socket option enabled.

TCP_MAXRT This is new with Posix.1g. It specifies the amount of time in seconds before a connection is broken once TCP starts retransmitting data. 0 : use default -1:retransmit forever positive value:rounded up to next transmission time

TCP_MAXSEG This allows us to fetch or set the maximum segment size(MSS) for TCP connection.

TCP_NODELAY purpose of the Nagle algorithm. This option disables TCP’s Nagle algorithm. (default this algorithm enabled) purpose of the Nagle algorithm. ==>prevent a connection from having multiple small packets outstanding at any time. Small packet => any packet smaller than MSS.

Nagle algorithm Default enabled. Reduce the number of small packet on the WAN. If given connection has outstanding data , then no small packet data will be sent on connection until the existing data is acknowledged.

Nagle algorithm disabled e 250 l 500 l 750 o 1000 ! 1250 1500 1500 1750 2000

Nagle algorithm enabled e 250 l 500 el l 750 o 1000 ! 1250 lo 1500 1500 1750 ! 2000 2250 2500

fcntl function File control This function perform various descriptor control operation. Provide the following features Nonblocking I/O(chapter 15) signal-driven I/O(chapter 22) set socket owner to receive SIGIO signal. (chapter 21,22)

#include <fcntl.h> int fcntl(int fd, int cmd, …./* int arg */); Returns:depends on cmd if OK, -1 on error O_NONBLOCK : nonblocking I/O O_ASYNC : signal driven I/O notification

Nonblocking I/O using fcntl Int flags; /* set socket nonblocking */ if((flags = fcntl(fd, f_GETFL, 0)) < 0) err_sys(“F_GETFL error”); flags |= O_NONBLOCK; if(fcntl(fd, F_SETFL, flags) < 0) err_sys(“F_ SETFL error”); each descriptor has a set of file flags that fetched with the F_GETFL command and set with F_SETFL command.

Misuse of fcntl /* wrong way to set socket nonblocking */ if(fcntl(fd, F_SETFL,O_NONBLOCK) < 0) err_sys(“F_ SETFL error”); /* because it also clears all the other file status flags.*/

Turn off the nonblocking flag Flags &= ~O_NONBLOCK; if(fcntl(fd, F_SETFL, flags) < 0) err_sys(“F_SETFL error”);

F_SETOWN The integer arg value can be either positive(process ID) or negative (group ID)value to receive the signal. F_GETOWN => retrurn the socket owner by fcntl function, either process ID or process group ID.