0
votes

I want to create ICMP fragmentation needed packet using Scapy. When I give type = 3 and code =4 and display the message again, it shows me type =destination unreachable and code = fragmentation needed. But I also want to see one more field associated with this ICMP "next-hop MTU". DO I need to create custom field or is there any other way I can create it. Here is what I'm doing.

i=ICMP()
i.display()
type = 3
code = 4
checksum = 0
unused = 0

Display it again

i.display ()
type= destination unreachable
code = fragmentation needed
checksum =0 
unused = 0
1
I'd recommend writing the packet out to Wireshark to see if you are creating the packet you expect. - RyPeck
Thanks RyPeck. When I fill something in unused and send this ICMP. This unused field is showing as next-hop MTU in wireshark. But I want to inject this packet into existing TCP connection, I created ICMP, TCP, and IP header with scapy but I can't see this packet in wireshark whenever I include TCP header with ICMP and IP. Any reason? - Aaron88
Can you actually have TCP in an ICMP packet? - RyPeck
I know ICMP doesn't uses TCP or UDP but then how do you inject an ICMP fragmentation needed into any TCP connection? We should mention the port number we are targeting rite? ICMP fragmentation needed message is used by TCP to find path-MTU. - Aaron88
no MTU is about the data link, so just the src ip is enough - Dragonborn

1 Answers

0
votes

from other references it seems you can use:

i.unused = mtu