Transfer file over ICMP - networking

I'm studying about Networking . I'm want to transfer file over ICMP protocol then capture networking traffic by wireshark to decode raw data . But I dont know how to transfer file by ICMP protocol. So my question is how can I transfer file by ICMP between host.
Thanks a lot .

If you insist on sending data using ICMP (which is reasonable in some use-cases) I suggest you read this article and that one. The first one also contains proof-of-concept C-code for client and server that use ICMP to transfer data. You can find another example written in C++ here.
The idea behind this method is using the data (payload) section of ICMP Echo (ping) requests and responses for transferring data (or files in this case). Most devices reply to ICMP Echo (ping) requests so it's a way to transfer files when other protocols (such as ssh, smb, ftp, etc.) are blocked.

If you study about TCP/IP layers, you will find that ICMP is a Internet layer protocol and its purpose is to:
The Internet Control Message Protocol (ICMP) is a supporting protocol in the Internet protocol suite. It is used by network devices, like routers, to send error messages and operational information.
So ICMP is not a data transfer protocol like HTTP or FTP etc. Technically it is not possible in any case to use ICMP as data transfer protocol, Unless you change structure and all coding of ICMP and then it will no longer be ICMP.

Related

Why request dhcp packet is neccessary?

In DHCP protocol we have 4 packets named DORA.
first of all client send a broadcast Discovery packet for detecting DHCP server.
Then server send a Offer packet contain ip, subnet and many options and waiting for client.
If client find Offer packet suitable, send a broadcast Request and get ACK or NAK.
But why ?
Why we can't ignore Request packet and replace this way to sending 3 packets.
Discovery, Offer and ACK.
client -> Discovery
server -> Offer
client -> ACK
Why this way is not secure or suitable ?
When the client broadcasts the Discover packet, it may get Offer packets from multiple DHCP servers. The purpose of the Request packet is to say to one of the servers, "I want to use the IP address that you offered to me". If that wasn't sent:
the server whose offered IP the client is going to use wouldn't know not to offer that IP to a different client, and
the other servers wouldn't know that they can offer their IPs to other clients.
Then the final Acknowledge packet tells the client that the server has gotten the Request, and that the client now has the "lease" on the IP address.
This is intended to ensure that:
IP addresses are not wasted because a server thinks the client is using the Offered IP, when the client is actually using a different server's Offered IP.
The same IP is not accidentally leased to two clients at the same ... which causes chaos.
In the variation that you proposed, suppose that the ACK packet from the client to the server is lost. Now the server won't realize that the client is going to use the Offered IP address. A few minutes later, it could then Offer the same IP address to a different client and ... chaos ensues.
Please don't imagine that the people who design internet protocols are dullards. They have thought these things through carefully before they write the RFCs. And many other (equally smart) people have gone over the pre-approved RFCs carefully looking for problems. So ... if there is something about a standard protocol that you think is wrong ... it is probably you, and not the protocol designer who is mistaken.

Can you send a packet without being visible to the receiver?

Can you send data to a UDP receiver without your IP address or location visible to the receiver?
Yes. It's possible to create and send UDP packets with a spoofed IP address using a raw socket.
Raw sockets allow applications to create their own IP headers including the source address fields. Look around for examples in whatever language you write in.
However, creating and sending such a packet doesn't mean that the networks along the way to the recipient will actually deliver it. Some networks employ defensed like Reverse path forwarding to protect against IP spoofing. There's CAIDA a research project that tests for IP spoofing in networks around the world, you can find an up to date report here.

destination port in UDP protocol

My question is that how the destination port address in UDP is chosen/given?
I mean what matters to set a destination port in a UDP packet?
Because when we send a packet, just the destination address(ip) is important and we want to send data to our destination.
It has nothing to do with the port!
Do we assign a random port?
Typically, whatever documentation tells you what to put in the UDP datagram you're sending should also tell you what port to send it to.
For example, if you're trying to talk to an NTP server, RFC5905 tells you what to put in the UDP datagrams you send. It also tells you, on page 16, to send it to port 123.
If you're writing a DNS resolver, RFC1035 is one place you might look for the information needed to know what to put in your UDP datagrams. It also tells you, in section 4.2, to send the datagrams to port 53.
So however you're figuring out what to put in the UDP datagrams you're going to send, that's typically what tells you either what port to send them to or, in some cases, how to determine what port to send them to.
For example, a media streaming protocol might start with the information about the stream being delivered by a web server. In that case, the information delivered by the web server to the client might include the destination port to send datagrams to.
Generally, there's either a well-known port that at least one side listens for datagrams on or there's some external method using a different protocol that tells whichever end sends the first datagram what port to send it to. The other end then just replies, sending its response datagrams to whatever port that first datagram was sent from.
Generally, the sending port is chose randomly for the ephemeral ports available.
The destination port is the port to which the destination application is listening. To facilitate this, IANA maintains the Service Name and Transport Protocol Port Number Registry for standard applications and protocols.
If you create your own application or protocol, there is a range for you to use, but you should always check the registry to make sure you will not step on some other application or protocol.
When you design your listening application or protocol, you choose a port on which it listens, and the sending application will need to send to that port.

Unable to capture a UDP protocol packet with Wireshark by visiting any website

I am using wireshark, and for an exercise we need to capture a UDP packet with wireshark by visiting any website, and then analyze the information within that packet.
I have tried numerous times and all websites appear to send packets with TCP protocol. I have looked at Wireshark documentation, as well as looked online and am stumped.
What am I doing wrong, and how can I get a UDP packet by visiting a website?
Thats the main question. A side question is: how do I filter the captured packets to only those packets referring to requests and responses from websites over the network? Currently there appear to be a bunch of low-level captured packets that I need to scroll through.
Thanks in advance!
Because websockets/HTTP is over TCP.
And in Wireshark,if you are intending to see packets corresponding to a particular client/server, click on the packet and do "Follow TCP/UDP stream"
You will never see a UDP packet in a WEB connection. Never never never. The Web's connection is in HTTP protocol and HTTP is encapsulated in TCP.
If you need see UDP packets en wireshark you can generate UDP sockets from your host. You can:
Make a connection with a TFTP server.
Renew your IP you will see the DHCP protocol.
You search, what protocols are encapsulated in UDP and use it.
Make a program with UDP sokects.

computer networking: ARP - point of the ICMP echo packets

I'm studying Address Resolution Protocol and in all my books and slides the diagrams showing an ARP take place (i.e. Host1 sends ARP request, Router checks it, redirects it, eventually gets to Host2 and then Host2 sends back an ARP Reply).
What I'm wondering is why the examples include ICMP echo replies and requests, do they serve any purpose within ARP?
Thanks
I would guess that it is to initiate the ARPs. A machine is not going to send an ARP for no reason. It will only send an ARP if it needs to send something to the IP address (and doesn't know the destination MAC address yet). Maybe the ICMP echo request is that 'something' the authors use in their examples to cause the source machine to send an ARP.
Short answer: There is no special relationship between ICMP and ARP; that's just what the authors of your book decided to use as an example.

Resources