Why does TCP segment contain source and destination port numbers while this information is already present in Network layer Datagram (IP)?
Can't we make use of the latter to get port numbers?
Network Engineering Stack Exchange is a question and answer site for network engineers. It only takes a minute to sign up.
Sign up to join this communityWhy does TCP segment contain source and destination port numbers while this information is already present in Network layer Datagram (IP)?
Can't we make use of the latter to get port numbers?
Huh? I assume your "network layer datagram" is supposed to be the IP packet - the IP packet just carries the protocol number for the transport layer, nothing else transport-layer specific.
The headers's protocol number field containing 0x06 indicates that the packet's payload is a TCP segment.
The TCP segment has got its own header indicating the source and destination port numbers.
You can check out what's in the headers yourself:
IPv4: https://en.wikipedia.org/wiki/IPv4#Header
IPv6: https://en.wikipedia.org/wiki/IPv6_packet#Fixed_header
TCP: https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure