DEV Community

SATO, Yoshiyuki
SATO, Yoshiyuki

Posted on

POng is Not pinG.

I created the pong command in Go language.

See below for a run-time image.

demo

This command was inspired by the existing awesome pong command.

That awesome pong command was created by kurehajime.

GitHub logo kurehajime / pong-command

pong is not ping. pong is CLI game.

pong-command

pong

Pong-command is a CLI game.

POng is Not pinG.

How to use.

1. Download Win/Mac OSX/Linux binary

Download here. Windows,MacOSX,Linux,BSD binary

2. Move file or Add directory to PATH

Mac OSX / Linux :

Copy a file into /usr/local/bin

cp ./pong /usr/local/bin/pong

Windows :

Add directory to PATH Environment Variable

3. pong

Run command.

$./pong <IP Address>

Start game.


                                                                     006 - 000
--------------------------------------------------------------------------------








                                                                      1
                                                                        9   ||
                                                                          2 ||
  ||                                                                      . ||
  ||                                                                    1   ||
  ||                                                                  6
  ||                                                                8
                                                                  .
                                                                1
                                                              .
                                                            1


--------------------------------------------------------------------------------
EXIT : ESC KEY


... or install by 'go install'

go install github.com/kurehajime/pong-command/pong@latest
Enter fullscreen mode Exit fullscreen mode

LICENSE

This software is released under the MIT License, see LICENSE.txt.




In this pong command, the target hostname you enter will take the place of the ball.

Sounds like a great idea, doesn't it?

The key types for pong and ping are similar (O and I next to each other in QWERTY).
Therefore, I feel that it is similar to the key type correction effect of the sl command for the ls command.

If you thought the above article and command ideas were great, I encourage you to star the repository before reading the rest of the text.

When I saw this command, I thought, "Great idea."
However, at the same time, I thought, "Is there another possibility?"

So let's start by looking at the pong game and the ping command.

What is pong game?

It is a game like so-called table tennis (ping pong).
Various pong games have been created since recorded history.

Pong is a table tennis–themed twitch arcade sports video game, featuring simple two-dimensional graphics, manufactured by Atari and originally released in 1972. It was one of the earliest arcade video games; it was created by Allan Alcorn as a training exercise assigned to him by Atari co-founder Nolan Bushnell, but Bushnell and Atari co-founder Ted Dabney were surprised by the quality of Alcorn's work and decided to manufacture the game. Bushnell based the game's concept on an electronic ping-pong game included in the Magnavox Odyssey, the first home video game console. In response, Magnavox later sued Atari for patent infringement.

It is common for two players to play against each other, or for users against computers.
There are paddles (or racquets) on the left and right (or top and bottom) of the screen, and players operate the paddles to hit the ball.

I think it is no exaggeration to say that it is probably the beginning of e-sports.

What is the ping command?

The ping command is a command that checks whether there is a response from a device with a specific IP address on the IP network.

The ping command is usually executed by specifying the target host (IP address or hostname).

The executed ping command will send an ICMP protocol echo request packet towards the target.
When the target host receives an ICMP echo request packet, it returns an echo reply packet to the source (some hosts do not respond due to settings, etc.).

If the target host is not on the same network, the gateway between networks will relay the echo request/reply packets. At that time, the TTL (Time To Live) value in the packet is decremented by 1, and if the result of the decrement is 0, the packet is not relayed and discarded.

The ping command records network reachability, response time, etc. by receiving or not returning an ICMP echo reply from the target host.

Depending on the execution environment and option specification, it sends and receives ICMP echo packets for a specified number of times or until the user stops (such as CTRL+C), and finally reports the result.

ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network. It is available for virtually all operating systems that have networking capability, including most embedded network administration software.

I created the pong command.

After examining the similarities and differences between the pong game and the ping command, I created the pong command.

demo

When you run the pong command with a target host, the local host (on the far left of the screen) will send an ICMP ECHO packet.

On the target host (the paddle you control on the right), take the incoming ICMP ECHO packets and send them back to the host that sent them (the localhost on the far left).

However, the Gateway (the paddle on the left side of the screen, operated by the computer) in between, for whatever reason, always sends it back to the target host when it receives an ICMP ECHO packet.
So you need to send an ICMP ECHO packet back to the localhost while avoiding the Gateway.
When the Gateway sends back, the TTL is decremented, so send it back before the TTL runs out (by default the TTL starts from 64).

Also, if you send back many times, the network speed will gradually increase. be careful.

By default, the local host will send ICMP ECHO packets 4 times.
After the last packet has been received (or lost), or if the user has stopped, display packet response state statistics up to that point.

The starting method of this pong command is as follows.

pong [options] <destination>
Enter fullscreen mode Exit fullscreen mode

The following can be specified as options.

Application Options:
  -h, --help                 print help and exit
  -v, --version              print version and exit
  -c, --count=<count>        stop after <count> replies (default: 4)
  -t, --ttl=<ttl>            define time to live (default: 64)
  -p, --padding=<pattern>    contents of padding byte

Arguments:
  <destination>:             dns name or ip address
Enter fullscreen mode Exit fullscreen mode

The source code is on GitHub.

Pong-is-not-Ping

This command is pong game.

POng is Not pinG.

Inspired by kurehajime/pong-command

Installation

go install github.com/yoshi389111/pong-is-not-ping/cmd/pong@latest

Usage

Usage:

  pong [options] <destination>

Options:

Application Options:
  -h, --help                 print help and exit
  -v, --version              print version and exit
  -c, --count=<count>        stop after <count> replies (default: 4)
  -t, --ttl=<ttl>            define time to live (default: 64)
  -p, --padding=<pattern>    contents of padding byte

Arguments:
  <destination>:             dns name or ip address

Copyright and License

(C) 2022 SATO, Yoshiyuki

This software is released under the MIT License.

The Japanese version of this article is below.

Top comments (0)