A TCP/IP (Transfer Control Protocol/ Internet Protocol) suite is part and parcel of Computer Networking or advanced computer networking. It is the family of protocols (TCP,UDP,IP,ICMP, ARP) used for communication over the global Internet, and is often used in private networks such as local-area networks and corporate intranets. In order to attach a device to the network, the device must be able to use the TCP/IP protocols for communication. You can see presence of TCP/IP suite in fig 1.
Fig. 1: Image Showing TCP/IP Usage Inside and Outside a Wireless Sensor Network or embedded systems
But if we ask how it is implemented? Many people will say, “Microsoft Inc must knowing that”. But Microsoft is selling Windows operating system executables. They cannot give source code of TCP/IP protocol suite. Where is TCP/IP suite in windows operating system? In Windows XP and Windows 7, TCP/IP suite must be in the windows system directory. After searching C:WindowsSystem32 system directory, we find following files tcpmib.dll, tcpmon.dll, tcpmon.ini, and tcpmonui.dll . These files are TCP/IP protocol site. This implementation of TCP/IP protocol suite is in Megabytes, Which cannot fit in smaller devices like set-top box, medical devices. We need tiny TCP/IP protocol suite. We should able to put in 512 Kilo byte flash memory or in in-built memory of microcontroller.
This Tiny TCP/IP protocol suite highly applied in wireless sensors, wireless router, refrigerators, micro-ovens and thermostat etc. This suite can be very useful in embedded systems because it requires very small amounts of code and RAM. It has been ported to several platforms, including DSP platforms. It makes many unusual design choices in order to reduce the resources it requires.
We can see fig 2 to understand Tiny TCP/IP protocol suite layer diagram for general purpose microcontroller. LPC 1768 (ARM cortex M3 by NXP) microcontroller supports Ethernet technology that’s why we can easily test tiny TCP/IP on this microcontroller.
We can run tiny TCP/IP as a single process or single Hex file also. This single *.hex file can be created in Keil cross compiler IDE (www.keil.com) environment and open source code for tiny TCP/IP is available on internet. Most popular code is belong to Adam Dunkel’s Swedish student.
Communication of Tiny TCP/IP with microcontroller:
Tiny TCP/IP runs as a main program in single task system. Main program check whether packet has arrived from network and other process is checking of periodic time out happen. If network packet has arrived, program use tcp/ip stack is called. Input handler will not be blocked so that other packet can reach to the embedded system. Periodic timeouts are used to drive TCP mechanisms that depend on timers such as delayed acknowledgements, retransmission.
We need 192.168.1.210 IP address in the code and when we are connecting Embedded system board to PC. PC should be in same domain of network to test Tiny TCP/IP code. You can give 192.168.1.100 to your PC through Networking properties of your NIC of computer.
Basic Steps to create Tiny TCP/IP suite:
1) Select Microcontroller which supports Ethernet technology. (Eg LPC1768 make NXP)
2) Identification of cross compiler to do crossing of code design for Lpc1768 microcontroller. This cross compiler helps to generate hex file which can be transfer to boot loader of microcontroller’s flash memory.
3) Designing of various blocks of coding to test TCP/IP protocol suite e.g. TCP, ARP, IPv4, IPv6, ICMP, UDP etc.( Pick up this code from open source code of Adam Dunkel’s website dunkels.com/adam/software.html)
4) Implementation of code in the Keil cross compiler version 4 or higher which will support IP version 4 and windows XP and windows 7 operating system. You can easily create Hex file using Keil compiler. We are assuming that you are having Ethernet driver source code of your board or microcontroller.
Testing of Tiny TCP/IP protocol by connecting Embedded system board by burning Hex file using flash magic utility with PC and ping host machine by c:>ping 192.168.1.210
Fig 3 shows interfacing of ARM LPC1768 with PC/Hub/Switch.
Fig. 3: Picture Showing ARM Cortex Microcontroller Interfacing with Host
Applications of Tiny TCP/IP
Tiny TCP/IP can be pushed in to hardware as dedicated web server, packet loggers, industrial internet, Internet of things, Wireless Sensor networks. eMetering, lighting management, remote process control, interconnecting smart objects.
Note: If you are getting error in running TCP/IPstack on your board then one reason could be IP address of your PC is not in Same domain. Make sure subnet mask of your computer should be 255.255.255.0 and IP address of host should be 192.168.1.100
Author is proprietor of “TMB Enterprises, Thane,Mumbai ” and author of “Computer Network” book which is published by Wiley publishers.
Filed Under: Articles