This tutorial is of 2 parts.
First part explains the following :
–Starting a Server on your PC & start listening on a port (say 350) . For this we use SOCKET TEST or HERCULES software
— Once the port is listening , we test communication locally using PuTty
— Windows Firewall setting has to be done for a NEW INBOUND RULE allowing port 350 for communication.
— For connecting to this port from external world , PORT FORWARDING to be done in Router’s Virtual Server setting so that any contact to the public IP is routed to the PORT 350 .
Second part is practical demo using GSM SIM900 or ESP8266 with Arduino.
The following picture shows my simple home network connections.A BINATONE make Router is used to connect to the Internet provider Airtel Broadband.The IP address of the Router is
which is the Gateway IP address used to access the settings on Router.My Laptop is connected over WIFI to this Router.The Router assigns a local IP address to my PC which is
Apart from these, the Internet Provider assigns a Public IP to my Network which is
This is the IP by which external world can contact my network.
Note that all these IP addresses are DYNAMIC & changes every time I power up the Router.
In another post I’ll explain how to make these IP addresses STATIC , so that the IP remain the same always.
All the Network Tools I’ve used for this demo can be downloaded HERE.
Let us start a server on port 350 using the SOCKET TEST tool.
This tool allows us to start a server easily.Click on the SERVER Tab & then feed in the port number where you want to listen.
Click on START LISTENING.
Now the server is up & running.It starts listening on port 350.
Remember to avoid the standard ports like 80 ( http) , 21 (FTP), 23 (TELNET), 22 (SSH) ,etc which are well known ports ,pre assigned for the particular protocol.
The dynamic range of port number you can assign goes up to 65535 or 2^16-1 (16 bits).
The IP address of the router can be known from the command window
RUN –> CMD –> ipconfig
The Default Gateway IP is the address of the Router.
LOCAL TESTING TOOLS (optional)
Once the port is assigned for the server , you can use the ADVANCED PORT SCANNER tool to verify the port on the particular IP.
In the screen shot below you can see that the port number 350 is discovered as a TCP Server port on my PC whose local IP is 192.168.1.150
While the port scanner is scanning , you get messages on your SOCKET TEST window.
Here you can see the Port scanner software connecting to the port & then disconnecting after scanning.
Alternatively you can use a PUTTY serial port tool to test local communication.
Select the connection type as RAW & provide the host IP which is 192.168.1.150 & thtn the port number 350
Click on open , to see the New client connection on the Socket test window.
Now you can test two way communication between socket test (server) & putty ( client).
WINDOWS FIREWALL SETTINGS
The Windows Firewall settings has to be done to allow the port 350 to listen from outside.
Open the Windows Firewall & Advanced Security window.
Click on Inbound Rules & then New Rule.
Select the Rule Type as PORT & in the next screen select protocol as TCP.
Under Specified local ports feed the port number as 350
Under Action window select Allow the Connection
Next window is Profile window , here tick mark all – Domain,Public & Private.
Provide a name to the Rule & save it.
Now your PORT 350 is allowed to listen by the Windows Firewall.
This step is final where you redirect the incoming request to the port number of local IP where the server is started.
Here my local PC’s IP is 192.168.1.150 & server is started on port 350.
Anyone from external world connecting to my public IP has to be directed to the port 350 on local IP 192.168.1.150.
This is called PORT FORWARDING , which is very widely used in CCTV Remote viewing & in Gaming.
The setting has to be done in your Router.
Type in the Gateway IP of your Router , here it is 192.168.1.1 , on your browser & provide the user name & password.
Here is an excellent website showing all screen shots of almost all Routers in the world
Mine is BINATONE Router.
You’ve to search for something called VIRTUAL SERVER on the router setting.
For my Router it’s hidden under ADVANCED SETUP –> NAT –> VIRTUAL SERVER
For more details you can visit the above portforward link
Create a new Virtual server listing by entering the
— Port number , which is 350 .Enter same number at all fields like start & stop.
— Local IP address , here you provide the IP where server is started , 192.168.1.150
— save the listing
Once saved , the port number 350 is open to outside world.
Online port open test tools are available
Once you open the link , your public IP will be automatically shown.
Fill in the PORT number to be checked & click on CHECK button.
If you see SUCCESS , then you’re done with PORT FORWARDING
Following is the list of AT commands used by the GSM SIM900A to contact the server.
This is for part 2 of the post.PART 2 LINK HERE