networking - Chromecast Stream from Android Phone to Laptop via Ad Hoc Network

07
2014-07
  • CalG

    I want to mirror the screen of my Android phone (HTC Sensation) on my laptop wirelessly.

    Google Chromecast looks like a good solution to this - how would I set up an ad-hoc network so that I can view my phone's display on my laptop without a router? (I don't need internet connection)

    Additionally, my laptop only has an HDMI out and not an HDMI in - can I plug the chromecast to my laptop via USB.

    I found this tutorial but I'm not sure if its what I want:

    http://pack3tlife.com/2013/11/18/ad-hoc-network-with-chromecast-and-windows-8/

    I don't own a chromecast so can't test this.

    Can anybody help me with this?

  • Answers
  • MKzero

    Using an Ad-Hoc network won't work if your Android phone does not support Ad-Hoc mode (properly), which in my experience are most Android phones.

    You could fall back to a WiFi hotspot, e.g. provisioned by your phone, but this hogs a lot of power.

    Another problem you get with a Chromecast but no HDMI-in will be the HDCP, so even if you managed to get a signal through some adapters, this probably won't work.

    If you have a rooted phone, there are some alternatives like AndroidScreencast or a VNC server, but this needs the root access.

    The Android version for TeamViewer could work on your phone, but that probably needs an internet connection to initialize the connection between your computer and your phone.


  • Related Question

    networking - Ubuntu & Android: Sharing a tethered internet connection of a phone & laptop with another laptop through ethernet
  • Questioner

    First off let me explain the problem I'm trying to solve:

    I have an Android 2.2 phone that tethers its internet connection through USB to a laptop running Ubuntu 10.10. What I want to do is share this internet connection through an ethernet cable with another laptop running Ubuntu 10.10.

    I've been looking on the internet but I haven't seen any cases of anyone else trying to to do this. If anyone knows of any resource for this, please let me know.

    I believe that I have gotten it the devices to communicate one way via ping but I cannot go the other way. This is where I believe the internet connection is getting blocked.

    How I did this was through Firestarter, which uses NAT, installed on the machine the phone is plugged into and using the following guide: http://www.fs-security.com/docs/connection-sharing.

    Basically, the interface that is giving the connection is usb0 and I'm trying to share the connection through eth0. I basically just followed the above guide, replacing the instances of eth0 with usb0 an etho1 with etho0. The only thing it says to do that I'm not able to do is to enable DHCP on the Android phone, because frankly I don't know how.

    I manually configured the network instead of using Firestarter's DHCP option because I'm hoping to ultimately not have to use firestarter to do this.

    To be more specific, this is what I did: through the GUI Network Connections:

    On the first laptop (the one connected to the phone)

    IP address: 192.168.0.1 Netmask: 255.255.255.0 Default gateway (IP):

    On the second latop, again through Network Connections: IP address: 192.168.0.2 Netmask: 255.255.255.0 Default Gateway: 192.168.0.1 *My /etc/resolv.conf file actually doesn't show anything so that may be a problem.

    *Also I just tried to share my wireless connection through ethernet through Firestarter and that didn't work either. I can ping between the two laptops but I can't get internet.

    At the bottom, it tells how to test the setup. I can ping 192.168.0.2 like it says in the guide and get a response. However, I can't go to google.com on the laptop thats supposed to be getting the shared connection. In addition, on the 2nd laptop, I can ping to the phone. However, I can't ping from the phone to the 2nd laptop. This is why I believe I can't get to the internet.

    I'm at a loss for what I need to do to get this connection to work. Do I need to brige the connection between usb0 and eth0 on the latop the phone is connected to? or is that what Firestarter is already doing?

    **Side note: I cannot ping from the 2nd laptop to the phone if I turn Firestarter off on the machine it is running on.

    If anyone has an idea of how to get this working, it would be greatly appreciated.


  • Related Answers
  • Beni Cherniavsky-Paskin

    These steps are kind of low-level and can be automated using, for example, NetworkManager on current GNOME 3 distributions. However, here are lower level instructions that should work across a wide variety of Linux distributions and versions:

    Step 1: Get the usb0 internet connection working fine on the box that's directly connected by USB to the phone.

    Step 2: Plug in the ethernet cable between the computers.

    Step 3: Use the following commands on the host computer, as root, or wrap in sudo:
    ifconfig eth0 192.168.0.1 (or choose your own IP address within the designated LAN IP segments
    ifconfig eth0 netmask 255.255.255.0

    Step 4: Use the following commands on the client computer (the one that doesn't currently have an internet connection), as root, or wrap in sudo:
    ifconfig eth0 192.168.0.2 (the first three numbers should be the same; the last one should be different, from the private IP of the host computer)

    ifconfig eth0 netmask 255.255.255.0

    Step 5: Adapted from here, execute these steps as root or wrap in sudo on the host computer:
    echo 1 > /proc/sys/net/ipv4/ip_forward

    /sbin/iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE

    /sbin/iptables -A FORWARD -i usb0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT

    /sbin/iptables -A FORWARD -i eth0 -o usb0 -j ACCEPT

    If you have existing settings (such as whatever Firestarter did) you may have to flush your iptables on the host, before executing step 5:

    iptables -F

    You can check your existing settings using

    iptables -L

    Finally: You probably already have a private IP address on a LAN from your usb0 connection. You may not use the same IP subnet for your NAT on the eth0 NAT. So if your usb0 has 192.168.0.10, you can't use anything from 192.168.0.x on eth0 on either computer.

  • Justin

    Do you have to tether through USB? If Wifi is available on at least one computer then you should be able to create a Wifi AP in Android, connect with wifi on one of the laptops and then connect the two laptops together with ethernet. Configure the "middle" laptop to route traffic through its wifi connection. For example, in windows you would configure the adapter for internet connection sharing.

    None of what I mention above will work with USB tethering which is why you would be better off to switch to WiFi.