You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to write a ping tool, but I'm having issues while trying out different sizes of buffer for the Ipv4/Icmp packets.
The main idea is to be able to adjust the payload size on the the ip packet, but when I implemented the thing, I realized that I was more confused than I thought.
According to RFC 791, an IP can handle a datagram of maximum size 65,535 bytes. It also states that the max "guaranteed" size to be handled is around 500bytes.
Let me provide an example of something that I don't quite understand.
Here's a snippet of the code:
let(tx, rx) = pnet::transport::transport_channel(2 << 15,Layer3(IpNextHeaderProtocols::Icmp)).map_err(|e| e.to_string()).expect("Failed creating transport channel. Try to `sudo setcap cap_net_raw+ep /path/to/exec`.\ Or run program with sudo.");
let icmp_packet = IcmpPacket::new(packet).unwrap();match icmp_packet.get_icmp_type(){IcmpTypes::EchoReply => {let echo_reply_packet = echo_reply::EchoReplyPacket::new(packet).unwrap();info!("{} icmp - {} ip packet bytes from {:?}: icmp_seq={} ttl={} time={:.3} ms",
icmp_packet.packet().len(),
ip_packet_size,
source,
echo_reply_packet.get_sequence_number(),
ttl,
dt
);}
....}
When running with these values for the buffers and lengths, I don't get any response.
If I change the value of the Ipv4 header to 21. I start getting responses like this:
21 icmp - 41 ip packet bytes from 192.168.1.68: icmp_seq=1 ttl=64 time=0.121 ms
I've played around with the values, but the first thing I noticed is that using a header size of 20 for IP never works. Which is weird, because 20 should be the minimum size for the header.
I would like some help in figuring out why I couldn't use this minimum header size.
Here's the link to the git repo. in case anyone's curious about the code.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm trying to write a ping tool, but I'm having issues while trying out different sizes of buffer for the Ipv4/Icmp packets.
The main idea is to be able to adjust the payload size on the the ip packet, but when I implemented the thing, I realized that I was more confused than I thought.
According to RFC 791, an IP can handle a datagram of maximum size 65,535 bytes. It also states that the max "guaranteed" size to be handled is around 500bytes.
Let me provide an example of something that I don't quite understand.
Here's a snippet of the code:
I'm creating the transport like this:
And the packet is created like this:
And this is how I handle the reply:
When running with these values for the buffers and lengths, I don't get any response.
If I change the value of the Ipv4 header to 21. I start getting responses like this:
I've played around with the values, but the first thing I noticed is that using a header size of 20 for IP never works. Which is weird, because 20 should be the minimum size for the header.
I would like some help in figuring out why I couldn't use this minimum header size.
Here's the link to the git repo. in case anyone's curious about the code.
Beta Was this translation helpful? Give feedback.
All reactions