Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to estabilish TCP connection over the internet between 2 computers which are in different local networks (the local networks use wifi). I have looked for description of TCP protocol, esspecially the structure of TCP header:

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

But how does the router in recipient's local network know which computer in this network is the final destination without MAC address or local ip address?

EDIT: In my situation I have: a mobile phone connected to the internet (not by wifi) and the server (pc) in home local network connected to router by wifi.

So the question is: Are the global sender/reciepient IP address and ports all that are needed or are the MAC addresses also needed to estabilish connection?

If MAC is not necessary what if there are two computers 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 are there no conflicts?

share|improve this question

closed as off-topic by HopelessN00b, MadHatter, Ward, Oliver, mdpc Jan 22 '14 at 18:25

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Oliver, mdpc
  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – HopelessN00b, MadHatter, Ward
If this question can be reworded to fit the rules in the help center, please edit the question.

In a switched network, yes the MAC address is required by the client.

In a routed network, no the MAC address is not required by the client.

In the routed example, the packet leaves the source network via the default route. That router then consults its routing table to decide how to send the traffic to the destination. On arrival at the destination network, the ARP protocol is used for the router to discover the correct MAC address on the local network and the packet is sent.

share|improve this answer
In this situation we have: a mobile phone connected to the internet(not by wifi) and the server(pc) in home local network. – Wojciech Ketrzynski Jan 21 '14 at 1:16
Sounds like the routed example. – dmourati Jan 21 '14 at 1:17
I described it better in the edit in op. Thank you for all your help : ) . As soon as I can upvote I'll do that. – Wojciech Ketrzynski Jan 21 '14 at 1:18
See also: – dmourati Jan 21 '14 at 1:19

If MAC is not necessary what if there are two computers 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 are there no conflicts?

There are conflicts. This is one of the reasons being behind NAT and on a network with a single public IP kind of sucks. There are three ways the router can tell which machine to send the packet to:

  1. If the connection originated from the inside, the router can make a NAT table entry. When it sees the inbound packet, it looks up the source IP address, source port, and destination port up in its NAT table. This tells is the inside destination IP address. It can then rewrite the destination IP address.

  2. If port forwarding is specifically set up in the router, it can look up this destination port and rewrite the destination IP address as configured.

  3. If a dynamic protocol like UPnP is configured, then the inside machine can create a dynamic forwarding entry in the router, allowing it to rewrite the destination IP address.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.