Routers and disconnected mode
A common network configuration in the entreprise world is to set up a LAN and to give an internet access to each station by installing a gateway/router/firewall that interconnects internet and the LAN. This configuration is more and more frequent at homes and users experience many problems about "i can't recieve files by ICQ", "i cant host a server game", "i cant send via DCC on IRC" This happen because each incoming connection from the net is blocked by the router, first for security, and then, because the router can't know the local machine concerned by the incoming connection (except if we configure it to make "port redirection"). The thing i wondered the first time i met those problems is "How can i recieve information then?". The answer i gave to me was "It's because it's always my machine that connects to a server outside and, when the connection is made the channel is bi-directionnal". Was it a good, a bad or an complete answer? I didn't know, because there were situations that invalidated this idea : - I could both recieve and send files via msn - My eDonkey could connect to users to download pieces of files and users could connect to me to download things from my computer. THIS WITHOUT making any port redirection. Those situations made my answer quite unsure but i leaved this problem until now. ---------- Now i'm interesting in making an internet multiplayer game and I have been first thinking of an UDP based solution. Ok but now i enter in the meat of the topic, i remember that UDP is in "disconnected mode" Thus, conforming to my idea, if a server wants to send a datagram to a client and if this client is behind a router, the datagram may never reach him. BUT, i'm behind a router and, in most popular games i don't have experienced any problem. I can play really fine to CS and other shoots. And i believe that those games use UDP. So, my idea of how work routers is now completely invalidated My question is : What's exactly happening on my router when i play counterstrike for exemple? By the way : How the server makes the difference between another machine on my LAN? Thanks for reading me.
The only part of this I can answer is about the LAN vs. outside world question.
When you buy a router, it has 1 port labeled WLAN, and the rest are not ... whatever you plug into the WLAN port is considered "outside" (WLAN, Wide LAN) and whatever you plug into the other ports is considered "inside" (LAN).
It is very much like all the ports on the "inside" are connected by a dumb hub, not a router, and the router is a bridge between the hub, and the external device (usually a cable/dsl modem). It is not exactly like that, because sometimes the hub is less dumn and is then called a switch, or even a managed switch (which usually is just an attempt to allow more maximum bandwidth by reducing collisions between computers).
On the hub/switch side, all traffic going between any devices plugged into the hub/switch are all transmitted with no blocking and no changing (translation).
Between the hub/switch and the WLAN port though, things are different. The router is NOT transmitting all packets from each side to the other. First of all, it is blocking most packets from the "outside" and never sending them to the "inside" ... unless that port is open, or the inside computer has previously (recently) made a connection with the outside computer. The router is actually smart and remembers the destinations of the packets sent from the inside to the outside. Then when packets come from the outside to the inside, it looks at its memory and port configuration to decide if the incoming packets are allowed to get in. If so it transmits them on the inside, if not, it drops them.
If NAT translation is involved, it basically means that the router remembers additional information and performs additional work. Say the router's ip address is 208.100.100.100, and you have 2 internal computer with ip addresses 192.168.1.201 and 192.168.1.202. The addresses in the 192.168 range are NOT allowed on the internet (real internet routers do NOT transmit them). So what happens is your router sees a packet leaving your computer going to an outside address (lets say 135.1.1.10), it intercepts the packet and either changes the sender address from 192.168.1.201 to 208.100.100.100 (making the router the sender instead of the internal computer) - or it adds a wrapper packet (who's sender is the router at 208.100.100.100). So either way, the router has changed the sender from the 192.168 address, to it's own address.
Later a packet comes from the outside world (135.1.1.10) destined for the router itself (208.100.100.100). The router sees this, looks at its forwarding table/memory or the wrapper packets contents ... and modifies the packet to strip off the wrapper (if there is one) and transmit a packet on the "inside" hub/switch destined for your comptuer (192.168.1.201).
OK, so maybe I said more than I thought I was going to ... hope it helps.
When you buy a router, it has 1 port labeled WLAN, and the rest are not ... whatever you plug into the WLAN port is considered "outside" (WLAN, Wide LAN) and whatever you plug into the other ports is considered "inside" (LAN).
It is very much like all the ports on the "inside" are connected by a dumb hub, not a router, and the router is a bridge between the hub, and the external device (usually a cable/dsl modem). It is not exactly like that, because sometimes the hub is less dumn and is then called a switch, or even a managed switch (which usually is just an attempt to allow more maximum bandwidth by reducing collisions between computers).
On the hub/switch side, all traffic going between any devices plugged into the hub/switch are all transmitted with no blocking and no changing (translation).
Between the hub/switch and the WLAN port though, things are different. The router is NOT transmitting all packets from each side to the other. First of all, it is blocking most packets from the "outside" and never sending them to the "inside" ... unless that port is open, or the inside computer has previously (recently) made a connection with the outside computer. The router is actually smart and remembers the destinations of the packets sent from the inside to the outside. Then when packets come from the outside to the inside, it looks at its memory and port configuration to decide if the incoming packets are allowed to get in. If so it transmits them on the inside, if not, it drops them.
If NAT translation is involved, it basically means that the router remembers additional information and performs additional work. Say the router's ip address is 208.100.100.100, and you have 2 internal computer with ip addresses 192.168.1.201 and 192.168.1.202. The addresses in the 192.168 range are NOT allowed on the internet (real internet routers do NOT transmit them). So what happens is your router sees a packet leaving your computer going to an outside address (lets say 135.1.1.10), it intercepts the packet and either changes the sender address from 192.168.1.201 to 208.100.100.100 (making the router the sender instead of the internal computer) - or it adds a wrapper packet (who's sender is the router at 208.100.100.100). So either way, the router has changed the sender from the 192.168 address, to it's own address.
Later a packet comes from the outside world (135.1.1.10) destined for the router itself (208.100.100.100). The router sees this, looks at its forwarding table/memory or the wrapper packets contents ... and modifies the packet to strip off the wrapper (if there is one) and transmit a packet on the "inside" hub/switch destined for your comptuer (192.168.1.201).
OK, so maybe I said more than I thought I was going to ... hope it helps.
Check out the Forum FAQ; specifically the parts about NAT and NAT introduction/traversal/punch-through.
enum Bool { True, False, FileNotFound };
Thanks for your replies, now i know the truth.
The article in the FAQ http://www.mindcontrol.org/~hplus/nat-punch.html
is very interesting for what i want to do. I'll surely implement an Introducer server for my game
GroOvY
The article in the FAQ http://www.mindcontrol.org/~hplus/nat-punch.html
is very interesting for what i want to do. I'll surely implement an Introducer server for my game
GroOvY
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement