Setting up a Mac as a wifi hotspot to run mobile broadband test cases

244 views Asked by At

I need to set up an environment where I can simulate mobile network internet connectivity for iOS and Android devices that don't have mobile data plans. I was thinking that I could use my MAC to set up a wifi hotspot and then use ipfw to throttle the data connection to simulate a 3G network. I've managed to get my MAC set up through the "Internet Sharing" settings in my System Preferences. I can connect both my iPhone 4 and my Samsung Galaxy S3 perfectly fine and pull up web pages with no problem. However, I'm having trouble with the ipfw side of it. I put together a linux script to set up the pipes, but when I run the program my smartphones can no longer connect to the internet. I think it might be an routing issue, but I'm not sure what I'm missing. Here's what my script looks like:

ipfw del pipe 1
ipfw del pipe 2
ipfw -q -f flush
ipfw -q -f pipe flush

BW_DOWN=780
[ ! -z $1 ] && BW_DOWN=$1

BW_UP=330
[ ! -z $2 ] && BW_UP=$2

if [ "$1" == "off" ]; then
        echo "disabling BW limit"
        exit
else
        echo "Download = ${BW_DOWN}KByte/s, Upload = ${BW_UP}KByte/s"
        ipfw add pipe 1 ip from any to any
        ipfw add pipe 2 ip from any to any
        ipfw pipe 1 config bw ${BW_DOWN}KByte/s
        ipfw pipe 2 config bw ${BW_UP}KByte/s
fi

Any ideas?

0

There are 0 answers