使用有限的网络访问权限测试iPhone应用 [英] Testing iPhone app with limited network access
问题描述
使用iPhone模拟器时,有没有办法模拟有限或无3G / Wifi / EDGE连接?
Is there any way of simulating limited or no 3G / Wifi / EDGE connectivity when using the iPhone simulator?
推荐答案
是你希望测试速度的变化吗?或访问每种技术?
Is it the variations in speed you wish to test? Or access to each technology?
如果它的速度那么你可以使用以下ipfw技巧,图标工厂的Craig Hockenberry,使用ipfw来限制连接到给定域名。在这个例子中,它是twitter,它限制了进出主机的所有连接的速度。
If it's speed then you could use the following ipfw trick, courtesty of Craig Hockenberry of the Icon Factory, to use ipfw to limit connectivity to a given domain. In this example, it's twitter and it limits the speed of all connections to and from the host.
这是一个bash脚本,如果你正在做iPhone开发你会在Mac上,所以只需创建它并在终端中运行。
It's a bash script, if you're doing iPhone dev you'll be on a mac so just create it and run in the terminal.
#!/bin/bash
# configuration
host="twitter.com"
# usage
if [ "$*" == "" ]; then
echo "usage: $0 [off|fast|medium|slow]"
exit
fi
# remove any previous firewall rules
sudo ipfw list 10 > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo ipfw delete 10 > /dev/null 2>&1
fi
sudo ipfw list 11 > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo ipfw delete 11 > /dev/null 2>&1
fi
# process the command line option
if [ "$1" == "off" ]; then
# add rules to deny any connections to configured host
sudo ipfw add 10 deny tcp from $host to me
sudo ipfw add 11 deny tcp from me to $host
else
# create a pipe with limited bandwidth
bandwidth="100Kbit"
if [ "$1" == "fast" ]; then
bandwidth="300Kbit"
elif [ "$1" == "slow" ]; then
bandwidth="10Kbit"
fi
sudo ipfw pipe 1 config bw $bandwidth
# add rules to use bandwidth limited pipe
sudo ipfw add 10 pipe 1 tcp from $host to me
sudo ipfw add 11 pipe 1 tcp from me to $host
fi
这篇关于使用有限的网络访问权限测试iPhone应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!