in reply to SNTP pack and unpack
cheako@arcadia:~$ perl warn unpack("B620",pack( 'B8 C3 N10 B32', '00100011', '0', '0', '0', '0', '0', '0', '0', '0', 1425691777, 761152, '0', '0', 1425691777, 761152 )); 00100011000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 01010100111110100101010010000001 00000000000010111001110101000000 00000000000000000000000000000000 00000000000000000000000000000000 01010100111110100101010010000001 10111000000000000000000000000000 at - line 1. Different output, but identical input :/. cheako@arcadia:~$ perl warn unpack("B620",pack( 'B8 C3 N11', '00100011', '0', '0', '0', '0', '0', '0', '0', '0', 1425691777, 761152, '0', '0', 1425691777, 761152 )); cheako@arcadia:~$ perl warn unpack("B620",pack( 'B8 C3 N11', '00100011', '0', '0', '0', '0', '0', '0', '0', '0', 1425691777, 761152, '0', '0', 1425691777, 761152 )); 00100011000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 01010100111110100101010010000001 00000000000010111001110101000000 00000000000000000000000000000000 00000000000000000000000000000000 01010100111110100101010010000001 00000000000010111001110101000000 at - line 1. cheako@arcadia:~$ perl warn unpack("B620",pack( 'B8 C3 N10 B32', '00100011', '0', '0', '0', '0', '0', '0', '0', '0', 1425691777, 761152, '0', '0', 1425691777, '00000000000010111001110101000000' )); 00100011000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 01010100111110100101010010000001 00000000000010111001110101000000 00000000000000000000000000000000 00000000000000000000000000000000 01010100111110100101010010000001 00000000000010111001110101000000 at - line 1.
I've a lot of experience with pack and unpack and every time I learn something new, seems they never behave the way one would think they should. Check it with a warn unpack("B384",$send_sntp_packet) the best thing you can do at times like this is add in warn every branch.
Wrap each call to pack/unpack like this and you'll see what's wrong.my@argsforpacksend_sntp_packet=($client_li_vm_mode , + $client_stratum , $client_poll , $client_precision , $client_root_de +lay , $client_dispersion , $client_reference_identifier , $client_ref +erence_timestamp_sec , $client_reference_timestamp_microsec , $client +_originate_timestamp_sec , $client_originate_timestamp_microsec , $cl +ient_receive_timestamp_sec , $client_receive_timestamp_microsec , $cl +ient_transmit_sec , $client_transmit_microsec); warn Dumper \@argsfo +rpacksend_sntp_packet; my $send_sntp_packet = pack "B8 C3 N10 B32", @argsforpacksend_sntp_p +acket; warn unpack("B384",$send_sntp_packet)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SNTP pack and unpack
by Anonymous Monk on Mar 07, 2015 at 00:42 UTC | |
| |
|
Re^2: SNTP pack and unpack
by thanos1983 (Parson) on Mar 07, 2015 at 01:33 UTC | |
by choroba (Cardinal) on Mar 07, 2015 at 02:03 UTC | |
by thanos1983 (Parson) on Mar 07, 2015 at 17:23 UTC | |
|
Re^2: SNTP pack and unpack
by Anonymous Monk on Mar 07, 2015 at 11:06 UTC | |
|
Re^2: SNTP pack and unpack
by thanos1983 (Parson) on Mar 07, 2015 at 12:13 UTC | |
|
Re^2: SNTP pack and unpack
by Anonymous Monk on Mar 07, 2015 at 00:07 UTC | |
| |
|
Re^2: SNTP pack and unpack
by cheako (Beadle) on Mar 07, 2015 at 02:09 UTC |