-1

I want to estabilish TCP connection over the internet between 2 computers which are in different local networks(wifi). I have looked for description of TCP protocol, esspecially the structure of TCP header: http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Checksum_computation

I assumed from that data that only: Source address(global ip), Destination address(global ip), Source port, Destination port are needed.

But how router in recipient's local network will know which computer in this network is recpient without MAC address or local ip address?

So the question: Is MAC address is needed to estabilish connection?

Wojciech Ketrzynski
  • 2,503
  • 2
  • 15
  • 12
  • Please ask on Serverfault. Your question is a bit odd, anyway, because you're asking if a ISO/OSI level 3+ connection is possible without a feature (MAC) of a level 2 protocol (e.g. ethernet). – Uli Köhler Jan 21 '14 at 01:02
  • 1
    MAC address is abstracted by a protocol like TCP which stays on trasport layer. TCP shouldn't care about it, even if it used by lower levels protocols to route packets. – Jack Jan 21 '14 at 01:03

1 Answers1

1

No, MAC addresses are not needed for that.
What you´re asking is called port forwarding:
The router of the server side must be configured that way
that incoming connections on port x are connected to local PC y.
(This could maybe be automated with UPNP, depends on the router etc.)

At the client side, after the client send something to the server,
the router "remembers" where to forward the incoming answer

deviantfan
  • 11,268
  • 3
  • 32
  • 49
  • Thanks. What if there are two pc's in the same network that are listening on the same port. As far as I remember all pc's use port 80 for http which uses tcp. Why there is no conflict if we have for example 4 computers in that network browsing? – Wojciech Ketrzynski Jan 21 '14 at 01:07
  • @WojciechKetrzynski StackOverflow is about *programming* problems. Please ask on Superuser or on ServerFault! This is *not* the right place to ask! – Uli Köhler Jan 21 '14 at 01:10
  • 1
    If server and client are in the same local network, just use the local server ip to connect (which is locally unique, ie. each of the 4 computers has it´s own local IP). The global ip and port forwarding aren´t needed at all. – deviantfan Jan 21 '14 at 01:10
  • 1
    @Uli Köhler: Well, he asked already, and people said that already...just wait for someone to move. – deviantfan Jan 21 '14 at 01:11
  • @deviantfan They are not on the same network. I meant that when we browse the web(like 2 people in the same local network) how the router knows to whom forward incoming messages from websites if both use the same http port 80. – Wojciech Ketrzynski Jan 21 '14 at 01:13
  • Say the webserver is listening to port 80 to handle HTTP requests, the browser isn't listening for responses on 80. The source port the browser will open for handling a request will be a free port, possibly from a specific range. – damienc88 Jan 21 '14 at 01:17
  • The 2 people are clients. Port 80 in HTTP (and similar ports for other applications) is the server, so that clients know how to find him (a single server machine could run more than HTTP server). When the connection is etablished, the client ue a own unused port number for that connection locally. Other than that, the router may change the whole thing. If client with a local ip connects to a server, in reality, it "connects" to the local router. The router makes the request and is demanding the answer of the server to port xy. If there is data received at xy, it´s sent to the correct client. – deviantfan Jan 21 '14 at 01:22