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

📄 net_design.nr

📁 早期freebsd实现
💻 NR
📖 第 1 页 / 共 3 页
字号:
.NC "The Design of the ARGO Network Layer".sh 1 "Connectionless Network Layer.ppThe following sections describe the design of the ARGOconnectionless network layer (CLNL).The connectionless network service is provided by severalnetwork-layer protocols: ES-IS (ISO 9542), CLNP (ISO 8348), and (ISO 8208) X.25.The protocol CLNP is the primary connectionless network layerprotocol.It is supported by X.25 when X.25 is used as a subnetwork layer.X.25 can also be viewed as a link layer protocol in this context.The ES-IS protocol supports CLNP by providing the following functions:.ip \(bu 5automatic mapping of NSAP-addresses to SNPA addresses,.ip \(bu 5automatic configuration of networks of end systems and intermediatesystems,  and.ip \(bu 5redirection of network-layer traffic in response to configuration changes..ppThe rest of this chapter describes the design of CLNP, the design of  ES-IS,and the design of the connection-orientednetwork layer, including the connection-oriented subnetwork service (X.25)..ppCLNP has two subsets defined: the Inactive Network Layer protocol subset and the Non-Segmenting protocol subset. The Inactive Network Layer subset is a null-function subset in which the CLNP is not needed, and the protocol consists of sendinga 1-byte header containing the value zero. This "subset" is not supported in ARGO..ppThe Non-Segmenting protocol subset permits simplification of the DT NPDUheader when it is known that segmentation of the DT NPDU is not required.ARGO supports this subset.When this subset is used, the segmentation part of the DT NPDU (data packet) header is not present, and the \fIdon't segment\fR bit is set in the fixed part of the header. This subset is chosen by setting the bit\fICLNP_NO_SEG\fR in the \fIflags\fR argument to \fIclnp_output()\fR..ppThroughout the remainder of thisdocument,following definitions apply:.(b\(bu DT NPDU: data transfer NPDU.\(bu ER NPDU: error report NPDU.\(bu NPDU: either an ER or DT NPDU..)b.sh 2 "DT NPDU Output".ppA CLNP DT NPDU is transmitted by calling \fIclnp_output()\fR. .so figs/clnp_output.nr.\" FIGURE.CFoutlines the sequence of steps taken by \fIclnp_output()\fR whentransmitting an NPDU. The solid lines indicate normal flow of control. Thedashed lines indicate possible error returns (with associatederror code)..pp\fIClnp_output()\fR will automatically cache (in the \fIisopcb\fR)the header of each packet it sends. This cached copy of the headeris used on subsequent sends reducing the amount of time spent generatingthe header. Therefore, the first action \fIclnp_output()\fR takes is toexamine the cached header (if any). If the header is still valid (see below)then it is used. Otherwise, a new header is built..sh 3 "When The Cached Header Is Invalid".ppBefore any resources are allocated, the options to be sent with the packetare examined. If any unsupported options are present, the error \fIEINVAL\fRis returned.Next, the length of the source and destination NSAP addresses (taken from the \fIisopcb\fR)are checked. The source address length may be zero. Thisindicates that \fIclnp_output()\fR should compute the source address based uponthe route taken, in which case CLNP callsthe function \fIclnp_srcroute()\fR.Source routing will be discussed in detail later in this section.If, in the process of checkingthe address lengths, an invalid length is detected, the error\fIENAMETOOLONG\fR is returned..ppAfter checking the lengths of the addresses, CLNP allocates an \fImbuf\fR in which the DT NPDU header will be constructed. If an \fImbuf\fR cannot be found, the error\fIENOBUFS\fR is returned. Once the \fImbuf\fR is allocated, the fixed part of the DT NPDU header is copied into the \fImbuf\fR..ppThe next step is to route the DT NPDU. This is accomplished by the\fIclnp_route()\fR function. It is necessary to route the datagram early in the output process becausein many cases, the source address will not be known until the routehas been created.When a system is multi-homed it has several source addresses. The source address to choose depends on thenetwork interface (thus, the route) used..ppThe address part of the DT NPDU follows the fixed part. Since appending the address part is the next task, the source address must be determined.Therefore the route must be determined..ppAfter appending the address part to the fixed part of theNPDU header, CLNPappends any options given in the arguments to \fIclnp_output()\fR.The options are specified in aseparate \fImbuf\fR stored in the \fIiso_pcb\fR.If this \fImbuf\fRpointer is not null, a copy of the \fImbuf\fR is made, and this copy is chained (appended) to the\fImbuf\fR in which theNPDU header resides. The options \fImbuf\fR linked in with the DT packetmust be a copy of the options \fImbuf\fR passed to \fIclnp_output()\fR. Ifthis was not done, thenthe options \fImbuf\fR passed would be freed by the interfacedriver after the NPDU had been transmitted.Since a copy must be made, it is possible for \fIclnp_output()\fR toreturn \fIENOBUFS\fR at this time.A later section of this chapter describesthe handling of options in greater detail..ppUser data for the packet are passed to \fIclnp_output()\fR as an \fImbuf\fR chain.This \fImbuf\fR chain is appended to the DT NPDU header chain. At this point, the DT NPDU is ready for transmission. If header caching has not been disabled, a cache entry is made in the \fIisopcb\fR.If the size of the entire packet is less than the maximum transmission unit (MTU) of the network interface to be used,the packet is placed on the queue for that network interface,otherwise \fIclnp_fragment()\fR is invoked tobreak up the packet into smaller packets, called"derived NPDUs", and transmit the derived NPDUs..sh 3 "When A Cached Header Exists".ppIn this case, \fIclnp_output()\fR updates the segmentation part of theheader (if segmenting is permitted), computes the checksum, and transmits(or fragments) the packet..ppThe cached CLNP header is stored in the \fIstruct isopcb\fR. The field\fIisop_clnpcache\fR within the \fIisopcb\fR points to an \fImbuf\fRwhich contains a \fIstruct clnp_cache\fR:.(b\fC.TStab(+);l s s.struct clnp_cache {.T&l l l l.+u_short+cni_securep;+/* ptr to security option */+struct iso_addr+clc_dst;+/* destination of packet */+struct mbuf+*clc_options;+/* ptr to options mbuf */+int+clc_flags;+/* flags passed to clnp_output */+int+clc_segoff;+/* offset of seg part of header */+struct sockaddr+*clc_firsthop;+/* first hop of packet */+struct ifnet+*clc_ifp;+/* ptr to interface */+struct mbuf+*clc_hdr;+/* cached pkt hdr (finally)! */};.TE\fR.)bThe first three fields \fIclc_dst, clc_options\fR and \fIclc_flags\fRare used to check the validity of the cache entry. The cache is consideredvalid if:.ip \(bu 5The options mbuf has not changed..ip \(bu 5The destination of the packet has not changed..ip \(bu 5The route still exists and is up..ip \(bu 5The flags have not changed..ppIf all these conditions are met, then the bulk of the \fIclnp_output()\fRprocessing is avoided. The fields \fIclc_segoff, clc_firsthop,\fR and \fIclc_ifp\fR are used by \fIclnp_output()\fR to transmit the packet.The field \fIclc_ifp\fR contains the actual cached header which is copiedand then enqueued on the outgoing interface..sh 2 "NPDU Input".pp.\" FIGURE.so figs/clnp_input.nrAll CLNP NPDUs are processed by \fIclnp_input()\fR. .CFoutlinesthe flow of control within \fIclnlintr()\fR and \fIclnp_input()\fR. The solid linesindicate normal flow of control. The dashed lines indicate possible error returns..pp\fIClnlintr()\fR is invoked by a software interrupt. This interrupt is posted by a device driver whenever a packet is placed in CLNL's input queue \fIclnlintrq()\fR, and the queue is empty. It is the responsibility of \fIclnlintr()\fR, when invoked, to process all packets present on the input queue. Thus, to begin the task of processing a packet, \fIclnlintr()\fRremoves the next packet from the queue. When an error is discovered during processing, the packet is discarded and\fIclnlintr()\fR begins afresh..ppOnce removed, the type of the NPDU is checked. If the NPDU is anES-IS packet, then \fIesis_input()\fR is called. If the NPDU is a CLNPpacket, then \fIclnp_input()\fR is called. Other packets are silentlydiscarded.The function \fIclnp_hdr_ck()\fR checks the NPDU for consistency. Before checking consistency, \fIclnp_hdr_ck()\fR insuresthat the entire NPDU header is locatedcontigiously in a single \fImbuf\fR (\fIm_pullup()\fR\** performs this task)..(f\** If the NPDU header is larger than \fIMLEN\fR (currently 256), then\fIm_pullup()\fR will allocate a cluster \fImbuf\fR..)fAfter "pulling" the header into a single \fImbuf\fR, \fIclnp_hdr_ck()\fRchecks for the proper CLNP version and protocol identification. It also checks that the lifetime field is greater than zero.After checking header consistency, the NPDU checksum is computed.\**.(f\** If the checksum value is zero, the checksum is not computed. The value zero is reserved to mean \*(lqdo not use checksum\*(rq..)fIf the checksum is valid, \fIclnp_data_ck()\fR is called to insurethat the amount of data in the \fImbuf\fR chain corresponds to theamount indicated in the NPDU header..ppOnce the consistency of the NPDU has been assured, the various parts of thepacket are extracted. Care is taken with each extraction to insure that an attempt is not madeto address data that does not really exist. (Such an attempt couldresult in a kernel trap)..ppNext, the options part of the NPDU, if present, is checked for validity.If unsupported options are found, the packet is discarded. See the section \*(lqNPDU options\*(rq for details of options processing..ppFinally, after the preceding checks and extractions have been made, thedestination address is examined. If the address indicates that the packet's destination is not thissystem, the packet is forwarded by calling \fIclnp_forward()\fR. See the section \*(lqDT NPDU Forwarding\*(rl for details of packet forwarding.If this end system is thepacket's destination, processing continues..ppIf the packet is not complete, it is passed to \fIclnp_reass()\fR forreassembly. See the section \*(lqDT NPDU Reassembly\*(rqfor details of packet reassembly..ppAt this point, a complete NPDU is in hand. If the NPDU is a DT NPDU, it is given to the transport layerby calling the TP input routine. Otherwise, it is give to the ER NPDU processing function, \fIclnp_er_input()\fR..sh 3 "DT NPDU Forwarding".ppPacket forwarding is accomplished by \fIclnp_forward()\fR. This is performed regardless of the system's type (end or intermediate).The task offorwarding a packet is fairly straight-forward. First, the lifetimefield of the datagram is decremented. If this operation changes the value to zero, the packet is discarded..ppIf the source route option is present, and the address at the top of the listmatches an address of one of the system's network interfaces, thenthe next-source-route-to-be-used offset is adjusted in the option.Next, the packet is routed by \fIclnp_route()\fRor \fIclnp_srcroute()\fR. If the record route option is present, the address of the outgoing network interface is recorded by \fIclnp_dooptions()\fR..ppFinally the packet is dispatched. If the size of the entire packet is less than the MTU of the output network interface, the packet is enqueued for that interface, otherwise \fIclnp_fragment()\fR is invoked tofragment the packet and enqueue the derived NPDUs..sh 2 "NPDU Options".ppThe options section of an NPDU consists of a series of triplets:\fIoption identification\fR, \fIoption length\fR, and \fIoption value\fR. These triplets are checked each time the options are examined or changed. To avoid repeated parsing of the options, the ARGO CLNPmaintains an index. This index is organized as a \fIclnp_optidx\fR structure. This structure is shown below..(b\fC.TStab(+);l s s.struct clnp_optidx {.T&l l l l.+u_short+cni_securep;+/* ptr to security option */+char+cni_secure_len;+/* length of security option */+u_short+cni_srcrt_s;+/* offset of src rt option */+u_short+cni_srcrt_len;+/* length of src rt option */+u_short+cni_recrtp;+/* ptr to head of recrt option */+char+cni_recrt_len;+/* length of recrt option */+char+cni_priorp;+/* ptr to priority option */+u_short+cni_qos_formatp;+/* ptr to format of qos option */+char+cni_qos_len;+/* length of qos option */+char+cni_er_reason;+/* reason from ER pdu option */};.TE.)bThis index allows CLNP quickly to discover the existence and value of an option. For example, if a security option is present, the \fIcni_securep\fRfield of the option index is non-zero and the value of\fIcni_securep\fR is an offset to the beginning of the security option. The function \fIclnp_opt_sanity()\fR parses the options and computes the index.While parsing, it also verifies that the options are valid and correctly structured.If an error occurs while parsing an option, \fIclnp_opt_sanity()\fR returns an error code. The following sections describe how options are processedduring the send, forward and receive operations..sh 3 "Sending Options".ppOptions to be sent with a datagram are passed to \fIclnp_output()\fR astwo arguments. An option index is passed along with an \fImbuf\fRcontaining the options. The options in the \fImbuf\fR must be formattedexactly as specified by CLNP. If the security, quality of service, orpriority options are specified, \fIclnp_output()\fR will not transmit thedatagram and \fIEINVAL\fR is returned.The system call \fIsetsockopt()\fR is used to set the CLNP options to be sent on a datagram. See \fIclnp(4)\fR for more information about setting CLNP options..ppIf a source route is specified, the normal CLNP routing function \fIclnp_route()\fR is not used, and \fIclnp_srcroute()\fR is invoked..ppWhen the DECBIT config option is specified, \fIclnp_output\fR willautomatically add the globally unique quality of service option to the packet.The sequencing preferred and low delay bits in this option are set..sh 3 "Forwarding Options".ppDuring packet forwarding, the padding, security,and priority options are ignored. If record route is selected, thefunction \fIclnp_dooptions()\fR logs the current networkinterface address in the record route list..ppIf a source route is specified, the normal CLNP routing function \fIclnp_route()\fR is not used, and \fIclnp_srcroute()\fR is invoked..sh 4 "The Congestion Experienced Bit".ppIf a packet is forwarded containing the globally unique quality ofservice option, and the interface through which the packet will be transmitted has a queue length greater than \fIcongest_threshold\fR,then the congestion experienced bit is set in the quality of service option..ppThe threshold value stored in \fIcongest_threshold\fR may be changedwith the \fIclnlutil\fR utility..sh 3 "Receiving Options".ppOn receipt, all CLNP options are ignored except the security and globally unique quality of service option.If the security option is found, the packet is discarded.If the globally unique quality of service option is present, and thecongestion experienced bit is set, then the transport congestioncontrol function \fItpclnp_ctlinput(PRC_QUENCH2, addr)\fR is called.The following table summarizes the CLNP option processing..(b.TS

⌨️ 快捷键说明

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