⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a.t

📁 早期freebsd实现
💻 T
字号:
.\" Copyright (c) 1983, 1986, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)a.t	8.1 (Berkeley) 6/8/93.\".nr H2 1.\".ds RH "Gateways and routing.br.ne 2i.NH\s+2Gateways and routing issues\s0.PPThe system has been designed with the expectation that it willbe used in an internetwork environment.  The ``canonical''environment was envisioned to be a collection of local areanetworks connected at one or more points through hosts withmultiple network interfaces (one on each local area network),and possibly a connection to a long haul network (for example,the ARPANET).  In such an environment, issues ofgatewaying and packet routing become very important.  Certainof these issues, such as congestioncontrol, have been handled in a simplistic manner or specificallynot addressed.Instead, where possible, the network systemattempts to provide simple mechanisms upon which more involvedpolicies may be implemented.  As some of these problems becomebetter understood, the solutions developed will be incorporatedinto the system..PPThis section will describe the facilities provided for packetrouting.  The simplistic mechanisms provided for congestioncontrol are described in chapter 12..NH 2Routing tables.PPThe network system maintains a set of routing tables forselecting a network interface to use in delivering a packet to its destination.  These tables are of the form:.DS.ta \w'struct   'u +\w'u_long   'u +\w'sockaddr rt_gateway;    'ustruct rtentry {	u_long	rt_hash;		/* hash key for lookups */	struct	sockaddr rt_dst;	/* destination net or host */	struct	sockaddr rt_gateway;	/* forwarding agent */	short	rt_flags;		/* see below */	short	rt_refcnt;		/* no. of references to structure */	u_long	rt_use;			/* packets sent using route */	struct	ifnet *rt_ifp;		/* interface to give packet to */};.DE.PPThe routing information is organized in two separate tables, onefor routes to a host and one for routes to a network.  Thedistinction between hosts and networks is necessary sothat a single mechanism may be usedfor both broadcast and multi-drop type networks, andalso for networks built from point-to-point links (e.gDECnet [DEC80])..PPEach table is organized as a hashed set of linked lists.Two 32-bit hash values are calculated by routines defined foreach address family; one based on the destination beinga host, and one assuming the target is the network portionof the address.  Each hash value is used tolocate a hash chain to search (by taking the value modulo thehash table size) and the entire 32-bit value is thenused as a key in scanning the list of routes.  Lookups areapplied first to the routingtable for hosts, then to the routing table for networks.If both lookups fail, a final lookup is made for a ``wildcard''route (by convention, network 0).The first appropriate route discovered is used.By doing this, routes to a specific host on a network may bepresent as well as routes to the network.  This also allows a``fall back'' network route to be defined to a ``smart'' gatewaywhich may then perform more intelligent routing..PPEach routing table entry contains a destination (the desired final destination),a gateway to which to send the packet,and various flags which indicate the route's status and type (host ornetwork).  A countof the number of packets sent using the route is kept, alongwith a count of ``held references'' to the dynamicallyallocated structure to insure that memory reclamationoccurs only when the route is not in use.  Finally, a pointer to thea network interface is kept; packets sent usingthe route should be handed to this interface..PPRoutes are typed in two ways: either as host or network, and as``direct'' or ``indirect''.  The host/networkdistinction determines how to compare the \fIrt_dst\fP fieldduring lookup.  If the route is to a network, only a packet'sdestination network is compared to the \fIrt_dst\fP entry storedin the table.  If the route is to a host, the addresses mustmatch bit for bit..PPThe distinction between ``direct'' and ``indirect'' routes indicateswhether the destination is directly connected to the source.This is needed when performing local network encapsulation.  Ifa packet is destined for a peer at a host or network which isnot directly connected to the source, the internetwork packetheader willcontain the address of the eventual destination, whilethe local network header will address the interveninggateway.  Should the destination be directly connected, these addressesare likely to be identical, or a mapping between the two exists.The RTF_GATEWAY flag indicates that the route is to an ``indirect''gateway agent, and that the local network header should be filled infrom the \fIrt_gateway\fP field instead offrom the final internetwork destination address..PPIt is assumed that multiple routes to the same destination will notbe present; only one of multiple routes, that most recently installed,will be used..PPRouting redirect control messages are used to dynamicallymodify existing routing table entries as well as dynamicallycreate new routing table entries.  On hosts where exhaustiverouting information is too expensive to maintain (e.g. workstations), thecombination of wildcard routing entries and routing redirectmessages can be used to provide a simple routing managementscheme without the use of a higher level policy process. Current connections may be rerouted after notification of the protocolsby means of their \fIpr_ctlinput\fP entries.Statistics are kept by the routing table routineson the use of routing redirect messages and theiraffect on the routing tables.  These statistics may be viewed using.IR netstat (1)..PPStatus information other than routing redirect control messagesmay be used in the future, but at present they are ignored.Likewise, more intelligent ``metrics'' may be used to describeroutes in the future, possibly based on bandwidth and monetarycosts..NH 2Routing table interface.PPA protocol accesses the routing tables throughthree routines,one to allocate a route, one to free a route, and oneto process a routing redirect control message.The routine \fIrtalloc\fP performs route allocation; it iscalled with a pointer to the following structure containingthe desired destination:.DS._fstruct route {	struct	rtentry *ro_rt;	struct	sockaddr ro_dst;};.DEThe route returned is assumed ``held'' by the caller untilreleased with an \fIrtfree\fP call.  Protocols which implementvirtual circuits, such as TCP, hold onto routes for the durationof the circuit's lifetime, while connection-less protocols,such as UDP, allocate and free routes whenever their destination addresschanges..PPThe routine \fIrtredirect\fP is called to process a routing redirectcontrol message.  It is called with a destination address,the new gateway to that destination, and the source of the redirect.Redirects are accepted only from the current router for the destination.If a non-wildcard routeexists to the destination, the gateway entry in the route is modified to point at the new gateway supplied.  Otherwise, a new routingtable entry is inserted reflecting the information supplied.  Routesto interfaces and routes to gateways which are not directly accessiblefrom the host are ignored..NH 2User level routing policies.PPRouting policies implemented in user processes manipulate thekernel routing tables through two \fIioctl\fP calls.  Thecommands SIOCADDRT and SIOCDELRT add and delete routing entries,respectively; the tables are read through the /dev/kmem device.The decision to place policy decisions in a user process impliesthat routing table updates may lag a bit behind the identification ofnew routes, or the failure of existing routes, but this periodof instability is normally very small with proper implementationof the routing process.  Advisory information, such as ICMPerror messages and IMP diagnostic messages, may be read fromraw sockets (described in the next section)..PPSeveral routing policy processes have already been implemented.  Thesystem standard``routing daemon'' uses a variant of the Xerox NS Routing InformationProtocol [Xerox82] to maintain up-to-date routing tables in our localenvironment.  Interaction with other existing routing protocols,such as the Internet EGP (Exterior Gateway Protocol), has beenaccomplished using a similar process.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -