Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Use the TC flow control test under Linux     - MySQL and MariaDB traditional master-slave cluster configuration (Database)

- Getting Started with Linux system to learn: How to compress JPEG images on the command line (Linux)

- Linux configuration Samba server (Server)

- Use Bosh deploy CloudFoundry problems encountered on OpenStack (Server)

- The execution order of Oracle WHERE condition is not from right to left (Database)

- Laravel 4 Expansion Pack (Server)

- Configuring the PXE server in Ubuntu 14.04 (Server)

- Dockerfile use to build a mirror-based CentOS 7 (Linux)

- Nginx high concurrency optimization ideas (Server)

- Create several practical points of high security PHP site (Linux)

- Linux ./configure --prefix command (Linux)

- Oracle Execute to Parse perform analytical Ratio Analysis (Database)

- How to make GRub instead of the default Ubuntu software center (Linux)

- xCAT error Unable to dispatch hierarchical sub-command to NORESOLUTION: 3001 (Linux)

- How to understand Python yield keyword (Programming)

- OpenResty load balancing MySQL (Database)

- After Ubuntu Password Forgot your way back (Linux)

- Ubuntu 14.04 Enable root and disable the guest (Linux)

- Oracle how to maintain the consistency of read? (Database)

- Rely on IP chain established Linux firewall (Linux)

 
         
  Use the TC flow control test under Linux
     
  Add Date : 2017-08-31      
         
         
         
  Gateway do need to flow control, IP and network for the control, there are ways to achieve with iptables, may also have internal and external network for the server, the rules understand, very easy.

The following is a shell script, non-iptables way:

#! / Bin / bash

# Set the following values to somewhat less than your actual download

# And uplink speed. In kilobits. Also set the device that is to be shaped.

#INGOING traffic (gateway)

IN = eth0

#what ip do you want to limit

INET = "192.168.138."

IPS = "100"

IPE = "254"

#Total DOWNLINK

DOWN = "100mbit"

#ensure rate speed of DOWNLINK

DOWNLOADrate = "100kbit"

#Allow max rate speed of DOWNLINK

DOWNLOADceil = "250kbit"

Start () {

    #clean eth1 eth0 existing down- and uplink qdiscs, hide errors

    / Sbin / tc qdisc del dev $ IN root 2> / dev / null

    # Install root htb of downlink and uplink

    # Main class

    / Sbin / tc qdisc add dev $ IN root handle 1: htb

    / Sbin / tc class add dev $ IN parent 1: classid 1: 1 htb rate $ DOWN ceil $ DOWN

    #simgle ip limit

    / Sbin / tc class add dev $ IN parent 1: 1 classid 1: 2 htb rate $ DOWNLOADrate ceil $ DOWNLOADrate

    / Sbin / tc qdisc add dev $ IN parent 1: 2 sfq perturb 2

    / Sbin / tc filter add dev $ IN protocol ip parent 1: prio 49 u32 match ip dst 192.168.138.10 flowid 1: 2

    / Sbin / tc filter add dev $ IN protocol ip parent 1: prio 49 u32 match ip dst 192.168.2.0/32 flowid 1: 2

    # Net1 limit

    For ((i = $ IPS; i < = $ IPE; i = i + 1))

    Do

        ##### Control DOWNLINK

        / Sbin / tc class add dev $ IN parent 1: 1 classid 1: 1 $ i htb rate $ DOWNLOADrate ceil $ DOWNLOADceil

        / Sbin / tc qdisc add dev $ IN parent 1: 1 $ i sfq perturb 1 $ i

        / Sbin / tc filter add dev $ IN protocol ip parent 1: prio 50 u32 match ip dst $ INET $ i flowid 1: 1 $ i

    Done

    # Net2 limit

    #for ((i = $ IPS; i < = $ IPE; i = i + 1))

    #do

    # ##### Control DOWNLINK

    # / Sbin / tc class add dev $ IN parent 1: 1 classid 1: 2 $ i htb rate $ DOWNLOADrate ceil $ DOWNLOADceil

    # / Sbin / tc qdisc add dev $ IN parent 1: 2 $ i sfq perturb 2 $ i

    # / Sbin / tc filter add dev $ IN protocol ip parent 1: prio 50 u32 match ip dst $ INET $ i flowid 1: 2 $ i

    #done

    #Other traffic

    / Sbin / tc filter add dev $ IN protocol ip parent 1: prio 2 u32 match ip dst 0.0.0.0/32 flowid 1: 1

}}

Stop () {

    Echo -n "(Delete all qdisc ...)"

    (/ Sbin / tc qdisc del dev $ IN root 2> / dev / null && echo "ok.Delete sucessfully!") || echo "error."

}}

#show status

Status () {

    Echo "1.show qdisc $ IN: ----------------------------------------- ----- "

    / Sbin / tc -s qdisc show dev $ IN

    Echo "2.show class $ IN: ----------------------------------------- ----- "

    N1 = `/ sbin / tc class show dev $ IN | wc -l`

    If [$ N1 == 0]; then

        Echo "NULL, OFF Limiting"

    Else

        / Sbin / tc -s class show dev $ IN

        Echo "It work"

    Fi

}}

#show help

Usage () {

    Echo "(usage):` basename $ 0` [start | stop | restart | status] "

    Echo "help:"

    Echo "start - TC Flow Control start"

    Echo "stop - TC Flow Control stop"

    Echo "restart - TC Flow Control restart"

    Echo "status - TC Show all TC Qdisc and class"

}}

Case "$ 1" in

    Start)

        (Start && echo "Flow Control! TC started!") || echo "error."

        Exit 0

        ;

 

    Stop)

        (Stop && echo "Flow Control TC stopped!") || echo "error."

        Exit 0

        ;

    Restart)

        Stop

        Start

        Echo "Flow Control restart"

        ;

    Status)

        Status

        ;

 

    *) Usage

        Exit 1

        ;

Esac

test:
Enable flow control TC:

# ./tc_last.sh start

There is a restricted IP: 192.168.138.131

# Ifconfig eth0

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: DA: 56: 1C

          Inet addr: 192.168.138.131 Bcast: 192.168.138.255 Mask: 255.255.255.0

          UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

          RX packets: 1811422 errors: 0 dropped: 0 overruns: 0 frame: 0

          TX packets: 1083449 errors: 0 dropped: 0 overruns: 0 carrier: 0

          Collisions: 0 txqueuelen: 1000

          RX bytes: 943250761 (899.5 MiB) TX bytes: 87045802 (83.0 MiB)

 

# Wget http://ftp13.enet.com.cn:88/pub/multimedia/video/uvs9_trial_e_rtm.rar

--2013-08-08 17: 44: 01-- http://ftp13.enet.com.cn:88/pub/multimedia/video/uvs9_trial_e_rtm.rar

Resolving ftp13.enet.com.cn ... 122.224.6.16

Connecting to ftp13.enet.com.cn | 122.224.6.16 |: 88 ... connected.

HTTP request sent, awaiting response ... 200 OK

Length: 180175741 (172M) [application / octet-stream]

Saving to: 'uvs9_trial_e_rtm.rar.17

 

Unlimited IP: 192.168.138.99

 

# Ifconfig eth0

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: 88: EC: 85

          Inet addr: 192.168.138.99 Bcast: 192.168.138.255 Mask: 255.255.255.0

          UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

          RX packets: 88578 errors: 0 dropped: 0 overruns: 0 frame: 0

          TX packets: 43771 errors: 0 dropped: 0 overruns: 0 carrier: 0

          Collisions: 0 txqueuelen: 1000

          RX bytes: 19401052 (18.5 MiB) TX bytes: 6876868 (6.5 MiB)

 

# Wget http://ftp13.enet.com.cn:88/pub/multimedia/video/uvs9_trial_e_rtm.rar

--2013-07-16 22: 57: 10-http://ftp13.enet.com.cn:88/pub/multimedia/video/uvs9_trial_e_rtm.rar

Resolving ftp13.enet.com.cn ... 122.224.6.16

Connecting to ftp13.enet.com.cn | 122.224.6.16 |: 88 ... connected.

HTTP request sent, awaiting response ... 200 OK

Length: 180175741 (172M) [application / octet-stream]

Saving to: `uvs9_trial_e_rtm.rar.2


The effect is still very significant, and set the flow range is biased, to be studied!
     
         
         
         
  More:      
 
- Introduction and MongoDB CRUD (Database)
- Install Oracle database error process of [INS-35172] (Database)
- Neo4j map data processing tab (Database)
- linux system optimization and security configuration (Linux)
- Java data structures - the single linked list LinkedList linear table (Programming)
- BCP importing and exporting large amounts of data Practice (Database)
- VPN built on CentOS (Server)
- 7 extremely dangerous Linux commands (Linux)
- ASP.NET 5 (vNext) Linux deployment (Server)
- Android Studio quick overview of Gradle (Programming)
- Preliminary understanding of SELinux security management (Linux)
- Linux kernel likely and unlikely to resolve macro definitions (Linux)
- Unix average load average load calculation method (Server)
- Python extension module Ganglia 3.1.x (Linux)
- Spark source code compiler package (Linux)
- Single Instance ASM under CRS-4124, CRS-4000 error handling (Database)
- Drawing from the Android source code analysis View (Programming)
- DRBD-based installation and configuration of CentOS 6.5 (Server)
- Singleton (Linux)
- GNU Linux use diff to generate a patch with the patch (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.