UDP 端口映射

本文介绍如何在Android模拟器中设置UDP包转发。通过telnet连接到模拟器实例,并使用ADB命令设置端口转发,使得从主机发送到指定端口的UDP包能够被转发到模拟器的相应端口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

On the host machine that runs the emulator, open a terminal window and
telnet to the emulator instance:

telnet localhost 5554


This will take you into the ADB emulator console. Then setup packet
forwarding on the port you are sending udp packets to:


redir add udp:<host machine port>:<emulator listen port>


example:


redir add udp:4444:4444


This will then have the emulator "listen" on your local machine's port
4444 for UDP packets, and forward those to the emulator's ETH adapter
on port 4444 (which can be changed to whatever you need).


I havent tried this with other external machines, but I struggled
getting this to work for a while. Also, any "servers" listening for
packets inside android (2.0) should be listening on IP 10.0.2.15
(android emulator's own Eth adapter), and in this case on port 4444.


In the case where you want to broadcast UDP packets out of the android
emulator to the local machine, you wont need to setup a port redir,
but you will want to send them out to IP address 10.0.2.2 as this is
the "loopback" address on the host computer, and you can send them
directly to the port it is listening on.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值