Are there any transport layer protocol that does not have the concept of ports? If so what do they use instead? Also how does NAT work for such protocols?
2 Answers
Yes. There are many layer-4 protocols. You can get the full registered list at Assigned Internet Protocol Numbers.
There are things like IGP protocols, e.g. EIGRP or OSPF transport protocols that do not use port numbers. Port numbers are addresses for some transport protocols. Most of the registered transport protocols do not use port numbers. Some use other addressing, and some do not use any addressing.
The port addressing allows an OS to multiplex the protocol, but many transport protocols do not need to multiplex, or they use something other than port addresses to multiplex. There may be only one application that needs the data being transported by a protocol. With something like TCP, you will have many applications using it for communications, but you may have a transport protocol dedicated to a single application.
There are several version of NAT. The common NAT is really NAPT. NAPT really only works well* for TCP, UDP, and ICMP. Other protocols have real problems with NAPT. Remember that NAPT is only a kludge to extend the life of IPv4 until IPv6 is ubiquitous. The IP paradigm is end-to-end, where each endpoint has a unique address, and NAPT breaks this IP paradigm.
*There are also applications using TCP or UDP that have real problems with NAT.
4.1.2. Network Address Port Translation (NAPT)
NAPT extends the notion of translation one step further by also translating transport identifier (e.g., TCP and UDP port numbers, ICMP query identifiers). This allows the transport identifiers of a number of private hosts to be multiplexed into the transport identifiers of a single external address. NAPT allows a set of hosts to share a single external address. Note that NAPT can be combined with Basic NAT so that a pool of external addresses are used in conjunction with port translation.
For packets outbound from the private network, NAPT would translate the source IP address, source transport identifier and related fields such as IP, TCP, UDP and ICMP header checksums. Transport identifier can be one of TCP/UDP port or ICMP query ID. For inbound packets, the destination IP address, destination transport identifier and the IP and transport header checksums are translated.
A NAPT router in figure 2 may be configured to translate sessions originated from N-Pri into a single external address, say Addr-i.
Very often, the external interface address Addr-Nx of NAPT router is used as the address to map N-Pri to.
Yes there is ICMP which did not have the concept of port number , and instead use the ICMP ID just like the port number and for more details you could see the below RFC: