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