I am using scapy to send data over ICMP. I need to send image and other files over ICMP using scapy. I am able to send simple strings in ICMP. How could I send image and other files ?
I think you've discovered why the inventors of the Internet developed TCP. There's a limit on the payload size in an ICMP packet. Most networks have a 1500-byte total limit on the size of Ethernet packets, so with a 20-byte IP header and an 8-byte ICMP header, your maximum payload size in a single packet will be 1472 octets. That's not enough for many image files.
You need a way of breaking up your image data stream into chunks of about that size, sending them in multiple ICMP packets, and reassembling them into a data stream on the receiver.
Considering that there's no guarantee ICMP packets are received in order, and indeed no guarantee that they'll all be received in order, you will need to put some kind of sequence number into the the individual packets, so you can reassembly them in order. You also may need some timeout logic so your receiving machine can figure out that a packet was lost and so the image will never be completed.
RTP and TCP are two protocols layered on IP that do that. They are documented in precise detail, and you can learn from those documents how to do what you're trying to do and some of the pitfalls and performance implications.
How to send an image in ICMP data field using ICMP