Skip to content

Commit

Permalink
iOS Ping functionality (#602)
Browse files Browse the repository at this point in the history
* Added ping button and rearranged traceroute button

* Progress on ping. Refactored some traceroute ui config to be reusued.

* Started working on adding the ping locations view

* Progress on ping functionality

* Automatically start ping after selection

* Cleanup

* Improve delegate method name

* Remove target-specific deployment target and update project deployment target

* Update credits.html

* Remove unnecessary availability check and remove some unnecessary frame calculations

* Remove CarPlay, Mac, and Apple Watch icon entries

* Expose immutable array of packet records
  • Loading branch information
robmaceachern authored Feb 27, 2019
1 parent a91ae84 commit d49d746
Show file tree
Hide file tree
Showing 20 changed files with 574 additions and 255 deletions.
2 changes: 1 addition & 1 deletion Common/Data/credits.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>Map of the Internet by Cogeco Peer 1</h1>
<p><b>Design</b>: Steamclock Software and Cogeco Peer 1.</p>
<p><b>Development</b>: Steamclock Software.</p>
<p><b>Data</b>: CAIDA and Jeff Johnston.</p>
<p><b>Dev Team:</b> Nigel Brooke, Justin Alm, Chani Armitage, Alexander von Franqu&eacute;, Angelina Fabbro, Shayla Sawchenko, Jot Kali, and Allen Pike.</p>
<p><b>Dev Team:</b> Nigel Brooke, Justin Alm, Chani Armitage, Alexander von Franqu&eacute;, Angelina Fabbro, Shayla Sawchenko, Jot Kali, Robert MacEachern, and Allen Pike.</p>
<p><b>Special thanks to conributors</b> Kyle Dickau, Victor Swarovski, Skyler Richter, and Rajan Sodhi.
<p><b>Special thanks to open source projects</b>: MBProgressHUD, vectormath, TTTAttributedLabel, Boost, jsoncpp, ASIHTTPRequest, ipify.org, and iptoasn.com.</p>
<p>Map of Internet includes GeoLite2 data created by MaxMind, available from maxmind.com</a></p>
Expand Down
18 changes: 10 additions & 8 deletions External Code/SCPinions/SCPacketUtility/SCIcmpPacketUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

@protocol SCIcmpPacketUtilityDelegate;

@class SCPacketRecord;

@interface SCIcmpPacketUtility : NSObject
{
NSData* _targetAddress;
Expand All @@ -57,7 +59,7 @@
@property (nonatomic, copy, readonly) NSData* targetAddress;
@property (nonatomic, copy, readwrite) NSString* targetAddressString;
@property (nonatomic, assign, readonly) uint16_t nextSequenceNumber;
@property (strong, nonatomic, readonly) NSMutableArray* packetRecords;
@property (strong, nonatomic, readonly, nonnull) NSArray<SCPacketRecord *>* packetRecords;

+ (SCIcmpPacketUtility*)utilityWithHostAddress:(NSString*)hostAddress; // contains (struct sockaddr) - should have this take IP string, then convert to struct sockaddr

Expand All @@ -67,7 +69,7 @@
- (void)start;
// Starts the packet utility object doing it's thing. You should call this after you've setup the delegate.

- (void)sendPacketWithData:(NSData *)data andTTL:(int)ttl;
- (void)sendPacketWithData:(NSData *)data andTTL:(NSInteger)ttl;
// Sends an ICMP packet. Do not try to send a packet before you receive the -SCIcmpPacketUtility:didStartWithAddress: delegate callback.

- (void)stop;
Expand All @@ -80,27 +82,27 @@

@optional

/// Called after the SCIcmpPacketUtility has successfully started up. After this callback, you can start sending packets via -sendPacketWithData:
- (void)SCIcmpPacketUtility:(SCIcmpPacketUtility*)packetUtility didStartWithAddress:(NSData *)address;
// Called after the SCIcmpPacketUtility has successfully started up. After this callback, you can start sending packets via -sendPacketWithData:

/// If this is called, the SCIcmpPacketUtility object has failed. By the time this callback is called, the object has stopped (that is, you don't need to call -stop yourself).
- (void)SCIcmpPacketUtility:(SCIcmpPacketUtility*)packetUtility didFailWithError:(NSError *)error;
// If this is called, the SCIcmpPacketUtility object has failed. By the time this callback is called, the object has stopped (that is, you don't need to call -stop yourself).

// IMPORTANT: On the send side the packet does not include an IP header.
// On the receive side, it does. In that case, use +[SCIcmpPacketUtility icmpInPacket:]
// to find the ICMP header within the packet.

/// Called whenever the SCIcmpPacketUtility object has successfully sent a packet.
- (void)SCIcmpPacketUtility:(SCIcmpPacketUtility*)packetUtility didSendPacket:(NSData *)packet;
// Called whenever the SCIcmpPacketUtility object has successfully sent a packet.

/// Called whenever the SCIcmpPacketUtility object tries and fails to send a packet.
- (void)SCIcmpPacketUtility:(SCIcmpPacketUtility*)packetUtility didFailToSendPacket:(NSData *)packet error:(NSError *)error;
// Called whenever the SCIcmpPacketUtility object tries and fails to send a packet.

/// Called whenever the SCIcmpPacketUtility object receives an ICMP packet that looks like a response to one of our packets
- (void)SCIcmpPacketUtility:(SCIcmpPacketUtility*)packetUtility didReceiveResponsePacket:(NSData *)packet arrivedAt:(NSDate*)dateTime;
// Called whenever the SCIcmpPacketUtility object receives an ICMP packet that looks like a response to one of our packets

/// Called whenever the SCIcmpPacketUtility object receives an ICMP packet that does not look like a response to one of our packets.
- (void)SCIcmpPacketUtility:(SCIcmpPacketUtility*)packetUtility didReceiveUnexpectedPacket:(NSData *)packet;
// Called whenever the SCIcmpPacketUtility object receives an ICMP packet that does not look like a response to one of our packets.

@end

13 changes: 9 additions & 4 deletions External Code/SCPinions/SCPacketUtility/SCIcmpPacketUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ @interface SCIcmpPacketUtility ()

@property (nonatomic, copy, readwrite) NSData* targetAddress;
@property (nonatomic, assign, readwrite) uint16_t nextSequenceNumber;
@property (strong, nonatomic, nonnull) NSMutableArray<SCPacketRecord *>* packetRecordsInternal;

@end

Expand Down Expand Up @@ -146,11 +147,15 @@ - (id)initWithAddress:(NSString*)hostAddress
if (self != nil) {
self->_targetAddressString = [hostAddress copy];
self->_targetAddress = hostAddressData;
self->_packetRecords = [[NSMutableArray alloc] init];
self.packetRecordsInternal = [[NSMutableArray alloc] init];
}
return self;
}

- (NSArray<SCPacketRecord *>*)packetRecords {
return [self.packetRecordsInternal copy];
}

- (NSData*)_formatAddress:(NSString*)address{
const char *ipstring = [address UTF8String];
struct sockaddr_in ip;
Expand Down Expand Up @@ -243,7 +248,7 @@ - (void)stop
#pragma mark - Packet sending


-(void)sendPacketWithData:(NSData *)data andTTL:(int)ttl{
-(void)sendPacketWithData:(NSData *)data andTTL:(NSInteger)ttl {

int err;
NSData * payload;
Expand Down Expand Up @@ -315,8 +320,8 @@ -(void)sendPacketWithData:(NSData *)data andTTL:(int)ttl{
packetRecord.sentWithTTL = ttl;
packetRecord.sequenceNumber = self.nextSequenceNumber;
packetRecord.departure = now;
[self.packetRecords addObject:packetRecord];

[self.packetRecordsInternal addObject:packetRecord];
}
}

Expand Down
2 changes: 1 addition & 1 deletion External Code/SCPinions/SCPacketUtility/SCPacketRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@interface SCPacketRecord : NSObject

@property uint16_t sequenceNumber; //A sequence number for tracking of packet relationships as we perform network operations
@property int sentWithTTL; // The TTL that our original packet has assigned to it
@property NSInteger sentWithTTL; // The TTL that our original packet has assigned to it
@property NSString* responseAddress; //The address of the machine that sent us a respponse packet for this sequence number
@property NSDate* departure; // Departure time of packet sent for this sequence number
@property NSDate* arrival; // Arrive of response packet for this sequence number
Expand Down
117 changes: 0 additions & 117 deletions Internet Map/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,123 +103,6 @@
"idiom" : "ios-marketing",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "60x60",
"idiom" : "car",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "car",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"size" : "24x24",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "38mm"
},
{
"size" : "27.5x27.5",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "42mm"
},
{
"size" : "29x29",
"idiom" : "watch",
"filename" : "[email protected]",
"role" : "companionSettings",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "watch",
"role" : "companionSettings",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "watch",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "38mm"
},
{
"size" : "86x86",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "38mm"
},
{
"size" : "98x98",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "42mm"
},
{
"idiom" : "watch-marketing",
"size" : "1024x1024",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit d49d746

Please sign in to comment.