• Stars
    star
    280
  • Rank 147,492 (Top 3 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created almost 12 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Highly accurate ICMP Ping controller for iOS

GBPing VersionΒ License

Highly accurate ICMP Ping controller for iOS (not based on Apple Sample Code, see "Details" section)

Details

This code is a low level ping library that gives extremely accurate round-trip timing results without being impacted by UI and other processing on the main thread. This is not the case with most other ping libraries such as the typical Apple SimplePing which are built as a single threaded class interleaved within the main thread of execution, causing them to suffer from all kinds of indeterministic errors. This library is a multi-threaded class built on top of BSD sockets and GCD, delivering the best possible timing accuracy regardless of system resource state or device performance.

Usage

First import header

#import <GBPing/GBPing.h>

Basic usage:

self.ping = [[GBPing alloc] init];
self.ping.host = @"google.com";
self.ping.delegate = self;
self.ping.timeout = 1.0;
self.ping.pingPeriod = 0.9;

[self.ping setupWithBlock:^(BOOL success, NSError *error) { //necessary to resolve hostname
    if (success) {
        //start pinging
        [self.ping startPinging];
        
        //stop it after 5 seconds
        [NSTimer scheduledTimerWithTimeInterval:5 repeats:NO withBlock:^{
            NSLog(@"stop it");
            [self.ping stop];
            self.ping = nil;
        }];
    }
    else {
        NSLog(@"failed to start");
    }
}];

Implement optional delegate methods:

-(void)ping:(GBPing *)pinger didReceiveReplyWithSummary:(GBPingSummary *)summary {
    NSLog(@"REPLY>  %@", summary);
}

-(void)ping:(GBPing *)pinger didReceiveUnexpectedReplyWithSummary:(GBPingSummary *)summary {
    NSLog(@"BREPLY> %@", summary);
}

-(void)ping:(GBPing *)pinger didSendPingWithSummary:(GBPingSummary *)summary {
    NSLog(@"SENT>   %@", summary);
}

-(void)ping:(GBPing *)pinger didTimeoutWithSummary:(GBPingSummary *)summary {
    NSLog(@"TIMOUT> %@", summary);
}

-(void)ping:(GBPing *)pinger didFailWithError:(NSError *)error {
    NSLog(@"FAIL>   %@", error);
}

-(void)ping:(GBPing *)pinger didFailToSendPingWithSummary:(GBPingSummary *)summary error:(NSError *)error {
    NSLog(@"FSENT>  %@, %@", summary, error);
}

Demo project

See: github.com/lmirosevic/GBPingDemo

Features

GBPing provides the following info (inside a GBPingSummaryObject exposed as properties):

  • NSUInteger sequenceNumber;
  • NSUInteger payloadSize;
  • NSUInteger ttl;
  • NSString *host;
  • NSDate *sendDate;
  • NSDate *receiveDate;
  • NSTimeInterval rtt;
  • GBPingStatus status;

Dependencies

None

Copyright & License

Copyright 2015 Luka Mirosevic

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

GBDeviceInfo

Detects the hardware, software and display of the current iOS or Mac OS X device at runtime.
Objective-C
1,140
star
2

GBVersionTracking

Track which versions of your iOS or Mac OS X app a user has previously installed, and the whole upgrade cookie crumb trail.
Objective-C
276
star
3

GBToolbox

Goonbee's iOS development toolbox
Objective-C
29
star
4

angular-stateManager

A simple state manager implementation for Angular.js which enables nested views, the browser back button, proper history, and deep linking.
JavaScript
24
star
5

GBAnalytics

Abstracts away different analytics networks and provides a unified simple interface
Objective-C
22
star
6

GBStorage

Simple iOS and Mac OS X persistence layer with in-memory caching, optional persistence, pre-loading, namespacing and a sweet syntax.
Objective-C
19
star
7

GBCardStack

iOS UI paradigm for a stack of sliding cards. Used in VLC iRemote
Objective-C
17
star
8

GBLaunchCounter

Count how many times your iOS or Mac OS X app has been launched, and optionally register blocks for when a certain number of launches has occurred.
Objective-C
11
star
9

GBJailbreakDetection

iOS jailbreak detection framework for GBDeviceInfo
Ruby
10
star
10

GBPingDemo

Demo project for GBPing
Objective-C
9
star
11

GBHUD

Lightweight HUD (heads up display) for quick transient modals in iOS & OSX apps
Objective-C
9
star
12

GBLaunchAtLogin

Add your app as a login item on Mac OS X
Objective-C
9
star
13

LiveDepot

A library for simple file downloading and inventory management for iOS. Including background transfers, mirrors, thumbnails, proper timeouts, persistent deferred retrying, reachability integration, and an elegant blocks based API. It's NSURLSession for download tasks, on lean steroids.
Objective-C
6
star
14

GBLoading

An elegant, lightweight & most importantly robust asynchronous resource loading library for iOS.
Objective-C
6
star
15

GBStickyViews

Allows you to anchor a view onto another view, even if they're across view hierarchies and coordinate spaces.
Objective-C
5
star
16

GBLocation

Wrapper facade for simplifying the Core Motion APIs and exposing a blocks based interface.
Objective-C
5
star
17

GBFeatureManager

Simple iOS and Mac OS X feature manager for unlocking functionality (e.g. for IAP purchases).
Objective-C
5
star
18

GBMotion

Utility library for helping with motion detection, such as orientation, etc.
Objective-C
4
star
19

GBFancyCamera

A blocks based class for taking pictures from the camera or camera roll, with preview and filters. Supports fully customising the UI as well as custom filters.
Objective-C
3
star
20

GBLittleNotification

Little library for showing in-app popups (e.g. for showing push notifications while the app is open, or notifying the user of transient event). Supports fully customisable animations, styling and interactions.
Objective-C
3
star
21

GBAds

Abstracts away different interstitial ad network implementations and implements simple mediation logic for maximising fill rates
Objective-C
2
star
22

GBRetractableTabBar

iOS Control for a retractable tab bar that supports full customisation in terms of sizing, behaviour, and custom views.
Objective-C
2
star
23

GBCloudBoxClient

GBCloudBox is a framework for over-the-air, asynchronous, in-the-background, resource syncing between iOS or Mac OS X apps and a server.
Objective-C
2
star
24

ReverseGeo

A gem for reverse geocoding lat/lng pairs into a 3 letter ISO country code, fully in-memory with no external service access.
Ruby
2
star
25

JRSwizzle-wrapper

Wrapper project for github.com/rentzsch/jrswizzle.git
Objective-C
1
star
26

GBIAP2

Goonbee's In-App Purchases, simplified. Second Edition.
Objective-C
1
star
27

GBThriftApi

A small library to make thrift a little more palatable in Objective-C on iOS and OS X.
Objective-C
1
star
28

Origin-client

iOS client for the Origin service.
C
1
star
29

GBPush

Objective-C client library for Goonbee's push service for iOS. Use this in your iOS apps to register on channels and handle received push notifications.
Objective-C
1
star
30

Origin-interface

Service interface component for the Origin service.
JavaScript
1
star
31

gb-push-client

Service interface library to Goonbee's simple push service. This is the component which you use to send push notifications to your subscribers.
JavaScript
1
star
32

GBNotificationCenter

A clean & elegant block based API for user notifications that uses Lion's native NSUserNotificationCenter on OS X 10.8+ and falls back to Growl for older versions.
Objective-C
1
star