How can I host a wifi from either a lan connection or wifi - raspberry-pi

I'm trying to host a wifi from either a lan connection (if available) or either sharing a network.
I did use the tutorial : https://kaiuwe.hüber.de/raspberry-pi-wifi-repeater-ohne-adapter/
But this just acts as a repeater ...
My expectation is a possibility to share wifi over wlan or when a lan connection is active share the wifi from lan.

I'm not sure you know enough about WiFi or TCP/IP networking to ask your question sensibly. What do you mean by "share WiFi?" There are two common scenarios:
Your Pi works as a WiFi bridge to an Ethernet LAN. In this case, the WiFi and the LAN are the "same" network, just different media. For instance, if your LAN uses the IPv4 address 192.168.42.0-255, your WiFi users will also share this network.
Your Pi works as a WiFi router, with an Ethernet LAN as the "uplink." In this case, your WiFi network has its own range of addresses, probably managed by your Pi, and the Pi works as a router between the WLAN and the LAN. This is like what most home WiFi access points do. (You will probably need to have the Pi do Network Address Translation as well. For some reason, Linux people insist on calling this 'masquerading.')
If you can clarify which of those you want to do, I could provide some pointers going forward. You many want to do some reading on the basics of TCP/IP networking first. If you don't know how a bridge and a router differ, you won't be able to ask useful questions.

Related

Is it possible to get the SSID & MAC Address of Currently connected WiFi Network in an App

I am looking for a way to get both the MAC Adress and the SSID of the currently connected WiFi Network in my project. I have used Tony Million's Reachability to decide when the user is on a WiFi network or not and was testing Kenial's NICInfo only to find out that it only provides the iPhone's WiFi MAC Address. Although both projects helped greatly in there own way, they do not get the job done.
I am wondering if there is a public API (for certain Apple App Approval) or some back door to achieve this.
This involves a few different things:
Getting SSID - This is independent of the MAC address issue. For this, check this SO answer: iPhone get SSID without private library. I don't know what the etiquette is regarding re-posting code from other answers so I'll just link.
Getting MAC address - since the majority of networking operates at Layer 3 (which is called, who would have guessed, the Network Layer - http://en.wikipedia.org/wiki/OSI_model) and the MAC address is at Layer 2 (the Data Link layer) you'll first need to get the IP address of the gateway of the WiFi interface. Just a side note - the question should be phrased as 'How do I get the SSID of the currently connected WiFi network and the MAC address of the WiFi router/gateway'. Anywho, to get the gateway address, see this SO answer: How to get the WIFI gateway address on the iPhone?
Once you have that, you need to convert it to a MAC address using ARP (Address Resolution Protocol, which is the protocol that all networks use to convert IP addresses to MAC addresses). Network interfaces don't communicate via IP, they communicate via MAC, so this actually happens everywhere, all the time. It's actually pretty easy to access the ARP table on a PC/Mac. For iOS, I found this SO answer to convert an IP address to a MAC address: Getting ARP table on iPhone/iPad

Is it possible to create a local WiFi network with Cocoa while staying connected to an existing Internet-enabled WiFi connection?

I do a lot of development that requires creating local networks on my machine in order to connect to them on my mobile devices. When you create a network, you disconnect from your existing network and lose internet access. Is there any way to programmatically create a network while still maintaining a second WiFi connection that can access the Internet?
As an aside, it's possible on the iPhone - when an iPhone connects to a locally created network, it somehow detects that it's not a real Internet connection and maintains its 3G connection while also being able to interact locally with the host computer.
No. It's not a matter of the software; most wifi chipsets only support being associated with a single network at a time.
The iPhone is able to avoid this because its 3G connection is a separate network interface from the wifi connection. If you have another method of connecting your laptop to the Internet, though, such as wired Ethernet, you can use that to get the same effect.

Finding IP Address for IPhone

I am working on IPhone. I want to know how to find a ip address of a iphone through USB/3G not on wifi.
I am aware of seeing IP if it is connected through WiFI.(Going through settings and looking under Wifi)
But i need IP through USB / 3G. what i did means i used personal hotspot and i connected my iphone to PC through usb. I got an IP.
But when i added one more Iphone with same hot spot enabled and connected through USB i am getting like unidentified network.
By using whatismyip.com site i am getting an ip . but i cant do anything with it. I am unable to reach my iphone with the provided ip of that site.
So can anyone kindly provide information on how to look for IP of multiple Iphones connected to same PC.
The purpose is to communicate to muliple iphones with their IP's.
Thanks a million in advance.
Unfortunately the responses are not completely correct. In a 3G/4G network every device gets an IP address, but THAT's NOT the IP address that you see when going to sites like www.whatismyip.com. That's the address that the Telco presents to the external world, not the device IP address.
Telcos such AT&t, Verizon, Telefonica and similar assign a "private" IP address that is only valid in their network. This is similar to the internal IP address that you have in your phone when connect to the house wireless, but if you check in www.whatismyip.com you get the external IP address of your wireless router (You can check that those are different addresses). What Telcos do is known as NAT or PAT. The reason is that the current version of IP has a very limited number of available IP addresses, and all those million of devices cannot get public IP addresses (like the one you see in whatismyip.com). Actually several devices share that external IP address.
Unlike Android devices where you can get the IP that the telco assigned to the device, iOS does not present that information to the user (unless you jailbreak the device or have an App).
Although the address that whatismyip presents is not your real IP, it is the one that the external world recognizes so it suffices for most purposes.
What you see on whatismyip.com is the IP address you get from your mobile provider, on which it depends what kind op IP you get. Very often 3G networks are NATted, meaning that you get an IP address from the range 10.0.0.0/8 which cannot be reached from outside.
Using www.whatismyip.com should definitely give you the correct address?
What address did you get when it came back?
How did you verify if this was your iPhone's address? I assume you don't have a firewall installed on your iPhone? Hmm, other thing is your provider is doing some kind of filtering, NAT-ing, or other tomfoolery. If you don't mind me asking, what exactly are you trying to achieve here? Are you trying to run some kind of server-style app on your iPhone? Or do you just want to get a connection between the iPhone and a server - might be easier to initiate the connection from the iPhone side.
You should check if it's at your provider's IP block range - an online whois check should tell you that (www.whois.net).
How did you test whether this was your iPhone's address?
Other option is just to have your iPhone hit a server that you control (using 3G), and check the server logs.
Or just make things easier, and use an app to tell you - e.g. iStat:
http://bjango.com/iphone/istat/
which will give you your cell (3G) IP address as well.
Cheers,
Victor
There are two types of IP addresses:
Private IP address (your device IP that you get it from your home Wi-Fi router or from your Teleco provider router to speak to those two routers).
Public IP address (your home Wi-Fi router and/or from your Teleco provider router which they will use it to allow you to speak to another person on the Internet).
**NOTE: Without Public IP address, you cannot speak to people who are on the Internet.
Now both (your home Wi-Fi router or your Teleco Provider router)they have something called DHCP, or Dynamic Host Configuration Protocol. This protocol is used to allocate private IP address to anyone connected to local network (either home Wi-Fi or Teleco provider).
That means both (home Wi-Fi router and Teleco provider router) have one single IP address called Public IP address to allow you to speak to outside world, but first they need to give private IP address to able you to speak with them (your home Wi-Fi router and your Teleco provider router).
If your iOS connected to your home Wi-Fi, then you will have a Private IP address:
1- Go to settings.
2- Click on Wi-Fi.
3- List of Wi-Fi networks will be appeared.
4- Click on your Wi-Fi network name (known as SSID).
5- Click on the blue circle of the exclamation mark on the right side of your Wi-Fi name.
You will see your Private IP Address there very clearly.
Now if your iOS device is not connected to any Wi-Fi network, but it connected to your Teleco provider, then you cannot see your private IP address.
I am sure there is a way to see your Private IP address that you got it from your Teleco Provider DHCP. You have to search from internet or ruin your device by jailbreak it.
For the Public IP Address (no matter if you are connected to your home Wi-Fi or your Teleco Provider), go to your internet browser (e.x. google chrome) and type: "What is my ip address". The result will be between your hand in fractions of seconds!
Now Back to your question:
If you connected two iPhones to your PC and both have hotspot enabled, that means your PC USB ports will handle two IP Private addresses because your iPhones will act as your home Wi-Fi router.
if you have windows OS in your laptop, then go to windows CMD terminal and type:
ipconfig
the CMD prompt terminal will give you number of IP address, there are your two Private IP addresses from your iPhones.
Now if unidentified network message still there, open RUN in your windows OS and type [ ncpa.cpl ], it will take you to network connection setting section, right click on one of your iPhones networks and disable it, keeping the other enabled.
I hope it is crystal clear now.
When the phone is the hotspot for the Telecom cellular provider it actually being used as a Router therefor if you connect laptop to that hotspot you can open network setting on the laptop to view its tcp/ip settings and see the ip of the laptop and the ip of the Router which is the IP of your Phone.
The Ip is a private one, you can ping to it or do what ever you want.
Example of connecting Iphone to Mac Xcode wirelessly:
share personal hotSpot from your phone.
connect your laptop to your phone private network using wifi, search for the ssid you set in your phone and set a correct password.
in Mac go to System prefences->Network->wifi connected->Advanced->Tcp/Ip
copy Router Ip - this is your Iphone private Ip.
In order to connect Xcode to Iphone wirelessly you first need to connect the phone with usb, open window->device and simulators, select your phone and set checkbox "connect via network"
Now if the phone is disconnected from the Mac and the private network is shared as explained, you know the phone Ip, then you can select the phone in Xcode (it remember phones that were connected), open window->device and simulators, select your phone , click on it to get menu of options, select "connect with ip", provide the ip you saw as "Router" previously.
Thats all, hope it'll help somebody.

How to send OSC commands from iPad/iPhone over the Internet (not Wi-Fi)

I am building an Arduino based servo driver that I want to control with OSC commands from my iPad over the Internet.
Is it possible to send OSC commands over 3G / UMTS with my iPad or iPhone to control a device? So I will not be limited by the router's range when I send OSC commands to the controller when both devices are part of the same Wi-Fi network.
It seems that the applications I downloaded (TouchOSC, iOSC) can only send OSC data over Wi-Fi, however I'd like to send the commands over the Internet (with port forwarding settings in my router).
I would get one of these. Look ma, no wi-fi :)
OSC typically uses UDP (User Datagram Protocol), even if some newer OSC implementations also allow TCP/IP messaging (also see Difference between TCP and UDP?).
Unfortunately (as far as I know), UDP does not work over 3G, which seems to be your problem. In other words: two mobile devices cannot talk to each other on a cellular network. So it has nothing to do with OSC apps not being able to do this, it's just not available from the cellular network.
However (I think, not tested), I see two workarounds here:
try to use TCP/IP instead of UDP to send your OSC packets
if you need UDP on the Arduino side, you could use a server in-between
Do port forwarding on your router to forward port x to the Arduino, and then use the IP address from whatsmyip.com and use that one in the touchOSC app when inputting the IP address. That may work.

Is it possible to connect a socket between two mobile devices (iPhones) over the internet?

Is it possible to connect a socket between two mobile devices (iPhones) over the internet?
I am trying to discover the IP of each device and connect directly. I know it can be done with Bonjour but that only works on local networks. I need a high speed connection between two devices over the internet.
Thanks.
If you had both the IP's and they were both routable, it should be possible. I'm not sure though if the IP's given out by the 3G network are routable. If you are using WIFI, the IP you get is almost certainly not routable. Assuming you have a routable IP though, it should be possible.
The trick is just discovering the IP of the other device. The best way to do that would probably be to have each device register its IP with a web service when your app starts up, then query that service to find the IPs of other devices.
It might get a bit tricky managing "unregistering" IPs when the app is closed or when an IP changes though, but it should be doable.
ETA:
If you have a server that they can both connect to, you should be able to implement a solution using that server (i.e. without the phones actually directly connecting to each other). This would avoid the issue of having routable IPs for the phones.
As for how to bridge the sockets together - your server program would basicly work like an old-school phone switchboard operator. You'd have some kind of registration & discovery protocol built into the server software that would allow a phone to register itself with the server, query a list of the other phones currently connected to the server, indicate which phone it wants to talk to, and accept connections from other phones.
Once it knows who wants to talk to whom, your server software would connect the two together by reading from one phone's socket and writing that data to the other phone's socket.
Only a suggestion, but if you can get each of them to connect to a third site, you'll then know the address of each. Send the address of phone A to phone B (and/or phone B to phone A) and then have them connect as you see fit.
Have you looked through all the 3.0 features? Specifically peer networking (the existence of which is public).
WiFi routers often have a feature called "Port Triggering" which allows internal hosts (in this case an iPhone) to inform the router that they would like to have a connections on particular port forwarded to them. I have no idea if the iPhone supports this protocol.
For IP lookup you may consider using DynamicDNS if the two hosts are known ahead of time OR as stated above a custom web service if they are not (i.e. friends exchanging hostnames vs. strangers discovering each other)
This is an old thread, but I just came across it. You could use a STUN server (or NAT-PMP) to get the public IP address/port combo and then SMS it over to the other phone. So long as you open a listening port on the first device, then your second device can just connect directly using the publi IP address/port you sent to it in the SMS (SMS push registry can automatically wake up your app on the second device to do this)
I have run into this issue with an app I was developing. I was trying to connect to a PC cell card from an iPhone. The problem is that AT&T doesn't enable mobile termination for iPhones so it is physically impossible for two phones on an AT&T network to connect to one another. This is straight from an AT&T antenna engineer.
I was able to get this to work by having the iPhone VPN into a server and then connect to the PC cell card but other than that, it wouldn't work.
I have a very strong feeling (but no evidence) that the iPhone address is going to be non-routable. Of course it actually depends on the operator but AT&T give out 10.x.x.x addresses.
Apple have sample (desktop) code that uses Bonjour to implement portmapping on a WiFi router that supports UnPnP.