I'm trying to write code for a traceroute program for a project. That is , a program that will trace the path of a packet from a source to a destination.

THEORY -> I'm using UDP, IP and ICMP protocols to implement the traceroute program. I'm sending a UDP packet to a high port (Eg. 33434) on a remote computer and it should reply with an ICMP Destination Unreachable Message (Type=3), Port Unreachable (Type 3) message. Contained within this ICMP message is the address of the remote host. In this way I can get the IP of each computer along the path by varying the TTL value from 1 to 255 until the destination is reached.

MY PROBLEM -> I am trying to send a UDP packet to a high port (33434) to my local machine which should give me an ICMP reply. However I'm getting a RawIP reply, the original IP header and the contents of the original UDP packet as the reply when I'm supposed to get an IP Header, the ICMP Header(Type 3), and the first 64-bits of the original UDP datagram, as the reply.
I can't figure out what I'm doing wrong!

CODE -> This is the code I have so far that gives the wrong reply
as described above in "MY PROBLEM".
The code is distributed among 5 files -> "IcmpHeader.h", "IpHeader.h", "PseudoHeader.h", "UdpHeader.h" and "Driver.cpp"

Does anyone know how to fix this? Any help will be greatly appreciated.
Thanks.