1.\" Copyright (c) 1983, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" From: @(#)inet.4 8.1 (Berkeley) 6/5/93 29.\" $FreeBSD: src/share/man/man4/inet.4,v 1.11.2.6 2001/12/17 11:30:12 ru Exp $ 30.\" 31.Dd March 22, 2015 32.Dt INET 4 33.Os 34.Sh NAME 35.Nm inet 36.Nd Internet protocol family 37.Sh SYNOPSIS 38.In sys/types.h 39.In netinet/in.h 40.Sh DESCRIPTION 41The Internet protocol family is a collection of protocols 42layered atop the 43.Em Internet Protocol 44.Pq Tn IP 45transport layer, and utilizing the Internet address format. 46The Internet family provides protocol support for the 47.Dv SOCK_STREAM , SOCK_DGRAM , 48and 49.Dv SOCK_RAW 50socket types; the 51.Dv SOCK_RAW 52interface provides access to the 53.Tn IP 54protocol. 55.Sh ADDRESSING 56Internet addresses are four byte quantities, stored in 57network standard format (on the 58.Tn VAX 59these are word and byte 60reversed). The include file 61.In netinet/in.h 62defines this address 63as a discriminated union. 64.Pp 65Sockets bound to the Internet protocol family utilize 66the following addressing structure, 67.Bd -literal -offset indent 68struct sockaddr_in { 69 u_char sin_len; 70 sa_family_t sin_family; 71 u_short sin_port; 72 struct in_addr sin_addr; 73 char sin_zero[8]; 74}; 75.Ed 76.Pp 77Sockets may be created with the local address 78.Dv INADDR_ANY 79to affect 80.Dq wildcard 81matching on incoming messages. 82The address in a 83.Xr connect 2 84or 85.Xr sendto 2 86call may be given as 87.Dv INADDR_ANY 88to mean 89.Dq this host . 90The distinguished address 91.Dv INADDR_BROADCAST 92is allowed as a shorthand for the broadcast address on the primary 93network if the first network configured supports broadcast. 94.Sh PROTOCOLS 95The Internet protocol family is comprised of 96the 97.Tn IP 98network protocol, Internet Control 99Message Protocol 100.Pq Tn ICMP , 101Internet Group Management Protocol 102.Pq Tn IGMP , 103Transmission Control 104Protocol 105.Pq Tn TCP , 106and User Datagram Protocol 107.Pq Tn UDP . 108.Tn TCP 109is used to support the 110.Dv SOCK_STREAM 111abstraction while 112.Tn UDP 113is used to support the 114.Dv SOCK_DGRAM 115abstraction. A raw interface to 116.Tn IP 117is available 118by creating an Internet socket of type 119.Dv SOCK_RAW . 120The 121.Tn ICMP 122message protocol is accessible from a raw socket. 123.Pp 124The 32-bit Internet address contains both network and host parts. 125However, direct examination of addresses is discouraged. For those 126programs which absolutely need to break addresses into their component 127parts, the following 128.Xr ioctl 2 129commands are provided for a datagram socket in the Internet domain; 130they have the same form as the 131.Dv SIOCSIFADDR 132and 133.Dv SIOCGIFADDR 134commands (see 135.Xr intro 4 ) . 136.Bl -tag -width ".Dv SIOCSIFNETMASK" 137.It Dv SIOCSIFNETMASK 138Set interface network mask. 139The network mask defines the network part of the address; 140if it contains more of the address than the address type would indicate, 141then subnets are in use. 142.It Dv SIOCGIFNETMASK 143Get interface network mask. 144.El 145.Sh ROUTING 146The current implementation of Internet protocols includes some routing-table 147adaptations to provide enhanced caching of certain end-to-end 148information necessary for Transaction TCP and Path MTU Discovery. The 149following changes are the most significant: 150.Bl -enum 151.It 152All IP routes, except those with the 153.Dv RTF_CLONING 154flag and those to multicast destinations, have the 155.Dv RTF_PRCLONING 156flag forcibly enabled (they are thus said to be 157.Dq "protocol cloning" ) . 158.It 159When the last reference to an IP route is dropped, the route is 160examined to determine if it was created by cloning such a route. If 161this is the case, the 162.Dv RTF_PROTO3 163flag is turned on, and the expiration timer is initialized to go off in 164.Va net.inet.ip.rtexpire 165seconds. 166If such a route is re-referenced, the flag and expiration timer are reset. 167.It 168A kernel timeout runs once every ten minutes, or sooner if there are 169soon-to-expire routes in the kernel routing table, and deletes the 170expired routes. 171.El 172.Pp 173A dynamic process is in place to modify the value of 174.Va net.inet.ip.rtexpire 175if the number of cached routes grows too large. 176If after an expiration run there are still more than 177.Va net.inet.ip.rtmaxcache 178unreferenced routes remaining, the rtexpire 179value is multiplied by \(34, and any routes which have longer 180expiration times have those times adjusted. This process is damped 181somewhat by specification of a minimum rtexpire value 182.Va ( net.inet.ip.rtminexpire ) , 183and by restricting the reduction to once in a ten-minute period. 184.Pp 185If some external process deletes the original route from which a 186protocol-cloned route was generated, the ``child route'' is deleted. 187(This is actually a generic mechanism in the routing code support for 188protocol-requested cloning.) 189.Pp 190No attempt is made to manage routes which were not created by protocol 191cloning; these are assumed to be static, under the management of an 192external routing process, or under the management of a link layer 193(e.g., 194.Tn ARP 195for Ethernets). 196.Pp 197Only certain types of network activity will result in the cloning of a 198route using this mechanism. Specifically, those protocols (such as 199.Tn TCP 200and 201.Tn UDP ) 202which themselves cache a long-lasting reference to route for a destination 203will trigger the mechanism; whereas raw 204.Tn IP 205packets, whether locally-generated or forwarded, will not. 206.Ss MIB Variables 207A number of variables are implemented in the net.inet branch of the 208.Xr sysctl 3 209MIB. 210In addition to the variables supported by the transport protocols 211(for which the respective manual pages may be consulted), 212the following general variables are defined: 213.Bl -tag -width IPCTL_FASTFORWARDING 214.It Dv IPCTL_FORWARDING 215.Pq ip.forwarding 216Boolean: enable/disable forwarding of IP packets. 217Defaults to off. 218.It Dv IPCTL_FASTFORWARDING 219.Pq ip.fastforwarding 220Boolean: enable/disable the use of fast IP forwarding code. 221Defaults to off. 222When fast forwarding is enabled, IP packets are forwarded directly to 223the appropriate network interface with a minimal validity checking, which 224greatly improves the throughput. On the other hand, they bypass the 225standard procedures, such as IP option processing and 226.Xr ipfirewall 4 227checking. 228It is not guaranteed that every packet will be fast-forwarded. 229.It Dv IPCTL_SENDREDIRECTS 230.Pq ip.redirect 231Boolean: enable/disable sending of ICMP redirects in response to 232unforwardable 233.Tn IP 234packets. 235Defaults to on. 236.It Dv IPCTL_DEFTTL 237.Pq ip.ttl 238Integer: default time-to-live 239.Pq Dq TTL 240to use for outgoing 241.Tn IP 242packets. 243.It Dv IPCTL_SOURCEROUTE 244.Pq ip.sourceroute 245Boolean: enable/disable forwarding of source-routed IP packets (default false). 246.It Dv IPCTL_RTEXPIRE 247.Pq ip.rtexpire 248Integer: lifetime in seconds of protocol-cloned 249.Tn IP 250routes after the last reference drops (default one hour). This value 251varies dynamically as described above. 252.It Dv IPCTL_RTMINEXPIRE 253.Pq ip.rtminexpire 254Integer: minimum value of ip.rtexpire (default ten seconds). This 255value has no effect on user modifications, but restricts the dynamic 256adaptation described above. 257.It Dv IPCTL_RTMAXCACHE 258.Pq ip.rtmaxcache 259Integer: trigger level of cached, unreferenced, protocol-cloned routes 260which initiates dynamic adaptation (default 128). 261.El 262.Sh SEE ALSO 263.Xr ioctl 2 , 264.Xr socket 2 , 265.Xr sysctl 3 , 266.Xr icmp 4 , 267.Xr intro 4 , 268.Xr ip 4 , 269.Xr ipfirewall 4 , 270.Xr tcp 4 , 271.Xr udp 4 272.Rs 273.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial" 274.%B PS1 275.%N 7 276.Re 277.Rs 278.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial" 279.%B PS1 280.%N 8 281.Re 282.Sh CAVEAT 283The Internet protocol support is subject to change as 284the Internet protocols develop. Users should not depend 285on details of the current implementation, but rather 286the services exported. 287.Sh HISTORY 288The 289.Nm 290protocol interface appeared in 291.Bx 4.2 . 292The 293.Dq protocol cloning 294code appeared in 295.Fx 2.1 . 296