These function codes are related to IP, TCP, UDP
Network Unreachable
Code value: 0
If there is no match found in the routing table for the packet’s destination the it will sent Network Unreachable message.
Host Unreachable
Code value: 1
The user sent the packet to the server and router R1 has a route to R2.
The packet is delivered to router R2. And Router R2 it is unable to get the MAC address of server it may occur in some problem with server or if it is down then.
It send ICMP Destination Unreachable message with host unreachable message to the user.
Protocol Unreachable
Code value: 2
Protocol Unreachable: User sent the packet to the server. It reaches the server and it is finding TCP or UDP.If TCP/UDP is not available on the server it send the user ICMP Designations Unreachable with code Protocols Unreachable
Port Unreachable: Code value: 3
User sent the packet to the server.
The server is up but web server software is not running. The packet will reach the server but cannot be delivered to the web server software. Hence it will send user the ICMP Designation Unreachable code with code Port Unreachable
Fragment Needed but DF set: Code value: 4
It the packet is too big then router R1 and R2 need the fragment the packet. There is a packet header field call Do Not Fragment in the Ip header. If the bit is set then the router cannot fragment the packet and hence sends ICMP Destination Unreachable message to user with the code Can’t Fragment