Working Theory

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Introduction:

The Internet Control Message Protocol (ICMP) is one of the core protocols of the Internet Protocol Suite. It is used by network devices, like routers, to send error messages indicating, for example, that a requested service is not available or that a host or router could not be reached. ICMP can also be used to relay query messages. It is assigned protocol number 1. ICMP differs from transport protocols such as TCP and UDP in that it is not typically used to exchange data between systems, nor is it regularly employed by end-user network applications (with the exception of some diagnostic tools like ping and trace route).ICMP for Internet Protocol version 4 (IPv4) is also known as ICMPv4. IPv6 has a similar protocol, ICMPv6. The design and operation of the Internet is based on the Internet Protocol Suite, commonly also called TCP/IP. In this system, hosts and host services are referenced using two components: an address and a port number. Ping is a computer network administration utility used to test the reachability of a host on an Internet Protocol (IP) network and to measure the round-trip time for messages sent from the originating host to a destination computer. The name comes from active sonar terminology which sends a pulse of sound and listens for the echo to detect objects underwater. Working theory: Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP response. In the process it measures the time from transmission to reception (round-trip time) and records any packet loss. The results of the test are printed in the form of a statistical summary of the response packets received, including the minimum, maximum, and the mean round-trip times, and sometimes the standard deviation of the mean. Ping does not evaluate or compute the time to establish the connection; it only gives the mean round-trip times of an established connection with an open session. Depending on the implementation, the ping command can be run with various command line switches to enable special operational modes. Example options include: Specifying the packet size used as the probe, automatic repeated operation for sending a specified count of probes, and time stamping.

Sample ping test


$ ping -n 5 www.example.com PING www.example.com (192.0.43.10) 56(84) bytes of data. 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=1 ttl=250 time=80.5 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=2 ttl=250 time=80.4 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=3 ttl=250 time=80.3 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=4 ttl=250 time=80.3 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=5 ttl=250 time=80.4 ms --- www.example.com ping statistics --5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 80.393/80.444/80.521/0.187 ms

How to use the tool: 1-As shown on Figure 1, once you open the executable file for the tool it will show the gateway address (router) address for our network, to start discovering live host we have to click Monitor which will create a thread and start monitoring.

Figure 1: Discovery tool first screen

2- By clicking monitor as shown on figure 2, newly discovered hosts will be listed under hosts in the network.

Figure 2: newly discovered hosts 3- After done discovering all hosts program will keep on pinging the same IP range and keep updating if found newly live hosts only then it will pop up a message stating the IP address for the live host

Figure 3: Newly discovered hosts message box

Methodology:
Operation theory works as follow

Identify Router (Gateway) ip address

Initialy Ping each and eavery host in the subnet

keep pinging each and every IP/Host and update the live host list

How is Ping related to identify if host is up or down When we ping a host and the host acknowledge receiving the ICMP packets thats indicate that the host is up and running, if packets are lost thats indicate that those packets werent able to be received and host considered down

$ ping 192.168.1.6 PING (192.168.1.6) 56(84) bytes of data. 64 bytes from 192.168.1.6 icmp_seq=1 ttl=250 time=80.5 ms --- www.example.com ping statistics --1 packets transmitted, 1 received, 0% packet loss, time 80.5ms

Codes: Below code will execute the thread responsible for the whole operation
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ListBox1.Items.Clear() If Not (ComboBox1.Text = "") Then trd = New Thread(AddressOf ThreadTask) trd.IsBackground = True trd.Start() End If

End Sub

This is the code for the thread which will do the ping operation and the logic:
Private Sub ThreadTask() Button1.Enabled = False Button3.Enabled = True Do While (1) Dim TestString As String = ComboBox1.Text ' Returns an array containing "Look", "at", and "these!". Dim TestArray() As String = Split(TestString, ".") Dim IPstart As String = TestArray(0) + "." + TestArray(1) + "." + TestArray(2) + "." checkifstill() Try

For i As Integer = 1 To 254 Step 1 Dim nextip As String Dim updown As String nextip = IPstart + i.ToString updown = (pingthis(nextip)) If updown = "1" Then If firsttime = "yes" Then ListBox1.Items.Add(nextip) Else checkifthere(nextip) End If End If Next Catch ex As Exception ' MsgBox("ex @ " + ex.ToString) End Try firsttime = "no" Loop End Sub

A function explicitly built to do the ping operation:


Function pingthis(ByVal thisip As String) Dim status As String If My.Computer.Network.Ping(thisip, 3000) Then status = "1" Else status = "0" End If Return (status) End Function

A form initialization, so it can detect the router IP and clear the list for the connected hosts:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load CheckForIllegalCrossThreadCalls = False ListBox1.Items.Clear() Dim myNetworkAdapters() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces Dim myAdapterProps As IPInterfaceProperties = Nothing Dim myGateways As GatewayIPAddressInformationCollection = Nothing For Each adapter As NetworkInterface In myNetworkAdapters myAdapterProps = adapter.GetIPProperties myGateways = myAdapterProps.GatewayAddresses For Each Gateway As GatewayIPAddressInformation In myGateways If Not Gateway.Address.ToString = "0.0.0.0" Then ComboBox1.Items.Add(Gateway.Address.ToString)

End If Next Next ComboBox1.Text = ComboBox1.Items.Item(0) End Sub

Coding our tool:

We have used visual studio (Visual Basic) as coding environment, code were compiled in framework .NET 3.5 Microsoft Visual studio: is an integrated development environment (IDE) from Microsoft. It is used to develop console and graphical user interface applications along with Windows Forms or WPF applications, web sites, and web applications. Visual basic: Visual Basic .NET (VB.NET) is an object-oriented computer programming language that can be viewed as an evolution of the classic Visual Basic (VB), implemented on the .NET Framework.

Shown on the figure below is the graphical interface for visual basic, where you can find tool box on the left and form where you draw your application components on the middle.

Building Applications in Visual Studio: In Solution Explorer, choose or open the solution. On the menu bar, choose Build, and then choose one of the following commands: Choose Build or Build Solution to compile only those project files and components that have changed since the most recent build. Choose Rebuild Solution to "clean" the solution and then build all project files and components. Or you can click the run button, and you can find the Exe file at (bin/debug/ ) Folder

You might also like