What exactly is the difference between ICMP type 3 code 1 and code 7 messages? By reading their descriptions they seem to be used for the same purpose. I am trying to understand when a router will choose to send one or the other.
The differences are explained in RFC 1812 IPv4 Router Requirements, page 81:
1 = Host Unreachable - generated by a router if a forwarding path (route) to the destination host on a directly connected network is not available (does not respond to ARP);
7 = Destination Host Unknown - generated only when a router can determine (from link layer advice) that the destination host does not exist;
Later in the RFC, it requires routers not to send a "Network Unreachable" instead of Type 3 Codes 1 or 7 when other hosts on the subnet are reachable...
Routers MUST use Host Unreachable or Destination Host Unknown codes whenever other hosts on the same destination network might be reachable; otherwise, the source host may erroneously conclude that all hosts on the network are unreachable, and that may not be the case.
Speaking practically, I haven't seen a router implement Type 3 Code 7 (Destination Host Unknown), normally I see Type 3 Code 1 (Host Unreachable).