Connecting SiMPLE to the "Outside World"
[Note: This webpage is intended for users of SiMPLE.]
|Click Here to Read About SiMPLE|
Prior to version 12.6.21, SiMPLE programs could exist only in a "closed universe". In other words, they could not communicate with other SiMPLE programs that might be running on other separate computers. But now it is possible for you to create SiMPLE programs that can communicate with other computers over a network.
A router is a device that forwards data packets between computer networks. A router is connected to two or more data lines from different networks. When a data packet comes in on one of the lines, the router reads the address information in the packet to determine its ultimate destination. Then, using information in its routing table, it directs the packet to the next network on its journey. Routers perform the "traffic directing" functions on the Internet. A data packet is typically forwarded from one router to another through the networks that constitute the internetwork until it gets to its destination node.
Every computer has many different ports (or "channels") through which information can flow. So, in order for a program to communicate with another computer, the contacting program must be able to specify not only which computer is to be contacted, but also the port number through which it wishes to communicate with that other computer.
Each computer in a network has a number (called its IP) which identifies it. Every IP has the form: a.b.c.d where a, b, c and d each represents a number in the range 0-255.
As confusing as it may seem, your computer may actually have two different IPs associated with it, depending on the router you are using. One of those IPs is your "Public" IP (which Google will tell you if you ask it: "What is my IP"). That "Public" IP is the IP of your router.
The second IP is the number that the router assigns to your computer. Your assigned IP will probably be of the form: 192.168.c.d. (You can find your assigned IP by either running the "Get My IP" program in your "Network" project folder, or by running SiMPLE in command-line mode and typing: IPCONFIG on the command line.)
Why Are IPs of the Form 192.168.c.d So Prevalent?
The following explanation is given by Mr. James Hart:
Any computer whose IP is of the form 192.168.c.d is a machine behind a router (or the router's IP). Computers don't usually connect to the internet directly. They all share the one connection to the internet uniquely identified by a different IP. (In the following illustration it is 188.8.131.52).
The router does all the hard work of keeping track of when a computer on the inside requests a connection to an IP on the internet and routes that connection between the internet and the correct computer behind the router. So in SiMPLE, when you use a 192.168.c.d IP, it must be for a computer behind the router. No one connected to the internet directly ever has this kind of IP. (That is a rule of the internet.) The router will never route a request to an internal IP (such as 192.168.0.2). It always routes the request to the correct computer behind the router. The outside IP (in this case 184.108.40.206) is what google tells you. It is unique and no one else in the entire world has that IP at the same time as you! Many other computers behind different routers share the a.b.c.d IP's. So there are probably thousands of computers that get 192.168.0.2 or 192.168.1.2 when they run IPCONFIG. (The consumer level router is probably the reason we haven't ran out of IP addresses yet!)
Now, some computers are not behind a router. They are connected directly to the internet and their IPCONFIG would show the same thing google does. These are the computers you can directly connect to with SiMPLE without any issue.
At least one of the computers in the two way connection has to be currently directed. That last statement is bit of a lie, because the way you manually fix the issue is to tell the router "If someone connects to you via the public IP (the one google shows) on a certain port, pretend (or route to) that computer as if it is actually directly connected to the internet."
How might it be possible for any SiMPLE user (anywhere in the world) to be able to write SiMPLE programs that could connect to any other SiMPLE user, even if they both have 192.168.c.d as their IP? One solution (which has not yet been implemented by SiMPLE CodeWorks) would be to implement a proxy that the SiMPLE programs could actually communicate through. What this means is, there could be a computer always running somewhere, and it would be the "middle man" (let's call this middle man "PROXY") between talking to both computers. So theoretically, there could be a SiMPLE library task [which might be named Opennetworklocationviaproxy("Unique ID"), where "Unique ID" would take the place of the IP and port combination]. As long as PROXY is running the connection would always work because PROXY would be setup in such a way that it isn't blocked because of the 192.168.c.d issue. So SiMPLE Client A and SiMPLE Client B would now both use the same "Unique ID" and get a connection.
The disadvantage of this setup is probably evident: If PROXY goes down (or gets restarted), anyone using a SiMPLE program would get disconnected. Also, having to have PROXY available online at all times would be costly.
An alternative solution (which has also not yet been implemented) would be to provide uPNP support in the SiMPLE network library. What this means is, if someone is behind a router (i.e., they have an IP of the form 192.168.c.d), SiMPLE would be able to tell that router, "Hey router, automatically make it so if someone connects to this port from the outside you send it to ME." This won't work for everyone because support for uPNP on consumer routers is somewhat new(ish). However, almost all of them come with it enabled out of the box nowadays, but there might be some legacy hardware still out there.
[ Webmaster | FAQ's | Home Page | Contact Us ]