I sit behind a nat network and i am able to ping 8.8.8.8. I know that normal tcp/udp packets gets assigned a inside global address and random port and all incoming packets to this port will be forwarded back to me. How does ICMP packets which do not use any tcp/udp ports work in pat. How will the ICMP echo reply will be forwarded to me?
The best practise for this is described in RFC 5508.
In a nutshell, NATs associate each ICMP-query with a query ID that is bound to the host who originated the query. The answer then gets mapped back on arrival. They use the IP header for this mapping.