What is Ping and How it Works

What is Ping

Ping is a computer network utility that is used to test the reachability of a host on an Internet Protocol (IP) network. Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP echo reply. But, What’s ICMP? It’s a transport layer protocol as TCP and UDP. But it’s not used for regular communication. ICMP is used for sending error messages or controling information between network devices.

How it works

When we ping a remote host, what lies behind the scene is that we send a ICMP packet to the remote host. When the remote host receive the packet, it will send back a reply to notify us that it’s reachable. Here is the information we need to specify in a ICMP packet.

IPV4 Datagram + ICMP

This IPV4 datagram shows what we actually send out to the network when we ping a remote host.The datagram can be divided into two parts by its background color. The blue part of the table is IPV4 header. The red part of the table is ICMP header which is wrapped inside IPV4 datagram. There are many fields that we need to specify in the datagram. But the most important field of ICMP header is Type of message. The most important fields of IPV4 header are Source IP address and Destination IP address.

Suppose the Bob want to ping kelvin.ink and we have the following parameters.

Bob's IP address : 192.168.1.100
Kelvin.ink IP address : 192.168.2.102

Bob can directly type the following command to his terminal:

ping 192.168.2.102

Then the ping utility will automatically construct an echo request ICMP packet with the following configuration and send out to the network.

Type of message = 8
Source IP address = 192.168.1.100
Destination IP address = 192.168.2.102

Where type of message = 8 means this message is an echo request message. For more information about type of message of ICMP, please refer to ICMP wiki.
In addition, ICMP protocol has also been used for route tracing network utilities like tracert in windows and traceroute in linux. I will explain these commands in details in other posts. Please refer to kelvin.ink for more information.

When kelvin.ink receive the ICMP packet, it will reply to Bob an echo reply ICMP packet with the following configuration.

Type of message = 0
Source IP address = 192.168.1.102
Destination IP address = 192.168.2.100

Where type of message = 0 means this message is an echo reply message.

When Bob receive the reply from kelvin.ink, he can be sure that the network configuration of his computer is correct and kelvin.ink is reachable.

Visualize it in Packet tracer

Packet Tracer is a visual simulation tool designed by Cisco Systems that allows users to create network topology and imitate computer networks. You can download and play it for free. This Youtube video will show you how a ping ICMP packet is transmitting in the network in more details. Youtube Video Link.

Youtube Video Link

Blinding Signature

Introduction

Blind signature is a cryptography scheme introduced by David Chaum. Blind signature scheme is used when the author and the signer of a message are not the same. For example, when voters want to cast their votes to voting center , they need a signature from election authority to prove that they are one of the citizens of the nation. Why do we need blind signature? In this voting example, we want to keep the privacy of all the voters. We don’t want anybody, including the election authority knowing the choices of voters.

I will introduce some background of blind signature first.

Hash function

A hash function H(x) can map arbitrary number of bits into fixed number of bits, like SHA256 or SHA3.

IMG.1 Hash Function

Hash functions are required to satisfied some properties. The most mentionable one of the properties is preimage resistant. That is when H(x) is known to adversary, it’s infeasible to find out x. This property can protect the voter from adversary attack as we will show below.

##Asymmetric encryption scheme ##
Asymmetric encryption scheme is also called public key cryptography. In asymmetric encryption scheme, a person has a pair of keys : public key and private key. Public key is known to everyone, but private key is only known to himself. Whoever want to send messages to him should encrypt those messages with his public key. When he receives those messages, he can decrypt it with his private key. RSA is a typical a symmetric encryption scheme developed by Ron Rivest, Adi Shamir, and Leonard Adleman.
Here is how RSA works:

Alice's public key : e
Alice's private key: d
Message from Bob: m
A large number known to both of Alice and Bob : n

IMG.2 RSA Encryption

In the formula, what Bob send to Alice is me(mod)n. Alice decrypt it with d: (me)d(mod n) ,and get the original message m. I don’t want to show the details or to prove RSA works correctly. If you are interested in it, you may refer to wikipedia. What you are required to know here is how private key and public key interact with each other and get the original message.

RSA can be used as a signature scheme to authenticate that a message is send from a particular part.
Suppose m is a message that Alice wants to send to everybody. How can others assure that the message really come from Alice?

Here is how it works:

IMG.3 RSA Decryption

Alice do not only send m , but also concatenate s = md (mod n) with it. When others receive the message , they check whether se equals m. If it’s true, people will believe that the message really come from Alice. Because Alice is the only person who holds private key d.

Now that you have learned all of the background of blind signature.

Let’s get started!

The blind signature procedure can be categorized into 3 stages: blinding, signing and unblinding as you can find below:

IMG.4 Procedure

The first step is blinding. Assume the voter’s message is M, the private key and public key of election authority is d and e respectively. What the voter needed is a signature from election authority : H(M)d(mod n). The voter randomly choose a number r, then send election authority H(M).re(mod n).

The next step is signing, the election authority check the identity of the voter. If it’s valid for the voter to cast a vote, the election will send back to the voter (H(M).re)d = H(M)d.r (mod n) .

The final step is unblinding. Because voter know r , he can remove r from H(M)d.r (mod n) and finally get H(M)d(mod n). What he can do now is to send M concatenate H(M)d(mod n) to the voting center.

That’s the end of the story.
The most important feature of blind signature is that it protects the privacy of every voters and provide a solid technological foundation for democracy election.