Skip to main content
added 530 characters in body
Source Link
Zac67
  • 88.1k
  • 4
  • 73
  • 137

The transport layer encapsulates the application layer data along with destination IP and destination port information and passes it along to the network layer.

That's not entirely correct. While the transport layer does use and pass on source and destination IP information, that information isn't encapsulated by the transport layer but by the underlying network layer.

(The transport layer needs to be aware of the source IP address because a host can have multiple interfaces or IP-interface bindings.)

why does the UDP datagram header contain a space for a source port?

Ports are a concept of the transport-layer protocol (L4). Not all those protocols use ports but the most common ones, TCP and UDP do.

There are no ports on the network layer (IP), so it wouldn't make sense to put that field in the IP header.

how does the application layer know what IP to respond to if the IP header has been stripped?

The IP header isn't visible to the application but its information is. The OS stack provides an API for the application to use, usually BSD-style sockets. That API also provides information about a connection partner's IP and L4 port.

why does the UDP datagram header contain a space for a source port?

Ports are a concept of the transport-layer protocol (L4). Not all those protocols use ports but the most common ones, TCP and UDP do.

There are no ports on the network layer (IP), so it wouldn't make sense to put that field in the IP header.

how does the application layer know what IP to respond to if the IP header has been stripped?

The IP header isn't visible to the application but its information is. The OS stack provides an API for the application to use, usually BSD-style sockets. That API also provides information about a connection partner's IP and L4 port.

The transport layer encapsulates the application layer data along with destination IP and destination port information and passes it along to the network layer.

That's not entirely correct. While the transport layer does use and pass on source and destination IP information, that information isn't encapsulated by the transport layer but by the underlying network layer.

(The transport layer needs to be aware of the source IP address because a host can have multiple interfaces or IP-interface bindings.)

why does the UDP datagram header contain a space for a source port?

Ports are a concept of the transport-layer protocol (L4). Not all those protocols use ports but the most common ones TCP and UDP do.

There are no ports on the network layer (IP), so it wouldn't make sense to put that field in the IP header.

how does the application layer know what IP to respond to if the IP header has been stripped?

The IP header isn't visible to the application but its information is. The OS stack provides an API for the application to use, usually BSD-style sockets. That API also provides information about a connection partner's IP and L4 port.

Source Link
Zac67
  • 88.1k
  • 4
  • 73
  • 137

why does the UDP datagram header contain a space for a source port?

Ports are a concept of the transport-layer protocol (L4). Not all those protocols use ports but the most common ones, TCP and UDP do.

There are no ports on the network layer (IP), so it wouldn't make sense to put that field in the IP header.

how does the application layer know what IP to respond to if the IP header has been stripped?

The IP header isn't visible to the application but its information is. The OS stack provides an API for the application to use, usually BSD-style sockets. That API also provides information about a connection partner's IP and L4 port.