Monday, 24 October 2016

Basic Commands for Troubleshooting network connectivity

IPCONFIG Command


ipconfig
Is used to find out your current TCP/IP settings. With IPCONFIG you can find out your IP Address, find your Default Gateway and find your Subnet Mask. This is a very handy network tool for finding your local IP address.

ipconfig /all
To display all your IP information for all adapters. With ipconfig /all you can also find out your DNS Server and MAC Address. This will show your full TCP/IP configuration for all adapters on your Windows machine. You can find out your own IP Address as well as your default gateway.

ipconfig /release
To release your current IP information and obtain a new IP Address from the DHCP server.

ipconfig /renew
Used to renew your IP Address if you have it set to obtain IP Address automatically.

ipconfig /displaydns
This shows your current DNS Resolver Cache Logs.

ipconfig /flushdns
The Flush DNS Command flushes or clears your current DNS Resolver Cache Logs.

ipconfig /registerdns
The register DNS command updates the DNS settings on the Windows computer. It doesn’t just access the local DNS cache, it initiates communication with the DNS server and the DHCP server so it can re-register the network address. You can use this for troubleshooting problems with connection to the ISP (Internet Service Provider), like failing to obtain a dynamic IP address from the DHCP Server or failing to connect to the ISP DNS server.

If you ever wonder "what your IP Address is" you would run an ipconfig as shown above. If you need to find your IP address, default gateway(router login) or subnet mask ip config is the tool to use. These numbers can be very helpful when trouble shooting your local network connection. If you have changed your settings but they are not taking place you may try a ipconfig release and renew. If you’re having problems resolving to a website you may try flushing your DNS Resolver Logs.
PING Command

In all of these examples “xxx.xxx.xxx.xxx” is an example of a Domain Name or an IP Address. You must fill those out yourself.

ping xxx.xxx.xxx.xxx
To Ping an IP Address you would type the following DOS Command in the Windows Command Prompt. Ping followed by an IP address. That is how you do an internet ping.

ping site.com (web address)
To ping a website you would type ping followed by the website domain name. If you know the websites IP Address you can ping it too.
Ping Command Switches

You maybe use the switches together.
ping xxx.xxx.xx.xx -t
Continuous Ping – It will keep on pinging forever until you hit Ctrl + C to stop it. This can be great for troubleshooting intermittent connections. Just open up a Command Prompt(or 3) and run the continuous ping command on a site like Google.com to see when you’re dropping packets. I would also run one on your router and on another site like site.com for a better data sample control group. What I mean by this, is if you’re pinging your website and losing packets yet not losing packets to Google, you know the problem is somewhere between you and your hosting company. If you are losing packets to your own router, the problem is with your local network. It could be the cat5 cable, your router or your hardware. You will have to do further troubleshooting to figure out where the problem is. To check if it is your router, do the same ping from another computer and if it is fine, it is your hardware or cable and not the router. You get the idea, use your head, be logical, troubleshoot.

ping xxx.xxx.xx.xx -n 10
Number of Pings – The N Switch is simply for setting the number of pings. By default the ping cmd sends out 4 packets at 32 bytes each.

ping xxx.xxx.xx.xx -l 1500
Size of Packet – By default the packets sent are a small 32 bytes. You can set your own size up to the max 65500 bytes. This can really help for stress testing your local network.

ping xxx.xxx.xx.xx -w 5000
Time Out – This is in milliseconds. The timeout by default is 4,000 milliseconds which amounts to 4 minutes. Just seeing if you were still paying attention. It really is only 4 seconds.

ping -a xxx.xxx.xx.xx
Resolves Hostname Address – This is a great one if you are helping someone else and need to find out what router model they are using. You an resolve the host of an IP Address with this command. Try pinging your router or your local computer with it. ping -a 127.0.0.1. Note that this switch will only work in front of the IP Address.
Ping Command Summary

The Ping command is a network tool used to determine if you are able to send packets between your network computer on the internet to another computer without losing packets along the way. By doing this you can determine if you’re online or if a website is down. It also calculates round trip time and Time to Live. This can let you know if your NIC card is working properly and if you’re able to reach your router or modem. It is an invaluable command for troubleshooting internal network and external internet connections.
Networking Basics Command Prompt

tracert site.com
With Trace route you can trace the path your packets take across the internet from you to your destination. Along the way you can determine the time from hop to hop. You can identify server problems and latency with this tool. It really helps see where the failure is between you and a destination. It may very well even be out of your hands.

nslookup site.com
nslookup xxx.xxx.xxx.xxx
nslookup is a way to get the IP address for a domain name. You can also do a reverse lookup from Domain Name to IP Address. It can be a way to find out if your DNS is properly working or if the site is having problems. You can obtain an IP from a site and try to visit the IP directly, bypassing the Domain Name Servers that would usually resolve the Domain name to IP name.

netstat
netstat can be used to view your active network connections and TCP/IP connections. You can determine what ports are open and being used, what programs are using your ports and what kind of TCP and UDP connections are present. Looking in here for the first time may scare the hell out of you.

netstat Switches
netstat -a Displays all active TCP connections. And TCP / UDP ports.
netstat -e Displays ethernet statistics.
netstat -b Displays all active programs that are listening.

netsh winsock reset winsock reset
netsh int ip reset resetlog.txt TCP/IP reset
netsh is used to reset or rebuild the Windows TCP/IP IP Stack. This can be done if you have a problem with DNS. Say you are able to browse to a sites IP address but not to it’s Domain Name. You can find the sites IP by using nslookup mentioned above.
You may need to run this command as an administrator by right clicking, run as admin for elevated permissions.

getmac
How do I find my MAC Address you might ask?
If you open up the command prompt you simply type getmac to get your computers local MAC address.

arp -a
To get the MAC address of your router or other devices on your local network, you may use the arp -a command. With this information, you can find out what type of router you are connected to by using this website. Simply plug in the MAC Address of your default gateway(found from IPCONFIG) and you can get the brand name of your router without looking at it. Pretty neat. Helpful in some situations.


jMeter Tutorial



jMeter is an Open Source testing software. It is 100% pure Java application for load and performance testing. jMeter is designed to cover categories of tests like load, functional, performance, regression, etc., and it requires JDK 5 or higher. This tutorial will give you great understanding on jMeter framework needed to test an enterprise level application to deliver it with robustness and reliability.

Writing a Test Plan

Follow the steps given below to write a test plan −

Step 1 − Start the JMeter Window

Open the JMeter window by clicking /home/manisha/apache-jmeter-2.9/bin/jmeter.sh. The JMeter window will appear as below −
JMeter GUI
This is a plain and blank JMeter window without any additional elements added to it. It contains two nodes −
  • Test Plan node − is where the real test plan is kept.
  • Workbench node − It simply provides a place to temporarily store test elements while not in use, for copy/paste purposes. When you save your test plan, Workbench items are not saved with it.

Step 2 − Add/Remove Elements

Elements (which will be discussed in the next chapter Test Plan Elements) can be added to a test plan by right-clicking on the Test Plan node and choosing a new element from the "add" list.
Alternatively, you can load an element from a file and add it by choosing the "merge" or "open" option.
For example, let us add a Thread Group element to a Test Plan as shown below −
Add Thread Group
To remove an element, make sure the element is selected, right-click on the element, and choose the "remove" option.
Remove Element

Step 3 − Load and Save the Elements

To load an element from file −
  • Right-click on the existing tree element to which you want to add the loaded element.
  • Select Merge.
  • Choose the file where you saved the elements.
  • JMeter will merge the elements into the tree.
By default, JMeter does not save the element, you need to explicitly save it.
Load Element
To save tree elements −
  • Right-click on the element.
  • Choose the Save Selection As ... option.
JMeter will save the element selected, plus all the child elements beneath it. By default, JMeter doesn't save the elements, you need to explicitly save it as mentioned earlier.

Step 4 − Configuring the Tree Elements

Any element in the Test Plan can be configured using the controls present in JMeter's right-hand side frame. These controls allow you to configure the behavior of that particular test element. For example, the Thread Group can be configured for a number of users, ramp up periods, etc., as shown below −
Add Thread Group

Step 5 − Saving the Test Plan

You can save an entire Test Plan by using either Save or "Save Test Plan As ..." from the File menu.
Save Test Plan

Step 6 − Run the Test Plan

You can run the Test Plan by clicking Start(Control + r) from the Run menu item. When JMeter starts running, it shows a small green box at the right-hand end of the section just under the menubar.
Run Test Plan
The numbers to the left of the green box are the number of active threads / total number of threads. These only apply to a locally run test; they do not include any threads started on remote systems when using client-server mode.

Step 7 − Stop the Test Plan

You can stop your test in two ways −
  • Using Stop (Control + '.'). It stops the threads immediately if possible.
  • Using Shutdown (Control + ','). It requests the threads to stop at the end of any current work.


Create Webservice Project

To create a webservice project, we have used Eclipse IDE. First write the Service Endpoint Interface HelloWorld under the packagecom.tutorialspoint.ws. The contents of the HelloWorld.java are as follows −
package com.tutorialspoint.ws;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)

public interface HelloWorld{

   @WebMethod String getHelloWorldMessage(String string);

}
This service has a method getHelloWorldMessage which takes a String parameter.
Next, create the implementation class HelloWorldImpl.java under the package com.tutorialspoint.ws.
package com.tutorialspoint.ws;

import javax.jws.WebService;

@WebService(endpointInterface="com.tutorialspoint.ws.HelloWorld")
public class HelloWorldImpl  implements HelloWorld  {
   @Override
 
   public String getHelloWorldMessage(String myName){
      return("Hello "+myName+" to JAX WS world");
   }
}
Let us now publish this web service locally by creating the Endpoint publisher and expose the service on the server.
The publish method takes two parameters −
  • Endpoint URL String.
  • Implementor object, in this case the HelloWorld implementation class, which is exposed as a Web Service at the endpoint identified by the URL mentioned in the parameter above.
The contents of HelloWorldPublisher.java are as follows −
package com.tutorialspoint.endpoint;

import javax.xml.ws.Endpoint;

import com.tutorialspoint.ws.HelloWorldImpl;

public class HelloWorldPublisher {

   public static void main(String[] args){
      Endpoint.publish("http://localhost:9000/ws/hello", new HelloWorldImpl());
   }
}
Modify the web.xml contents as shown below −
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>

   <listener>
      <listener-class>
         com.sun.xml.ws.transport.http.servlet.WSServletContextListener
      </listener-class>
   </listener>
 
   <servlet>
      <servlet-name>hello</servlet-name>
      <servlet-class>
         com.sun.xml.ws.transport.http.servlet.WSServlet
      </servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
 
   <servlet-mapping>
      <servlet-name>hello</servlet-name>
      <url-pattern>/hello</url-pattern>
   </servlet-mapping>
 
   <session-config>
      <session-timeout>120</session-timeout>
   </session-config>
 
</web-app>
To deploy this application as a webservice, we would need another configuration file sun-jaxws.xml. The contents of this file are as follows −
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">

   <endpoint name="HelloWorld" implementation="com.tutorialspoint.ws.HelloWorldImpl" url-pattern="/hello"/>
 
</endpoints>
Now that all the files are ready, the directory structure would look as shown in the following screenshot −
Webservice Dir structure
  • Now create a WAR file of this application.
  • Choose the project > right click > Export > WAR file.
  • Save this as hello.war file under the webapps folder of Tomcat server.
  • Now start the Tomcat server.
  • Once the server is started, you should be able to access the webservice with the URL − http://localhost:8080/hello/hello

Create JMeter Test plan

Now let us create a test plan to test the above webservice.

Rename the Test Plan

  • Open the JMeter window by clicking /home/manisha/apache-jmeter2.9/bin/jmeter.sh.
  • Click the Test Plan node.
  • Rename this Test Plan node as WebserviceTest.
WS Test Plan

Add Thread Group

Add one Thread Group, which is placeholder for all other elements like Samplers, Controllers, and Listeners.
  • Right click on WebserviceTest (our Test Plan) > Add > Threads (Users) > Thread Group. Thread Group will get added under the Test Plan (WebserviceTest) node.
  • Next, let us modify the default properties of the Thread Group to suit our testing. Following properties are changed −
    • Name − webservice user
    • Number of Threads (Users) − 2
    • Ramp-Up Period − leave the the default value of 0 seconds.
    • Loop Count − 2
WS Test Users

Add Sampler - SOAP/XML-RPC Request

Now that we have defined the users, it is time to define the tasks that they will be performing.
We will add SOAP/XML-RPC Request element −
  • Right-click mouse button to get the Add menu.
  • Select Add > Sampler > SOAP/XML-RPC Request.
  • Select the SOAP/XML-RPC Request element in the tree
  • Edit the following properties as in the image below −
  • The following details are entered in this element −
    • Name − SOAP/XML-RPC Request
    • URL − http://localhost:8080/hello/hello?wsdl
    • Soap/XML-RPC Data − Enter the below contents
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://ws.tutorialspoint.com/">

   <soapenv:Header/>
 
   <soapenv:Body>
 
      <web:getHelloWorldMessage>
         <arg0>Manisha</arg0>
      </web:getHelloWorldMessage>
  
   </soapenv:Body>
 
</soapenv:Envelope>
WS Test request

Add Listener

The final element you need to add to your Test Plan is a Listener. This element is responsible for storing all of the results of your HTTP requests in a file and presenting a visual model of the data.
  • Select the webservice user element.
  • Add a View Results Tree listener by selecting Add > Listener > View Results Tree.
WS Test request

Run the Test Plan

Now save the above test plan as test_webservice.jmx. Execute this test plan using Run > Start option.

View the Output

The following output can be seen in the listener.
WS Sample ResultWS Result RequestWS Response Data
In the last image, you can see the response message "Hello Manisha to JAX WS world".