Added a correct checksum print

This commit is contained in:
beffroi 2022-12-08 17:42:46 +01:00
parent 9bb93ca47c
commit 276bc6d174
1 changed files with 3 additions and 3 deletions

View File

@ -112,7 +112,7 @@ fn main() {
// Send the ping request to the specified destination IP address.
let dest_addr = SocketAddr::new(IpAddr::V4(dest_ip), 0);
println!("[SENDING ICMP DATA]\n");
println!("CHECKSUM: [{:04x}]",checksum);
println!("CHECKSUM: {:02x} {:02x}", (checksum&0xff00)>>8, (checksum)&0xff);
println!("{}",rhexdump::hexdump(&buf));
// Starting the timer
@ -150,8 +150,8 @@ fn main() {
// Print the parsed response.
println!("\n[ANALYSIS] \n");
// println!("CHECKSUM: {:02x} {:02x}",(icmp_checksum<<8)&0x00ff, icmp_checksum&0xff);
println!("CHECKSUM: [{:04x}]",icmp_checksum);
println!("CHECKSUM: {:02x} {:02x}", (icmp_checksum&0xff00)>>8, (icmp_checksum)&0xff);
// println!("CHECKSUM: [{:04x}]",icmp_checksum);
println!("{}",rhexdump::hexdump(&buf));
println!(" > {} bytes recv over the socket in {:.2} milliseconds", bytes_recv, (elapsed.as_micros() as f64)/1000.);
println!(" > icmp_type = {:width$} icmp_code = {:width$}", icmp_type, icmp_code, width=2);