Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    CoDel - How to use

    Scheduled Pinned Locked Moved Traffic Shaping
    206 Posts 30 Posters 112.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Harvy66
      last edited by

      @tuffcalc:

      @Harvy66:

      @tuffcalc:

      I take back what I said about Codel.  When I saturate the upload fully for a long period of time my pings still shoot through the roof (200+ ms).

      Try settings your WAN rate to about 95% of your stable upload rate and see what happens.

      That fixed it…

      Well, 200ms is a lot less than what I thought it would have been, so just enabling CoDel without setting bandwidth is probably doing something, just not as effective as in conjunction with settings your bandwidth.

      Just wondering, what was your ping during saturation when you have your bandwidth set?

      1 Reply Last reply Reply Quote 0
      • T
        tuffcalc
        last edited by

        @Harvy66:

        @tuffcalc:

        @Harvy66:

        @tuffcalc:

        I take back what I said about Codel.  When I saturate the upload fully for a long period of time my pings still shoot through the roof (200+ ms).

        Try settings your WAN rate to about 95% of your stable upload rate and see what happens.

        That fixed it…

        Well, 200ms is a lot less than what I thought it would have been, so just enabling CoDel without setting bandwidth is probably doing something, just not as effective as in conjunction with settings your bandwidth.

        Just wondering, what was your ping during saturation when you have your bandwidth set?

        I've been all over the place and probably gave some false information (because I am new to this and didn't really understand what I was doing).  Anyway, let me try and clear up my findings:

        1. No traffic shaping, all bandwidth available - ping 10ms
        2. No traffic shaping, download saturated - ping 60ms
        3. No traffic shaping, upload saturated - ping 500+ms

        4. CODEL active with no bandwidth limit set - all pings same as scenarios 1,2 & 3.

        5. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, all bandwidth available - ping 10ms
        6. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, download saturated - ping 60ms
        7. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, upload saturated - ping 50 to 80ms

        So it does work, although during a saturated upload I notice my VoIP phone going a bit "robotic", but much improved over no traffic shaping (VoIP calls would be largely unusable).  Did not have that issue with PRIQ when prioritizing VoIP as first in line.  That being said, CODEL is much easier to setup and it looks like it doesn't completely starve other queues like PRIQ.  I'm sticking with CODEL.

        Interested to see if FQ_CODEL will make my pings even lower.  Will test it as soon as it is available in pfsense.

        1 Reply Last reply Reply Quote 0
        • H
          Harvy66
          last edited by

          @tuffcalc

          Thanks for the info. I've done my fair share of "false" information with good intentions. It happens.

          Yes, the whole PRIQ replacement is kind of interesting. The eventual fq_codel will actually do similar things of PRIQ, but better for general usage. Except in the case where you need certain traffic to always get priority, fq_codel will do what most people want, keep latency low without the hassle of floating rules.

          1 Reply Last reply Reply Quote 0
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            @tuffcalc:

            @Harvy66:

            @tuffcalc:

            @Harvy66:

            @tuffcalc:

            I take back what I said about Codel.  When I saturate the upload fully for a long period of time my pings still shoot through the roof (200+ ms).

            Try settings your WAN rate to about 95% of your stable upload rate and see what happens.

            That fixed it…

            Well, 200ms is a lot less than what I thought it would have been, so just enabling CoDel without setting bandwidth is probably doing something, just not as effective as in conjunction with settings your bandwidth.

            Just wondering, what was your ping during saturation when you have your bandwidth set?

            I've been all over the place and probably gave some false information (because I am new to this and didn't really understand what I was doing).  Anyway, let me try and clear up my findings:

            1. No traffic shaping, all bandwidth available - ping 10ms
            2. No traffic shaping, download saturated - ping 60ms
            3. No traffic shaping, upload saturated - ping 500+ms

            4. CODEL active with no bandwidth limit set - all pings same as scenarios 1,2 & 3.

            5. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, all bandwidth available - ping 10ms
            6. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, download saturated - ping 60ms
            7. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, upload saturated - ping 50 to 80ms

            So it does work, although during a saturated upload I notice my VoIP phone going a bit "robotic", but much improved over no traffic shaping (VoIP calls would be largely unusable).  Did not have that issue with PRIQ when prioritizing VoIP as first in line.  That being said, CODEL is much easier to setup and it looks like it doesn't completely starve other queues like PRIQ.  I'm sticking with CODEL.

            Interested to see if FQ_CODEL will make my pings even lower.  Will test it as soon as it is available in pfsense.

            Out of curiosity, which exact places do you have CoDel active for? As the shaper discipline for the interface, or using HFSC with "Codel Active Queue" on specific queues? And if the latter, which queues?

            The more good/working examples we can get the better, I can put them up on the wiki for future reference.

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            1 Reply Last reply Reply Quote 0
            • T
              tuffcalc
              last edited by

              @jimp:

              @tuffcalc:

              @Harvy66:

              @tuffcalc:

              @Harvy66:

              @tuffcalc:

              I take back what I said about Codel.  When I saturate the upload fully for a long period of time my pings still shoot through the roof (200+ ms).

              Try settings your WAN rate to about 95% of your stable upload rate and see what happens.

              That fixed it…

              Well, 200ms is a lot less than what I thought it would have been, so just enabling CoDel without setting bandwidth is probably doing something, just not as effective as in conjunction with settings your bandwidth.

              Just wondering, what was your ping during saturation when you have your bandwidth set?

              I've been all over the place and probably gave some false information (because I am new to this and didn't really understand what I was doing).  Anyway, let me try and clear up my findings:

              1. No traffic shaping, all bandwidth available - ping 10ms
              2. No traffic shaping, download saturated - ping 60ms
              3. No traffic shaping, upload saturated - ping 500+ms

              4. CODEL active with no bandwidth limit set - all pings same as scenarios 1,2 & 3.

              5. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, all bandwidth available - ping 10ms
              6. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, download saturated - ping 60ms
              7. CODEL active (WAN side only) with bandwidth limit set at 98% of uplink speed, upload saturated - ping 50 to 80ms

              So it does work, although during a saturated upload I notice my VoIP phone going a bit "robotic", but much improved over no traffic shaping (VoIP calls would be largely unusable).  Did not have that issue with PRIQ when prioritizing VoIP as first in line.  That being said, CODEL is much easier to setup and it looks like it doesn't completely starve other queues like PRIQ.  I'm sticking with CODEL.

              Interested to see if FQ_CODEL will make my pings even lower.  Will test it as soon as it is available in pfsense.

              Out of curiosity, which exact places do you have CoDel active for? As the shaper discipline for the interface, or using HFSC with "Codel Active Queue" on specific queues? And if the latter, which queues?

              The more good/working examples we can get the better, I can put them up on the wiki for future reference.

              It's active only for the shaper discipline for the WAN interface.

              1 Reply Last reply Reply Quote 0
              • DerelictD
                Derelict LAYER 8 Netgate
                last edited by

                It's active only for the shaper discipline for the WAN interface.

                OK.  Now I'm confused.  If codel has no knobs, what is actually doing the shaping based on the bandwidth value?

                Chattanooga, Tennessee, USA
                A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                Do Not Chat For Help! NO_WAN_EGRESS(TM)

                1 Reply Last reply Reply Quote 0
                • H
                  Harvy66
                  last edited by

                  @Derelict:

                  It's active only for the shaper discipline for the WAN interface.

                  OK.  Now I'm confused.  If codel has no knobs, what is actually doing the shaping based on the bandwidth value?

                  CoDel is not a traffic shaper, it does not do any rate limiting, that is the job of your rate limiter. All CoDel does is figure out which packets to dequeue next or which to drop.

                  See my quotes from the makers of CoDel

                  https://forum.pfsense.org/index.php?topic=88162.msg488220#msg488220

                  1 Reply Last reply Reply Quote 0
                  • DerelictD
                    Derelict LAYER 8 Netgate
                    last edited by

                    Exactly.

                    The question I have is why tuffcalc sees a difference in behavior when he sets a bandwidth value of 98% of his upload when his scheduler type is CODELQ?

                    As I understand codel, it should make no difference, so what is actually doing the shaping?  Is it built into altq itself absent any HFSC, PRIQ, etc?

                    Chattanooga, Tennessee, USA
                    A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                    DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                    Do Not Chat For Help! NO_WAN_EGRESS(TM)

                    1 Reply Last reply Reply Quote 0
                    • H
                      Harvy66
                      last edited by

                      Ahh.. I assumed PFSense/FreeBSD had a built in interface rate limiter that functioned separately of queue management like AQMs or shapers. To me, they are all orthogonal problems. The interface can be rate limited and not care about how queues are implemented, how many queues there are, or which queue to dequeue next. Traffic shapers can decide which queues to pull from and how fast to dequeue those queues, and AQMs can decide which packet to dequeue from a given queue.

                      Interface->InterfaceRateLimiter->TrafficShaper(HFSC)->AQM(CoDel)

                      Like a pipeline, with none needing to know anything about the others. Not to say this is how it is implemented, but it could be implemented this way as none of them have any overlap or unique dependencies on each other. Some traffic shapers may need to know how fast to expect the interface to dequeue from them.  HFSC might not actually be really "limiting", it might be just "scheduling", while the interface limiter might be doing the limiting. I'm not sure about implementation details, just looking at it from an abstract point of view and what could be done. I am ignoring the fact that HFSC does have the notion of an upper bound, but ignoring that, pretty much all other features of HFSC could be done without any rate limiting, only scheduling.

                      1 Reply Last reply Reply Quote 0
                      • DerelictD
                        Derelict LAYER 8 Netgate
                        last edited by

                        This is what I get when I set scheduler type to CODELQ and a 900Mbit bandwidth:

                        altq on  em0_vlan1003 codelq bandwidth 900Mb queue

                        Absent any other requirements, that is probably sufficient to eliminate any buffer bloat one might have at their ISP (assuming bandwidth set to about 90-95% of reasonably-expected uplink.)

                        Chattanooga, Tennessee, USA
                        A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                        DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                        Do Not Chat For Help! NO_WAN_EGRESS(TM)

                        1 Reply Last reply Reply Quote 0
                        • C
                          cmutwiwa
                          last edited by

                          This is a very informative thread, I've been searching this forum on general traffic shaping methods / tricks and I've bookmarked a couple of threads including this one…I'm yet do to my setup, I like doing the research first so I can have an idea of what I'm dealing with.

                          I have a question tho'; from what I read CoDel is only meant to work (well) with high speed connections? 2.5mbit and above?. I'm currently using a very low ADSL connection 1770kbps down 550kbps up (thats what I get from speedtest although the ISP sells as 2mbit down 1mbit up), would CoDel work for me with this speeds?

                          I'm looking to upgrade to 10mbit down 2.5mbit up soon but I kindly need to know if CoDel would work for me with my current speeds.

                          Another question is; I'm I right to assume that CoDel can work side to side with PRIQ and the Limiter (I intend to use the Limiter to implement share bandwidth evenly on LAN as foxale08 has illustrated here; https://forum.pfsense.org/index.php?topic=63531.0 )

                          Regards.

                          1 Reply Last reply Reply Quote 0
                          • N
                            Nullity
                            last edited by

                            @cmutwiwa:

                            This is a very informative thread, I've been searching this forum on general traffic shaping methods / tricks and I've bookmarked a couple of threads including this one…I'm yet do to my setup, I like doing the research first so I can have an idea of what I'm dealing with.

                            I have a question tho'; from what I read CoDel is only meant to work (well) with high speed connections? 2.5mbit and above?. I'm currently using a very low ADSL connection 1770kbps down 550kbps up (thats what I get from speedtest although the ISP sells as 2mbit down 1mbit up), would CoDel work for me with this speeds?

                            I'm looking to upgrade to 10mbit down 2.5mbit up soon but I kindly need to know if CoDel would work for me with my current speeds.

                            Another question is; I'm I right to assume that CoDel can work side to side with PRIQ and the Limiter (I intend to use the Limiter to implement share bandwidth evenly on LAN as foxale08 has illustrated here; https://forum.pfsense.org/index.php?topic=63531.0 )

                            Regards.

                            Answer to your first question: No (but it couldn't hurt to try… :))

                            If you check CoDel's official site you would see that there are a few known problems. Here is a quote from  http://www.bufferbloat.net/projects/codel/wiki/Wiki/

                            At very low bandwidths (e.g. .5Mbps) on ADSL, we're having to play with the target; Kathie did not have to in her simulations. This is due to inevitable buffering
                            in htb or in the device driver. We have a version under development that does bandwidth limiting without buffering an extra packet, called cake. It's looking good so far.

                            The quote mentions "playing with the target", but this level of configuration is only available in the Linux kernel's Codel/fq_codel implementation (please correct me if I am wrong). I am assuming they mean target delay. Please refer to to the following link for more information:  http://man7.org/linux/man-pages/man8/tc-fq_codel.8.html

                            Regarding your second question; I have only used Codel as a stand-alone queue, never as part of another queueing algorithm like PRIQ or HFSC. I have no reason to think it wouldn't work though. Make sure to reset the firewall states and test your queueing configuration to confirm that it is working as expected.

                            Please correct any obvious misinformation in my posts.
                            -Not a professional; an arrogant ignoramous.

                            1 Reply Last reply Reply Quote 0
                            • H
                              Harvy66
                              last edited by

                              I use Codel in conjunction with HFSC on my 100/100 connection. In theory they're independent of each other. HFSC schedules which queue to dequeue and Codel deiced which packets to dequeue or to drop.

                              In practice, I never see any packets dropped according to the queue statistics, but I also never see any measurable latency spikes.

                              I'm not sure of a goad way to load test because my connection is "too" stable.

                              It is possible that if HFSC isn't "smooth" enough at interleaving the queues, a queue could wait longer than what Codel wants and could create packetloss when there isn't any real congestion, but HFSC seems like freaking magic. I assume bad things could happen with an older machine with 10ms timers or 10/40Gb interfaces that have fq_Codel tuned for 0.5ms, which is recommended for those rates. but right now, we do not have fq_codel nor do we have a way to tweak the target delay via the interface.

                              1 Reply Last reply Reply Quote 0
                              • S
                                sideout
                                last edited by

                                Here is how I have mine setup for testing right now:

                                QueueStatus1.JPG
                                TrafficShaper1.JPG
                                TrafficShaper2.JPG
                                TrafficShaper3.JPG
                                TrafficShaper4.JPG
                                TrafficShaper5.JPG
                                TrafficShaper6.JPG
                                QueueStatus1.JPG_thumb
                                TrafficShaper1.JPG_thumb
                                TrafficShaper2.JPG_thumb
                                TrafficShaper3.JPG_thumb
                                TrafficShaper4.JPG_thumb
                                TrafficShaper5.JPG_thumb
                                TrafficShaper6.JPG_thumb

                                1 Reply Last reply Reply Quote 0
                                • C
                                  cmutwiwa
                                  last edited by

                                  @Nullity:

                                  Answer to your first question: No (but it couldn't hurt to try… :))

                                  If you check CoDel's official site you would see that there are a few known problems. Here is a quote from  http://www.bufferbloat.net/projects/codel/wiki/Wiki/

                                  Thanks, will give it a try.

                                  I'm hoping it will work smoothly with PRIQ and the Limiter, I would achieve alot!

                                  1 Reply Last reply Reply Quote 0
                                  • L
                                    ltctech
                                    last edited by

                                    I have been experimenting with my home router which is running DD-WRT and enabled HTB along with FQ_CoDel. My latency under load has improved from 300ms+ to just under 20ms+ as measured by pinging Google DNS. The connection is a Frontier FIOS 25M/25M. My throughput as verified by speedtest.net are good whether I am using a Seattle based server or one in Atlanta. I thought that was great and looked into turning CoDel on in pfSense at work.

                                    We have two pfSense firewalls both in the Seattle area. One is sitting on a 50M/50M Comcast EDI circuit. The other one is sitting on a collocated burstable gigabit circuit that we shape to 100M/100M. Both use a simple PRIQ shaper with 500 packet queue limit, that's roughly a max queue delay of 114ms for 50M and 57ms for 100M. I have found that the 500 packet queue limit offers the best throughput performance with least drops and this has worked for us for a few years now.

                                    For most general traffic I really don't care that it queues up and gets delayed, but less intensive flows should not get delayed. Which I see CoDel doing on my home router. pfSsense was able to do the same on our work connections. However, something weird is going on when I do speed tests from the pfSense boxes. When I choose a local Seattle server with an RTT of under 10ms, both connections approach close to their shaped throughput. When I choose a server in Atlanta or Miami where the RTT is around 80ms, suddenly the upload throughput is 25-50% less, and it takes longer to get up to that throughput. Download throughput is never affected even though CoDel is enabled on the LAN queues and I verified that it is working via ping. If I turn off CoDel AQM, the upload for high RTT servers goes back to roughly shaped throughput.

                                    Can anyone explain why the longer RTT is causing issues for upload on pfSsense using CoDel. Why does DD-WRT not experience this issue?

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Harvy66
                                      last edited by

                                      Are you using the same computer when doing speed tests? I've seen large variations in speed tests between computers. Too bad PFSense doesn't have fq_codel yet, but there are some other awesome changes in the pipeline.

                                      1 Reply Last reply Reply Quote 0
                                      • L
                                        ltctech
                                        last edited by

                                        @Harvy66:

                                        Are you using the same computer when doing speed tests? I've seen large variations in speed tests between computers. Too bad PFSense doesn't have fq_codel yet, but there are some other awesome changes in the pipeline.

                                        I am using Windows Server 2008 R2 when testing the work connections. I am using Mac OS X 10.10.2 and Windows 8.1 Pro at home. I'll see if Windows 8.1 Pro makes a difference on the office connection tomorrow, though I doubt it.

                                        I am thinking that the queue length has something to do with it on pfSense.

                                        1 Reply Last reply Reply Quote 0
                                        • N
                                          Nullity
                                          last edited by

                                          @ltctech:

                                          @Harvy66:

                                          Are you using the same computer when doing speed tests? I've seen large variations in speed tests between computers. Too bad PFSense doesn't have fq_codel yet, but there are some other awesome changes in the pipeline.

                                          I am using Windows Server 2008 R2 when testing the work connections. I am using Mac OS X 10.10.2 and Windows 8.1 Pro at home. I'll see if Windows 8.1 Pro makes a difference on the office connection tomorrow, though I doubt it.

                                          I am thinking that the queue length has something to do with it on pfSense.

                                          If stream fairness is your goal then FAIRQ might be a better choice. There is a picture somewhere showing graphs of fq_codel, codel, SFQ (stochastic fair queue) and the latency changes when each algorithm is dealing with dozens of simultaneous streams. SFQ was a close 2nd behind fq_codel for best latency. FAIRQ is very similar to SFQ (both give each stream a hash then iterate through them round-robin style).

                                          Codel is lacking "fair queueing" (there are many papers on this topic) so it does poorly with multiple streams, unlike fq_codel.

                                          Please correct any obvious misinformation in my posts.
                                          -Not a professional; an arrogant ignoramous.

                                          1 Reply Last reply Reply Quote 0
                                          • H
                                            Harvy66
                                            last edited by

                                            @ltctech:

                                            @Harvy66:

                                            Are you using the same computer when doing speed tests? I've seen large variations in speed tests between computers. Too bad PFSense doesn't have fq_codel yet, but there are some other awesome changes in the pipeline.

                                            I am using Windows Server 2008 R2 when testing the work connections. I am using Mac OS X 10.10.2 and Windows 8.1 Pro at home. I'll see if Windows 8.1 Pro makes a difference on the office connection tomorrow, though I doubt it.

                                            I am thinking that the queue length has something to do with it on pfSense.

                                            There are a few things at play.

                                            1. If your queue is too small, it will drop packets too aggressively. You can look at queue statistics to find out if there are any drops happening.
                                            2. If your queue is too large and are not using something like Codel with time based dropping, your bandwidth can also be made less efficient
                                            3. My personal most common reason for poor upload speeds is the TCP stack of the OS I'm using

                                            Windows 202 R2 is the Win7 kernel, and Win7 defaults to some latency sensitive TCP congestion control. This may not be the same for the server edition, but when I switched to using CTCP, my upload bandwidth to higher latency targets increased substantially. Win8 of all versions default to CTCP.

                                            And never assume two similar machines would get the same performance. I had two identical computers, exactly the same hardware, both with a fresh install of Win7, and one was over 50% faster than the other for speed tests. The only thing I could think of that would make the difference was heuristics. Win7 tries to be "smart" about certain things, which can cause it to get confused. A quick trip into the registry to change some settings and a reboot and both systems were getting identical speedtests.

                                            So even freshly installed identical hardware can get large variations. ALWAYS test using the same machine. Or use an OS that doesn't suck. Freaking Windows.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.