https://github.com/angelcamposm/ping

A Ping package for Laravel

https://github.com/angelcamposm/ping

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary

Keywords

echo-request-datagrams icmp json laravel linux network-tools networking php ping windows
Last synced: 6 months ago · JSON representation

Repository

A Ping package for Laravel

Basic Info
  • Host: GitHub
  • Owner: angelcamposm
  • License: mit
  • Language: PHP
  • Default Branch: master
  • Homepage:
  • Size: 230 KB
Statistics
  • Stars: 56
  • Watchers: 2
  • Forks: 11
  • Open Issues: 4
  • Releases: 6
Topics
echo-request-datagrams icmp json laravel linux network-tools networking php ping windows
Created almost 6 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing Funding License Code of conduct Security

README.md

PING for Laravel

License Latest Stable Version StyleCI Total Downloads

Quality Gate Status Coverage Maintainability Rating Security Rating

This ping class allow making ping request from Laravel applications, it is based on PING command from the linux iputils package.

ping uses the ICMP protocol's mandatory ECHOREQUEST datagram to elicit an ICMP ECHORESPONSE from a host or gateway. ECHO_REQUEST datagrams (pings) have an IP and ICMP header, followed by a struct timeval and then an arbitrary number ofpadbytes used to fill out the packet.

Installation

You can install the package via composer and then publish the assets:

Prior to Ping 2.1.0 version you can install with:

```bash composer require acamposm/ping

php artisan vendor:publish --provider="Acamposm\Ping\PingServiceProvider" ```

From Ping 2.1.0 version you can install with:

```bash composer require acamposm/ping

php artisan ping:install ```

Usage

For basic usage you only need to create with an ip address as a first argument and run...

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

// Create an instance of PingCommand $command = (new PingCommandBuilder('192.168.1.1'));

// Pass the PingCommand instance to Ping and run... $ping = (new Ping($command))->run(); ```

Change Count

Stop after sending count ECHOREQUEST packets. With deadline option, ping waits for count ECHOREPLY packets, until the timeout expires.

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

// Change the number of packets to send to 10 $command = (new PingCommandBuilder('192.168.1.1'))->count(10);

$ping = (new Ping($command))->run(); ```

Change Interval

Wait interval seconds between sending each packet. The default is to wait for one second between each packet normally, or not to wait in flood mode. Only super-user may set interval to values less than 0.2 seconds.

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

// Change interval to 0.5 seconds between each packet $command = (new PingCommandBuilder('192.168.1.1'))->interval(0.5);

$ping = (new Ping($command))->run(); ```

Change Packet Size

Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

// Change packet size to 128 $command = (new PingCommandBuilder('192.168.1.1'))->packetSize(128);

$ping = (new Ping($command))->run(); ```

Change Timeout

Time to wait for a response, in seconds. The option affects only timeout in absence of any responses, otherwise ping waits for two RTTs.

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

// Change timeout to 10 seconds $command = (new PingCommandBuilder('192.168.1.1'))->timeout(10);

$ping = (new Ping($command))->run(); ```

Change Time To Live

ping only. Set the IP Time to Live.

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

// Change Time To Live to 128 $command = (new PingCommandBuilder('192.168.1.1'))->ttl(128);

$ping = (new Ping($command))->run(); ```

Sample outputs

Here you can see three output samples of the ping command... - The first with domain. - The second with an IPv4 Address - The third with an IPv6 Address

Sample output on Windows based server to https://google.com

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

$command = (new PingCommandBuilder('https://google.com'))->count(10)->packetSize(200)->ttl(128);

// Sample output from Windows based server $ping = (new Ping($command))->run();

dd($ping); json { "hoststatus": "Ok", "raw": [ "", "Haciendo ping a google.com [216.58.213.142] con 200 bytes de datos:", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=37ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=37ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "", "Estadísticas de ping para 216.58.213.142:", " Paquetes: enviados = 10, recibidos = 10, perdidos = 0", " (0% perdidos),", "Tiempos aproximados de ida y vuelta en milisegundos:", " Mínimo = 36ms, Máximo = 37ms, Media = 36ms", ], "latency": 0.036, "rtt": { "avg": 0.036, "min": 0.036, "max": 0.037, }, "sequence": { "0": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "1": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "2": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "3": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=37ms TTL=115", "4": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=37ms TTL=115", "5": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "6": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "7": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "8": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", "9": "Respuesta desde 216.58.213.142: bytes=68 (enviados 200) tiempo=36ms TTL=115", }, "statistics": { "packetstransmitted": 10, "packetsreceived": 10, "packetslost": 0, "packetslost": 0, }, "options": { "host": "google.com", "count": 10, "packetsize": 200, "ttl": 120, }, "time": { "start": { "asfloat": 1596984650.5006, "humanreadable": "09-08-2020 14:50:50.500600", }, "stop": { "asfloat": 1596984659.5802, "humanreadable": "09-08-2020 14:50:59.580200", }, "time": 9.08, }, }

```

Sample output from Windows based server to local gateway IPv4

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

$command = (new PingCommandBuilder('192.168.10.254'))->count(10)->packetSize(200)->ttl(120);

$ping = (new Ping($command))->run();

dd($ping); json { "hoststatus": "Ok", "raw": [ "", "Haciendo ping a 192.168.10.254 con 200 bytes de datos:", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "", "Estadísticas de ping para 192.168.10.254:", " Paquetes: enviados = 10, recibidos = 10, perdidos = 0", " (0% perdidos),", "Tiempos aproximados de ida y vuelta en milisegundos:", " Mínimo = 0ms, Máximo = 0ms, Media = 0ms", ], "latency": 0.0, "rtt": { "avg": 0.0, "min": 0.0, "max": 0.0, }, "sequence": { "0": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "1": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "2": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "3": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "4": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "5": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "6": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "7": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "8": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", "9": "Respuesta desde 192.168.10.254: bytes=200 tiempo<1m TTL=255", }, "statistics": { "packetstransmitted": 10, "packetsreceived": 10, "packetslost": 0, "packetslost": 0, }, "options": { "host": "192.168.10.254", "count": 10, "packetsize": 200, "ttl": 120, "version": 4, }, "time": { "start": { "asfloat": 1596985359.7592, "humanreadable": "09-08-2020 15:02:39.759200", }, "stop": { "asfloat": 1596985368.7952, "humanreadable": "09-08-2020 15:02:48.795200", }, "time": 9.036, }, } ```

Sample output from Windows based server to link local IPv6 address

```php use Acamposm\Ping\Ping; use Acamposm\Ping\PingCommandBuilder;

$command = (new PingCommandBuilder('fe80::6c42:407d:af01:9567'))->count(10)->packetSize(200)->ttl(120);

$ping = (new Ping($command))->run();

dd($ping); json { "hoststatus": "Ok", "raw": [ "", "Haciendo ping a fe80::6c42:407d:af01:9567 con 200 bytes de datos:", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "", "Estadísticas de ping para fe80::6c42:407d:af01:9567:", " Paquetes: enviados = 10, recibidos = 10, perdidos = 0", " (0% perdidos),", "Tiempos aproximados de ida y vuelta en milisegundos:", " Mínimo = 0ms, Máximo = 0ms, Media = 0ms", ], "latency": 0.0, "rtt": { "avg": 0.0, "min": 0.0, "max": 0.0, }, "sequence": { "0": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "1": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "2": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "3": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "4": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "5": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "6": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "7": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "8": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", "9": "Respuesta desde fe80::6c42:407d:af01:9567: tiempo<1m", }, "statistics": { "packetstransmitted": 10, "packetsreceived": 10, "packetslost": 0, "packetslost": 0, }, "options": { "host": "fe80::6c42:407d:af01:9567", "count": 10, "packetsize": 200, "ttl": 120, "version": 6, }, "time": { "start": { "asfloat": 1596985675.4344, "humanreadable": "09-08-2020 15:07:55.434400", }, "stop": { "asfloat": 1596985684.4659, "humanreadable": "09-08-2020 15:08:04.465900", }, "time": 9.032, }, } ```

Testing

For running the tests, in the console run:

bash composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Thank you for considering contributing to the improvement of the package. Please see CONTRIBUTING for details.

Security & Vulnerabilities

If you discover any security related issues, please send an e-mail to Angel Campos via angel.campos.m@outlook.com instead of using the issue tracker. All security vulnerabilities will be promptly addressed.

Standards

The php package IPv4 Address Converter, comply with the next standards:

Credits

License

The package Ping is open-source package and is licensed under The MIT License (MIT). Please see License File for more information.

Owner

  • Name: Angel Campos
  • Login: angelcamposm
  • Kind: user
  • Location: Palma de Mallorca, Spain
  • Company: RIU Hotels & Resorts

Long life learner. Programmer sometimes. Father of two.

GitHub Events

Total
  • Issue comment event: 1
  • Push event: 1
  • Pull request event: 2
  • Fork event: 2
Last Year
  • Issue comment event: 1
  • Push event: 1
  • Pull request event: 2
  • Fork event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 200
  • Total Committers: 6
  • Avg Commits per committer: 33.333
  • Development Distribution Score (DDS): 0.28
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
angelcamposm a****m@o****m 144
Angel Campos Muñoz w****o@m****m 47
Sergey Ko u****0@g****m 6
Yif Swery 7****z 1
LiamSystems 5****s 1
Fred Bradley c****e@f****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 14
  • Total pull requests: 20
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 13
  • Total pull request authors: 6
  • Average comments per issue: 3.43
  • Average comments per pull request: 0.45
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • beatific-angel (2)
  • wit3 (1)
  • sts-ryan-holton (1)
  • DaGLiMiOuX (1)
  • iraqhub (1)
  • ryangurn (1)
  • goldjunge4 (1)
  • hendrikbl (1)
  • yswery-reconz (1)
  • ghost (1)
  • hatbil (1)
  • simoebenhida (1)
  • AlexWinder (1)
Pull Request Authors
  • angelcamposm (11)
  • ahoiroman (4)
  • way5 (2)
  • fredbradley (1)
  • yswery-reconz (1)
  • LiamSystems (1)
Top Labels
Issue Labels
bug (2) question (1) enhancement (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • packagist 18,937 total
  • Total dependent packages: 1
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
packagist.org: acamposm/ping

Ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway.

Rankings
Stargazers count: 3.2%
Forks count: 4.7%
Average: 6.9%
Dependent packages count: 9.7%
Downloads: 10.0%
Maintainers (1)
Funding
  • url: https://www.blockchain.com/btc/address/3DWxSQg2HNijAADowkQWFJsDHHpKo8Ec2z: type: custom
Last synced: 6 months ago

Dependencies

composer.json packagist
  • orchestra/testbench ^6.23 development
  • phpunit/phpunit ^9 development
  • php ^8.0
composer.lock packagist
  • 108 dependencies
.github/workflows/main.yml actions
  • SonarSource/sonarcloud-github-action master composite
  • actions/cache v2 composite
  • actions/checkout v2 composite