i encounter this line in a program for creating icmp ping packets in python
header = struct.pack("bbHHh", ICMP_ECHO_REQUEST, 0, my_checksum, ID, 1)
what does "bbHHh" means here
i encounter this line in a program for creating icmp ping packets in python
header = struct.pack("bbHHh", ICMP_ECHO_REQUEST, 0, my_checksum, ID, 1)
what does "bbHHh" means here
Check here: https://docs.python.org/2/library/struct.html#format-characters
it means that
ICMP_ECHO_REQUEST is a signed char -> integer in python
0 the same
my_checksum is unsigned short -> integer in python
ID the same
h is a short -> integer in python
The documentation is here: https://docs.python.org/2/library/struct.html - it's a format string. Your particular example means the equivalent of this in C: