7

From what I've read, TCP sits on the layer between the application and IP, and handles setting up the packets, checking for errors, ordering etc so the application itself doesn't have to do it.

However, when I looked at the TCP header I became confused. From the way I understand it, some data is handed to TCP from the application, and is given a destination address to which to send the data. The TCP layer packages it up, and sends it on to the IP layer, who in turn hands it off, all the way on down to the physical layer.

But looking at the TCP header on Wikipedia, there is no mention of a destination address! There is only a destination port number which I am pretty sure is not an address.

TCP Header

So my question is, how does TCP get the addresses? And/or, how does IP get the address if TCP isn't passing them to it?

CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
  • 1
    Addresses are handled in the IP layer. TCP hands IP the addresses so there's no need to include them in the TCP header. –  Jun 29 '14 at 21:11
  • You are looking to wrong layer according to OSI model. Network layer is responsible for transport information between client / server – http://en.wikipedia.org/wiki/OSI_model – Krzysztof Safjanowski Jun 29 '14 at 21:15
  • @MikeW "TCP hands IP the addresses..." Doesn't that take place in the via the header?? – CodyBugstein Jun 29 '14 at 21:19
  • 1
    No. A TCP header always has one or more IP packets attached. You pass the destination address to *create* the TCP *packet*, but the TCP *header* does not need to contain the address. – Tom Zych Jun 29 '14 at 21:21
  • Possible duplicate of [How comes a TCP packet doesn't contains the source and destination IPs?](https://stackoverflow.com/questions/10016032/how-comes-a-tcp-packet-doesnt-contains-the-source-and-destination-ips) – KevinG May 03 '18 at 23:41

1 Answers1

0

It's the Application that's running on top of Transport Layer that chooses everything.

If the Application is designed with reliability in mind, it chooses the connection oriented protocol like TCP.

The same applications tells TCP what the Source and Destination port should be, TCP alone cannot decide this.

Example: If you're accessing a website, your Application would be the browser, since accessing websites normally happens over HTTP/HTTPS and HTTP/HTTPS is designed to be reliable, it chooses TCP. Port 80(HTTP) or 443(HTTPS) are the standard ports used for accessing websites, so either of these ports are used in the Destination Port field while the Source Port can be any random higher number port.

This combination is used to identify something called Transport Layer VC(Virtual Circuit).

Coming to IP, the same application tells what the Destination IP address is, while the Source IP is the machine from where you are running the browser.

IP in Network Layer and TCP in Transport Layer cannot choose anything, it's the Application that tells them what to choose, considering they are the chosen ones.

bvkmohan
  • 74
  • 9