为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

Linux流量控制HOWTO

2011-01-12 37页 pdf 1MB 16阅读

用户头像

is_296064

暂无简介

举报
Linux流量控制HOWTO Traffic Control HOWTO Version 1.0.2 Martin A. Brown linux−ip.net "Oct 2006" Revision History Revision 1.0.2 2006−10−28 Revised by: MAB Add references to HFSC, alter author email addresses Revision 1.0.1 2003−11−17 Revised by: MAB Added link to Leonardo Ballia...
Linux流量控制HOWTO
Traffic Control HOWTO Version 1.0.2 Martin A. Brown linux−ip.net "Oct 2006" Revision History Revision 1.0.2 2006−10−28 Revised by: MAB Add references to HFSC, alter author email addresses Revision 1.0.1 2003−11−17 Revised by: MAB Added link to Leonardo Balliache's documentation Revision 1.0 2003−09−24 Revised by: MAB reviewed and approved by TLDP Revision 0.7 2003−09−14 Revised by: MAB incremental revisions, proofreading, ready for TLDP Revision 0.6 2003−09−09 Revised by: MAB minor editing, corrections from Stef Coene Revision 0.5 2003−09−01 Revised by: MAB HTB section mostly complete, more diagrams, LARTC pre−release Revision 0.4 2003−08−30 Revised by: MAB added diagram Revision 0.3 2003−08−29 Revised by: MAB substantial completion of classless, software, rules, elements and components sections Revision 0.2 2003−08−23 Revised by: MAB major work on overview, elements, components and software sections Revision 0.1 2003−08−15 Revised by: MAB initial revision (outline complete) Traffic control encompasses the sets of mechanisms and operations by which packets are queued for transmission/reception on a network interface. The operations include enqueuing, policing, classifying, scheduling, shaping and dropping. This HOWTO provides an introduction and overview of the capabilities and implementation of traffic control under Linux. © 2006, Martin A. Brown Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no invariant sections, with no Front−Cover Texts, with no Back−Cover Text. A copy of the license is located at http://www.gnu.org/licenses/fdl.html. Table of Contents 1. Introduction to Linux Traffic Control..........................................................................................................1 1.1. Target audience and assumptions about the reader...........................................................................1 1.2. Conventions......................................................................................................................................1 1.3. Recommended approach...................................................................................................................1 1.4. Missing content, corrections and feedback.......................................................................................2 2. Overview of Concepts.....................................................................................................................................3 2.1. What is it?.........................................................................................................................................3 2.2. Why use it?.......................................................................................................................................3 2.3. Advantages........................................................................................................................................4 2.4. Disdvantages.....................................................................................................................................4 2.5. Queues...............................................................................................................................................5 2.6. Flows.................................................................................................................................................5 2.7. Tokens and buckets...........................................................................................................................5 2.8. Packets and frames............................................................................................................................6 3. Traditional Elements of Traffic Control.......................................................................................................8 3.1. Shaping.............................................................................................................................................8 3.2. Scheduling........................................................................................................................................8 3.3. Classifying........................................................................................................................................8 3.4. Policing.............................................................................................................................................9 3.5. Dropping...........................................................................................................................................9 3.6. Marking.............................................................................................................................................9 4. Components of Linux Traffic Control........................................................................................................10 4.1. qdisc................................................................................................................................................10 4.2. class.................................................................................................................................................11 4.3. filter.................................................................................................................................................11 4.4. classifier..........................................................................................................................................11 4.5. policer.............................................................................................................................................11 4.6. drop.................................................................................................................................................12 4.7. handle..............................................................................................................................................12 5. Software and Tools.......................................................................................................................................13 5.1. Kernel requirements........................................................................................................................13 5.2. iproute2 tools (tc)............................................................................................................................13 5.3. tcng, Traffic Control Next Generation............................................................................................16 5.4. IMQ, Intermediate Queuing device................................................................................................16 6. Classless Queuing Disciplines (qdiscs)........................................................................................................17 6.1. FIFO, First−In First−Out (pfifo and bfifo).....................................................................................17 6.2. pfifo_fast, the default Linux qdisc..................................................................................................18 6.3. SFQ, Stochastic Fair Queuing........................................................................................................19 6.4. ESFQ, Extended Stochastic Fair Queuing......................................................................................20 6.5. GRED, Generic Random Early Drop..............................................................................................20 6.6. TBF, Token Bucket Filter...............................................................................................................20 Traffic Control HOWTO i Table of Contents 7. Classful Queuing Disciplines (qdiscs)..........................................................................................................22 7.1. HTB, Hierarchical Token Bucket...................................................................................................22 7.1.1. Software requirements...........................................................................................................22 7.1.2. Shaping..................................................................................................................................23 7.1.3. Borrowing..............................................................................................................................23 7.1.4. HTB class parameters............................................................................................................24 7.1.5. Rules......................................................................................................................................25 7.2. HFSC, Hierarchical Fair Service Curve..........................................................................................25 7.3. PRIO, priority scheduler.................................................................................................................26 7.4. CBQ, Class Based Queuing............................................................................................................26 8. Rules, Guidelines and Approaches..............................................................................................................27 8.1. General Rules of Linux Traffic Control..........................................................................................27 8.2. Handling a link with a known bandwidth.......................................................................................27 8.3. Handling a link with a variable (or unknown) bandwidth..............................................................27 8.4. Sharing/splitting bandwidth based on flows...................................................................................27 8.5. Sharing/splitting bandwidth based on IP........................................................................................28 9. Scripts for use with QoS/Traffic Control....................................................................................................29 9.1. wondershaper..................................................................................................................................29 9.2. ADSL Bandwidth HOWTO script (myshaper)...............................................................................29 9.3. htb.init.............................................................................................................................................29 9.4. tcng.init...........................................................................................................................................29 9.5. cbq.init............................................................................................................................................29 10. Diagram.......................................................................................................................................................30 10.1. General diagram............................................................................................................................30 11. Annotated Traffic Control Links..............................................................................................................32 Notes......................................................................................................................................................33 Traffic Control HOWTO ii 1. Introduction to Linux Traffic Control Linux offers a very rich set of tools for managing and manipulating the transmission of packets. The larger Linux community is very familiar with the tools available under Linux for packet mangling and firewalling (netfilter, and before that, ipchains) as well as hundreds of network services which can run on the operating system. Few inside the community and fewer outside the Linux community are aware of the tremendous power of the traffic control subsystem which has grown and matured under kernels 2.2 and 2.4. This HOWTO purports to introduce the concepts of traffic control, the traditional elements (in general), the components of the Linux traffic control implementation and provide some guidelines . This HOWTO represents the collection, amalgamation and synthesis of the LARTC HOWTO, documentation from individual projects and importantly the LARTC mailing list over a period of study. The impatient soul, who simply wishes to experiment right now, is recommended to the Traffic Control using tcng and HTB HOWTO and LARTC HOWTO for immediate satisfaction. 1.1. Target audience and assumptions about the reader The target audience for this HOWTO is the network administrator or savvy home user who desires an introduction to the field of traffic control and an overview of the tools available under Linux for implementing traffic control. I assume that the reader is comfortable with UNIX concepts and the command line and has a basic knowledge of IP networking. Users who wish to implement traffic control may require the ability to patch, compile and install a kernel or software package [1]. For users with newer kernels (2.4.20+, see also Section 5.1), however, the ability to install and use software may be all that is required. Broadly speaking, this HOWTO was written with a sophisticated user in mind, perhaps one who has already had experience with traffic control under Linux. I assume that the reader may have no prior traffic control experience. 1.2. Conventions This text was written in DocBook (version 4.2) with vim. All formatting has been applied by xsltproc based on DocBook XSL and LDP XSL stylesheets. Typeface formatting and display conventions are similar to most printed and electronically distributed technical documentation. 1.3. Recommended approach I strongly recommend to the eager reader making a first foray into the discipline of traffic control, to become only casually familiar with the tc command line utility, before concentrating on tcng. The tcng software package defines an entire language for describing traffic control structures. At first, this language may seem daunting, but mastery of these basics will quickly provide the user with a much wider ability to employ (and deploy) traffic control configurations than the direct use of tc would afford. Where possible, I'll try to prefer describing the behaviour of the Linux traffic control system in an abstract manner, although in many cases I'll need to supply the syntax of one or the other common systems for defining these structures. I may not supply examples in both the tcng language and the tc command line, so 1. Introduction to Linux Traffic Control 1 the wise user will have some familiarity with both. 1.4. Missing content, corrections and feedback There is content yet missing from this HOWTO. In particular, the following items will be added at some point to this documentation. A description and diagram of GRED, WRR, PRIO and CBQ.• A section of examples.• A section detailing the classifiers.• A section discussing the techniques for measuring traffic.• A section covering meters.• More details on tcng.• I welcome suggestions, corrections and feedback at . All errors and omissions are strictly my fault. Although I have made every effort to verify the factual correctness of the content presented herein, I cannot accept any responsibility for actions taken under the influence of this documentation. Traffic Control HOWTO 1. Introduction to Linux Traffic Control 2 2. Overview of Concepts This section will introduce traffic control and examine reasons for it, identify a few advantages and disadvantages and introduce key concepts used in traffic control. 2.1. What is it? Traffic control is the name given to the sets of queuing systems and mechanisms by which packets are received and transmitted on a router. This includes deciding which (and whether) packets to accept at what rate on the input of an interface and determining which packets to transmit in what order at what rate on the output of an interface. In the overwhelming majority of situations, traffic control consists of a single queue which collects entering packets and dequeues them as quickly as the hardware (or underlying device) can accept them. This sort of queue is a FIFO. The default qdisc under Linux is the pfifo_fast, which is slightly more complex than the FIFO. There are examples of queues in all sorts of software. The queue is a way of organizing the pending tasks or data (see also Section 2.5). Because network links typically carry data in a serialized fashion, a queue is required to manage the outbound data packets. In the case of a desktop machine and an efficient webserver sharing the same uplink to the Internet, the following contention for bandwidth may occur. The web server may be able to fill up the output queue on the router faster than the data can be transmitted across the link, at which point the router starts to drop packets (its buffer is full!). Now, the desktop machine (with an interactive application user) may be faced with packet loss and high latency. Note that high latency sometimes leads to screaming users! By separating the internal queues used to service these two different classes of application, there can be better sharing of the network resource between the two applications. Traffic control is the set of tools which allows the user to have granular control over these queues and the queuing mechanisms of a networked device. The power to rearrange traffic flows and packets with these tools is tremendous and can be complicated, but is no substitute for adequate bandwidth. The term Quality of Service (QoS) is often used as a synonym for traffic control. 2.2. Why use it? Packet−switched networks differ from circuit based networks in one very important regard. A packet−switched network itself is stateless. A circuit−based network (such as a telephone network) must hold state within the network. IP networks are stateless and packet−switched networks by design; in fact, this statelessness is one of the fundamental strengths of IP. The weakness of this statelessness is the lack of differentiation between types of flows. In simplest terms, traffic control allows an administrator to queue packets differently based on attributes of the packet. It can even be used to simulate the behaviour of a circuit−based network. This introduces statefulness into the stateless network. 2. Overview of Concepts 3 There are many practical reasons to consider traffic control, and many scenarios in which using traffic control makes sense. Below are some examples of common problems which can be solved or at least ameliorated with these tools. The list below is not an exhaustive list of the sorts of solutions available to users of traffic control, but introduces the types of problems that can be solved by using traffic control to maximize the usability of a network connection. Common traffic control solutions Limit total bandwidth to a known rate; TBF, HTB with child class(es).• Limit the bandwidth of a particular user, service or client; HTB classes and classifying with a filter. traffic. • Maximize TCP throughput on an asymmetric link; prioritize transmission of ACK packets, wondershaper. • Reserve bandwidth for a particular application or user; HTB with children classes and classifying.• Prefer latency sensitive traffic; PRIO inside an HTB class.• Managed oversubscribed bandwidth; HTB with borrowing.• Allow equitable distribution of unreserved bandwidth; HTB with borrowing.• Ensure that a particular type of traffic is dropped; policer attached to a filter with a drop action. • Remem
/
本文档为【Linux流量控制HOWTO】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索