dummynet = local taffic > 100ms - help!

From: Bjorn Eikeland (bjorn_at_eikeland.info)
Date: 02/10/04

  • Next message: Hendrik Scholz: "remote traceroute and ping for jails"
    Date: Tue, 10 Feb 2004 01:43:44 +0100
    To: "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>
    
    

    I think I've made a mess of my attempt to shape my traffic, the traffic
    on my lan ip is getting delayed. (About 18ms idle and 100ms full load,
    load is the same as for internet traffic)

    Traffic to localhost and other lan hosts are not delayed, the delay only
    occurs from my box to my ip.

    I started with http://www.topfx.com/prioritizingackfreebsd.shtml as a
    template for my traffic shaping and have extended it a bit:

    DUMMYNET and HZ=10000 is in the kernel.

    Any suggestions what can be causing this? (I've only got the one nic,
    and use a adsl router for internett)

    thanks,
    Bjorn

    #
    # Traffic shaping rules
    #

    #
    # Define some variables (or "constants" really)
    #
    echo Setting up variables
    IPFW=ipfw
    WAN_UL_CAP=18KByte/s
    WAN_DL_CAP=180KByte/s
    LAN_NET=10.0.0.0
    LAN_CIDR=24
    echo WAN UPLOAD ${WAN_UL_CAP}
    echo WAN DOWNLOAD ${WAN_DL_CAP}
    echo LAN_NET ${LAN_NET}
    echo LAN_MASK ${LAN_MASK}
    echo LAN_CIDR ${LAN_CIDR}

    #
    # FLUSH old rules (< `echo y` answers yes)
    #
    echo Flushing rules
    ${IPFW} flush < `echo y`

    #
    # TRAFFIC SHAPING:
    #
    # Make packets exiting dummynet not continue down the chain
    # If this is not enabled, then packets leaving an early
    # queue might enter a later queue if the conditions for
    # the later queue are met, which would be completely
    # devastating to all the prioritizing we're doing
    #
    ${IPFW} enable one_pass

    #
    # Lopback and local net traffic
    #
    ${IPFW} pipe 1 config bw lo0
    ${IPFW} pipe 2 config bw fxp0
    ${IPFW} add pipe 1 all from localhost to localhost
    ${IPFW} add pipe 2 all from ${LAN_NET}/${LAN_CIDR} to
    ${LAN_NET}/${LAN_CIDR}

    #
    # WAN Pipes
    #
    echo Setting up WAN Pipes
    WAN_UL=3
    WAN_DL=4
    ${IPFW} pipe $WAN_UL config bw $WAN_UL_CAP
    ${IPFW} pipe $WAN_DL config bw $WAN_DL_CAP

    #
    # WAN_UL queues
    #
    echo Setting up WAN_UL Queues
    WAN_UL_HI=1
    WAN_UL_M1=2
    WAN_UL_M2=3
    WAN_UL_LO=4
      # Define a high-priority queue
       ${IPFW} queue $WAN_UL_HI config pipe $WAN_UL weight 50

      # Define a medium-high-priority queues
       ${IPFW} queue $WAN_UL_M1 config pipe $WAN_UL weight 10
       ${IPFW} queue $WAN_UL_M2 config pipe $WAN_UL weight 5

      # Define a low-priority queue
       ${IPFW} queue $WAN_UL_LO config pipe $WAN_UL weight 1

    #
    #Assign WAN_UL traffic to queue's
    #
    echo Assigning WAN_UL traffic
      # HIGH PRIORITY
       # Assign outgoing empty/small ACK + ICMP packets to the high-priority
    queue:
        ${IPFW} add queue $WAN_UL_HI tcp from me to not ${LAN_NET}/${LAN_CIDR}
    tcpflags ack iplen 0-80
        ${IPFW} add queue $WAN_UL_HI icmp from me to not ${LAN_NET}/${LAN_CIDR}

      # MEDIUM PRIORITY
       # Outgoing DNS and SSH traffic to the medium-high-priority queue:
        ${IPFW} add queue $WAN_UL_M1 ip from me to not ${LAN_NET}/${LAN_CIDR}
    domain
        ${IPFW} add queue $WAN_UL_M1 tcp from me to not ${LAN_NET}/${LAN_CIDR}
    ssh,telnet,login
       # Outgoing http requests - possibly file uploads & mails
        ${IPFW} add queue $WAN_UL_M2 tcp from me to not ${LAN_NET}/${LAN_CIDR}
    http,https,pop3,imap,smtp
       # Outgoing ftp-control
        ${IPFW} add queue $WAN_UL_M2 ip from me to not ${LAN_NET}/${LAN_CIDR}
    ftp
       # Add gaming traffic later

      # LOW PRIORITY
       # Assign all other outgoing traffic to the low-priority queue:
        ${IPFW} add queue $WAN_UL_LO all from me to not ${LAN_NET}/${LAN_CIDR}

    #
    # WAN_DL queues
    #
    echo Setting up WAN_DL Queues
    WAN_DL_HI=5
    WAN_DL_M1=6
    WAN_DL_M2=7
    WAN_DL_LO=8
      # Define a high-priority queue
       ${IPFW} queue $WAN_DL_HI config pipe $WAN_DL weight 50

      # Define a medium-high-priority queues
       ${IPFW} queue $WAN_DL_M1 config pipe $WAN_DL weight 10
       ${IPFW} queue $WAN_DL_M2 config pipe $WAN_DL weight 5

      # Define a low-priority queue
       ${IPFW} queue $WAN_DL_LO config pipe $WAN_DL weight 1

    #
    #Assign WAN_DL traffic to queue's
    #
    echo Assigning WAN_DL traffic
      # HIGH PRIORITY
       # Assign outgoing empty/small ACK + ICMP packets to the high-priority
    queue:
        ${IPFW} add queue $WAN_DL_HI tcp from not ${LAN_NET}/${LAN_CIDR} to me
    tcpflags ack iplen 0-80
        ${IPFW} add queue $WAN_DL_HI icmp from not ${LAN_NET}/${LAN_CIDR} to me

      # MEDIUM PRIORITY
       # Outgoing DNS and SSH traffic to the medium-high-priority queue:
        ${IPFW} add queue $WAN_DL_M1 ip from not ${LAN_NET}/${LAN_CIDR} to me
    domain
        ${IPFW} add queue $WAN_DL_M1 tcp from not ${LAN_NET}/${LAN_CIDR} to me
    ssh,telnet,login
       # Outgoing http requests - possibly file uploads & mails
        ${IPFW} add queue $WAN_DL_M2 tcp from not ${LAN_NET}/${LAN_CIDR} to me
    http,https,pop3,imap,smtp
       # Outgoing ftp-control
        ${IPFW} add queue $WAN_DL_M2 ip from not ${LAN_NET}/${LAN_CIDR} to me
    ftp
       # Add gaming traffic later

      # LOW PRIORITY
       # Assign all other outgoing traffic to the low-priority queue:
        ${IPFW} add queue $WAN_DL_LO all from not ${LAN_NET}/${LAN_CIDR} to me
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"


  • Next message: Hendrik Scholz: "remote traceroute and ping for jails"

    Relevant Pages

    • challenge with dummynet+ipfw
      ... I want to organize my bandwith in this mode ... an rule to multiple pipe or queue with different weights. ... ipfw pipe 1 config ...
      (freebsd-questions)
    • pipes and queues with ipfw
      ... I am trying to get a queue working on ipfw2 with FreeBSD 4.9 stable. ... connections going out into the internet. ... queue 1 config pipe 1 mask dst-ip 0x000000ff ... If I ipfw set disable 10, then the connections get out just fine. ...
      (comp.unix.bsd.freebsd.misc)
    • Re: Traffic Shaping not working correctly after ipfw coverted touse pfil_hooks API
      ... > outgoing packets with traffic shaping limiting the upstream at 480Kbps ... I have just looked through the ipfw to pfil_hooks changes ... as they relate to dummynet. ...
      (freebsd-current)
    • Re: How to shape VoIP traffic on FreeBSD 4.8 router?
      ... I'd also like to give TCP ACK packets a priority boost. ... > traffic without assimilating bandwidth. ... Define 1 pipe for the entire upstream bandwidth. ... add queue 2 ip from any to any not ssh,telnet,ntp out via oif ...
      (comp.unix.bsd.freebsd.misc)
    • gateway/firewall script
      ... add 1700 queue 1 log tcp from any to any 20,21 keep-state out ... queue 1 config weight 5 pipe 1 mask all ...
      (freebsd-net)