By virtual device do you mean an extra virtual network device?  Assuming 
you're using the ARM emulator, this can be done by passing extra options to 
qemu.

I'm going to also assume (1) you are running Linux (Mac I believe is okay, 
too) as I do not know how to do this on Windows; and (2) you have tunctl 
(on Ubuntu, this can be installed with sudo apt-get install uml-utilities).

You can create a TUN/TAP device with:
sudo tunctl -u <username> -t tap0

You can install the TUN/TAP device on the emulator with:
emulator -qemu -net nic -net user -net nic -net 
tap,ifname=tap0,script=no,downscript=no

I have found the script=no and downscript=no options to be useful for 
avoiding errors when the emulator shuts down.

You can confirm the TUN/TAP device is running with:
adb shell netcfg

You should see something like this:
lo       UP                                   127.0.0.1/8   0x00000049 
00:00:00:00:00:00
eth0     UP                                   10.0.2.15/24  0x00001043 
52:54:00:12:34:56
eth1     DOWN                                   0.0.0.0/0   0x00001002 
52:54:00:12:34:57
tunl0    DOWN                                   0.0.0.0/0   0x00000080 
00:00:00:00:00:00
gre0     DOWN                                   0.0.0.0/0   0x00000080 
00:00:00:00:00:00


Notice the eth1 device; this corresponds to tap0 that you just created.  To 
confirm, on the emulator run:
ifconfig eth1 up 10.11.12.2 netmask 255.255.255.0

On the host, open up a new terminal window and run:
sudo ifconfig tap0 up 10.11.12.1 netmask 255.255.255.0
sudo tcpdump -n icmp -v -i tap0

Finally, on the emulator run:
route add default gw 10.11.12.1 dev eth1
ping -c 5 10.11.12.1

You should get output similar to:
09:58:13.187475 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP 
(1), length 84)
    10.11.12.2 > 10.11.12.1: ICMP echo request, id 26881, seq 1, length 64
09:58:13.187489 IP (tos 0x0, ttl 64, id 35773, offset 0, flags [none], 
proto ICMP (1), length 84)
    10.11.12.1 > 10.11.12.2: ICMP echo reply, id 26881, seq 1, length 64
09:58:14.190013 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP 
(1), length 84)
    10.11.12.2 > 10.11.12.1: ICMP echo request, id 26881, seq 2, length 64
09:58:14.190028 IP (tos 0x0, ttl 64, id 35774, offset 0, flags [none], 
proto ICMP (1), length 84)
    10.11.12.1 > 10.11.12.2: ICMP echo reply, id 26881, seq 2, length 64
09:58:15.192087 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP 
(1), length 84)
    10.11.12.2 > 10.11.12.1: ICMP echo request, id 26881, seq 3, length 64
09:58:15.192103 IP (tos 0x0, ttl 64, id 35775, offset 0, flags [none], 
proto ICMP (1), length 84)
    10.11.12.1 > 10.11.12.2: ICMP echo reply, id 26881, seq 3, length 64
09:58:16.194919 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP 
(1), length 84)
    10.11.12.2 > 10.11.12.1: ICMP echo request, id 26881, seq 4, length 64
09:58:16.194935 IP (tos 0x0, ttl 64, id 35776, offset 0, flags [none], 
proto ICMP (1), length 84)
    10.11.12.1 > 10.11.12.2: ICMP echo reply, id 26881, seq 4, length 64
09:58:17.196961 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP 
(1), length 84)
    10.11.12.2 > 10.11.12.1: ICMP echo request, id 26881, seq 5, length 64
09:58:17.196977 IP (tos 0x0, ttl 64, id 35777, offset 0, flags [none], 
proto ICMP (1), length 84)
    10.11.12.1 > 10.11.12.2: ICMP echo reply, id 26881, seq 5, length 64

HTH,
Eric

On Wednesday, 29 August 2012 20:12:48 UTC-4, MW choi wrote:
>
> Hi All.
>
> I want to add virtual device on emulator. so I have built SDK on platform 
> source.
> And I am searching about goldfish in googling
> But I don't know how to approach it.
>
> Please help me anyone, anything.
>
> Thanks,
> MW
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to