Throttle RTMP connections

At work, we use Charles to throttle our connections while working locally to help test real life connections. Charles is an amazing program but the one thing that it doesn’t do is throttle RTMP connections (Flash streaming). If you ever need to throttle RTMP connections while debugging your Flash/Flex applications, here is nice code snippet that one of my coworkers found to do so. I’ve also converted here to a quick BASH script for OS X terminal.

It takes 2 parameters: First is the speed in kbytes; Second is the port to throttle (I usually just use 80)

throttle()
{
	sudo ipfw pipe 1 config bw $1KByte/s &&
	sudo ipfw add 1 pipe 1 src-port $2
}

rmthrottle()
{
	sudo ipfw delete 1
}

Example terminal output:

...$ throttle 150 80
Password:
00001 pipe 1 ip from any 80 to any
...$ rmthrottle
This entry was posted in development and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

4 Comments

  1. gavin
    Posted March 7, 2011 at 5:27 pm | Permalink

    This sounds exactly what I need, however I have no idea what to do with a BASH script or how to execute functions from one…..don’t suppose you could post up instructions

    cheers

    Gavin

  2. Posted March 7, 2011 at 10:32 pm | Permalink

    Hi Gavin,
    I’m on OSX so if you are on a different operating system, you might have to use a separate example. In your home directory, there is a file named .bash_profile. I’ve edited mine to point to a different file where I keep my bash snippets. Anyway, you use bash via terminal and would call it by saying throttle 150 80 (or whatever speed and port you want to use).

    Cheers,
    Kris

    Put this into your .bash_profile:
    # Alias definitions
    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi

    Then, I create a .bash_aliases file (in my same home directory) and add the following:
    throttle()
    {
    sudo ipfw pipe 1 config bw $1KByte/s &&
    sudo ipfw add 1 pipe 1 src-port $2
    }

    rmthrottle()
    {
    sudo ipfw delete 1
    }

  3. Posted May 5, 2011 at 1:17 am | Permalink

    I have tried this using both port 80 and port 1935 (which is what I’ve been told RTMP uses). And I get no noticeable difference in my bandwidth speed. Any insight?

  4. Posted May 5, 2011 at 10:39 pm | Permalink

    RTMP could use two ports, the default is 1935, the other *I think* is 443. You might want to try both. It should work as it limits all bandwidth from you computer, similarly to proxy programs like Charles. You might also want to try limiting it on all 3 at the same time if you aren’t seeing any results.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>