This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.
Implementation, testing and justification
The implementation of the tool provided a solid ground on which to visualise the finished artefact. Hands on interaction with the creation of the system enabled me to realise what was possible and, of course, what was not. Therefore during the implementation of the tool many problems became apparent.
Also whilst creating the artefact I had to overcome some novel and weird problems which required hours of research and trying different things.
1. Code features
Creating this system both challenged and expanded my knowledge of the .NET framework and in particular the C# programming language. Previous education in networking and the protocols used by modern networks have proved very useful and throughout the artefact marrying these two areas together has produced powerful results.
To access networking functions the System.Net namespace was used. According to Microsoft Corporation (2008):
“The System.Net namespace provides a simple programming interface for many of the protocols used on networks today. An implementation of network services that enables you to develop applications that use Internet resources without worrying about the specific details of the individual protocols”
Using this namespace I am able to bridge the gap between applications and the networks they rely on to provide a fully featured, rich application which enables users to understand and troubleshoot their own networks.
To walk the reader through specific features of the artefact I have compiled a list (in no particular order) of each providing details on its purpose, merit, and how it has been implemented.
1.1 Splash Screen
|What it does||Pauses the current thread whilst displaying the splash screen|
This section of the code uses multithreading to display the splash screen to the user. Multithreading is the process of enabling a CPU to switch betweeen different processing tasks. This may be used in a situation where information is not yet available (from cache or elsewhere) for a task to execute so instead of the CPU idling it can switch to another pending task.
In this case the previous task (loading the Main form) is intentionally paused. Giving time for the splash screen to execute and (after a predetermined time) self terminate.
It does this through pausing the current thread (the one started when the program was executed) and displays the splash screen whilst paused. After a predetermined time (3000 milliseconds) the thread is started again.
Through doing this I have created a splash screen which shows before the program is fully loaded.
1.2 Get MAC Addresses
|What it does||Obtains the MAC addresses of every installed network adapter|
|Merit||Creates an object for each network adapter (containing the name and MAC address of each adapter) and returns an array of these objects to the Main form|
This section uses the NetworkInterface class of the System.Net namespace. This class allows the application to obtain the name and MAC address of each installed network adapter. The code loops through each adapter installed and creates a new object (instantiation) of the Interface.cs class to contain the name and MAC of the adapter, before adding it to an array:
The array (containing all the interface objects) it returned to the main form to be placed in the menu (at the bottom) for the user to view.
This block retrieves the network adapters, stores their MAC address and name in an object, and returns the object(s) to the Main form.
As you can see below, Interfaces.cs is simply used as a storage medium to keep each network adapter name and its corresponding MAC address together. It consists of a constructor, and getter methods to retrieve the values back at a later date.
This section on the main form iterates through the array returned from Interfaces.cs and adds them to the MAC address menu at the bottom. In addition it creates an event handler on-the-fly to allow the user to click a MAC address and be directed to the keywords section for explanation.
1.3 Network Diagnosis
|What it does||Constructs a series of sentences based on the current network situation and connectivity issues|
|How its clever||Imports a windows dll combined with a multitude of functions to determine details about the network|
This is achieved through a series of different tests performed on the host system and its relationship with the network(s) it is connected to.
Functionality provided here mainly relies on the import of the Windows file; wininet.dll. Like all DLL's this provides shared functions which various applications can access. In this case functions relating to the internet. Since wininet.dll is integral to most versions of the Windows operating system the importation of this file into my application provides an almost guaranteed access to powerful information about the current system configuration.
Wininet.dll is imported first by referencing the System.Runtime.InteropServices namespace and using the following lines of code:
The first line gives my application access to wininet.dll whilst the second provides access to its features through using a reference to the connection state.
Now we have the connection state (which is returned in hexadecimal format) - we simply need to figure out what it means. This is done by using an enum:
An enum is simply a list of the possible connection states (in hexadecimal) and its human readable counterpart. For example 0x40 is translated to INTERNET_CONNECTION_CONFIGURED.
The returned connection description is then associated with a sentence:
For example the above sends the main form the connection state “INTERNET_CONNECTION_LAN” which is converted into the sentence “You use a LAN to connect to the internet”.
The next section uses wininet.dll to report on the current connection state which is again converted to a sentence. A false is converted to “Your computer is reporting that there are no physical connections available to connect” and a true converts to “Your computer is reporting that a valid internet connection exists”
The final section sends a ping (section 1.4) to a predetermined website (in this case www.google.co.uk) and registers whether a reply is received. A successful ping gets converted to: “Your internet connection is working fine” and an unsuccessful ping is converted to: “However there seems to be a problem with your internet connection”.
To concatenate these sentences together a StringBuilder was used. This enables me to construct strings during runtime to make sentences. So as the tests above were completing string was being progressively built.
When all tests were completed the resulting string was sent to screen:
1.4 Sending a Ping
|What it does||Test host accessibility across a network|
|How its clever||Can be done programmatically negating the need for command line execution|
Ping has long been used by network administrators to test the accessibility of hosts across an IP network. To perform a ping it is usually initialised from the command line to a determined IP address to discover if the path between the local host and the destination is clear.
However the implementation in the Network Support Tool has a slightly different use for this method. In this implementation the host will send a ping packet to a well known/reliable web server (in this case Google) and (providing a reply is received) the assumption is made that a valid internet connection exists.
To provide ping functionality the class Ping.cs was specifically written. The class references the System.Net namespace and calls the Ping class within it:
1.5 Obtaining External IP Address
|What it does||Obtains the IP Address of the external interface of the wireless router|
|How its clever||Uses regular expressions to parse the HTML of a web page displaying the external IP Address|
The external IP Address is the address used by external entities (such as those over the internet) to address your network. A valid external IP address is integral to provide any internet services. Therefore any problems obtaining a valid external IP address can indicate a problem to the end user.
The external IP address itself is not stored anywhere on the host system so usually if you wished to find out your external IP you would either access your router settings, or access a website such as www.whatismyip.com which will report your external IP back to you.
To provide a universal and automatic system the web access was be employed.
Retrieving a webpage through code is rather easy. This was done using a WebClient object and stores all the returned HTML into a UTF8Encoding object. Once the HTML has been obtained (containing the hosts external IP Address) a regular expression is used to parse the code and retrieve the external IP Address.
1. 6 Obtaining host IP address
|What it does||Obtains the IP Address of the host as used within a network|
|How its clever||Uses System.Net namespace to obtain it|
The System.Net namespace provides another useful feature within its Dns class which provides simple domain name resolution. To use this to obtain an IP address the Dns class must first be used to obtain the hostname of the current computer. Once a hostname is known a DNS lookup can be performed, resulting in the IP.
Automated extra information
In the keywords section of the Network Support Tool I designed for there to be a link for the end user to provide more information on that particular problem.
2. Problems during implementation
I have not included minor problems such as those typical to programming (missed semi-colon or using a method like a property etc) but instead have concentrated on problems that required research, forum posts, and an all round programmatically logical mind.
Here is a list of the problems experienced during development, the reason why, and how I solved the problem
Class RouterSettings.cs< table style ='border-collapse:collapse;'>
Problem Scenario: Router access not available
What happened: When (for whatever reason) access to the routers settings through a web browser was not possible the web browser returned an error 404 (Page Not Found). This posed a puzzling problem as I wanted to catch the error 404 within my application to warn the user the router config settings were not accessible. To get around this I added a WebBrowser control (available as part of .NET) to a form and instructed that to access the router.
However the WebBrowser control was not returning an error 404 where it was due. To find the error that it was returning I used a message box and discovered that in fact the error it was returning was a HRESULT code (very long number). I then tested for this number within the code, and now the application can successfully detect error 404's from the web browser. Additional help for this problem was found at http://vbcity.com/forums/topic.asp?tid=129166
In addition to error 404 I took it into my liberty to provide extra error codes which may occur such as 503 (Service Unavailable) and tested for the HRESULT code of each.
Problem scenario: Ping was failing and returning an error
What happened: When attempting to ping a service on the internet (The Google Search Engine) the ping kept timing out and failing, even though I was able to manually check there was a valid internet connection.
Initially I increased the ping timeout value however the problem still existed.
After much research the problem was attributed to my firewall. It was blocking echo reply (Ping) packets so the application was not receiving the packets returned from Google - hence the timeout. This was simply fixed by changing settings on the firewall to let them through and the problem was fixed. The message board at http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=57892 helped.
Problem Scenario: Attempted to ping web services in an effort to determine whether internet access was possible
What happened: In an attempt to ping some websites to determine internet connectivity I used the full URL of the website (including the HTTP:// prefix). This was preventing the ping class finding the host. In order to solve this I opened the windows command line and tested Ping within that. I discovered that with the HTTP:// prefix an error occurred, however if I included the URL without the prefix a successful ping ensued.
Problem Scenario: Retrieving the external IP address of the local machine was throwing an exception.
What happened: In order to get the IP address of the local machine (as others see it from over the internet) I needed to access an external entity which would be used to return the IP address as the local computer appears to it. This was achieved using regular expressions (see Design for a feasible Solution). To gain the external IP address the application contacted an online service (http://myip.dk/) and used regular expressions to retrieve the IP address from the title of the returned page. However an exception was being thrown. I manually checked the HTML code of compared that to the regular expression I was using to search for it. The problem occurred because I was search for the lower case title tag (<title></title>) whereas the code being returned was in uppercase (<TITLE></TITLE>) therefore causing an error. This was simply fixed by changing the case in the code.
|Web Browser was returning error 404 (could not find the file)||The Application.StartupPath property of the application provides the path of the executable file that started the application||Files are located irrespective of the applications actual path|
Problem Scenario: The Web Browser Control could find the HTML files I had created
What happened: The URL for the Web Browser control had to be absolute (i.e. the full filepath) instead of relative (where the file is in relation to the application). This wasn't causing many problems except for portability problems. I got around this by using Application.StartupPath which equates to the execution directory of the application. This allows the application to be fully portable.
Something like this?
|Class.cs||Web Browser Control could find the HTML files I had created|
Testing is an integral part of any software development process and is usually performed in stages. Throughout the development tests are carried out in conjunction with the software creation by the programmer to ensure obvious errors such as compilation errors and other obvious errors are rectified. This process ensures a piece of software is valid however it may not produce the correct results in all environments.
Following that testing is carried out on the system as a whole - to ensure the results it produces are accurate and verified as correct. This may mean that during this stage the development process may need to be re-entered for rectification.
Testing of this system was carried out through testing each separate function (in tern), verifying the results, and commenting on the success or failure. In addition each test was also carried out on a number of different computers which are independent of each other (not networked). This should provide a thorough testing procedure and guarantee a stable artefact.
|Feature||Expected outcome||PC 1||PC2||PC 3|
|Address information||Default gateway||Correct and verified through ipconfig||Correct|
|Clicking opens the keywords section displaying information on default gateway||Correct|
|MAC Addresses||Correct and verified through ipconfig||Correct|
|Clicking opens keywords section displaying information on MAC address||Correct|
|External IP address||Correct and verified through www.whatismyip.com||Correct|
|Clicking opens keywords section displaying information on IP address||Correct|
|Internal IP address||Correct and verified through ipconfig||Correct|
|Clicking opens keywords section displaying information on IP address||Correct|
|Router settings||Window open with access to the router settings||Correct|
|Preferences||Preferences saved and viewable elsewhere in the application||Correct|
|About||About box shown||Correct|
|Network Diagnosis||Diagnosis correct and verified through checking internet connectivity and network topology||Correct|
|Key Words||Selection||Choosing a key word from the selection results in the information being shown||Correct|
|More information||Opens the website of the users choice (as set in preferences)||Correct|
|When a key word has been selected the preferred website is searched||Correct|
|Browser||A clicked link in the key words browser opens that keyword||Partial fail|
|Lost Connectivity||All information imported from their respective rich text format||Correct|
|Step 1||Animation shown correctly||Correct|
|Step 2||Image of network devices shown||Correct|
|When hover over network devices full image shown||Fail|
|Step 3||Network states shown with information||Correct|
|Step 4||Windows media player loaded||Correct|
|Click on media plays animation full screen||Correct|
|Play, pause, sound fully active||Correct|
|Step 5||Configuration correct and confirmed with main screen and ipconfig||Correct|
|Step 6||Text loaded with links||Correct|
|Links open default browser||Correct|
Microsoft Corporation., 2008. System.Net Namespace (). [Online]. Microsoft Corporation. Available at: http://msdn2.microsoft.com/en-us/library/system.net.aspx [accessed 27 March 2008]