ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

INTRODUCING THE PACKET WHACKER


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

INTRODUCING THE PACKET WHACKER

Applications Part 2: Setting a Course with Code
by Fred Eady

Start ý Packet Whacker Utilities ý Receiving Packets ý Who ARP You?ý Ping ý UDP ý TCP ý FIN ý Sources and PDF

UDP

User datagram protocol (UDP) rides inside the data area of an IP datagram. You can visualize this by noting the location of the UDP header in the Packet Whacker source code definition area. Unlike TCP, UDP does not require a logical connection to the other end. UDP is termed unreliable because it also doesnýt require any acknowledgment (ACK) of reception or transmission, making UDP easier to implement than TCP. Say what you want about UDP, but in reality itýs a good way to do certain things. I like to think of it as a serial port on the LAN.

UDP communication is based on ports. IP gets the UDP data to its physical destination and the UDP port moves the data to the logical destination. The UDP datagram consists of a source and destination port, a length field, a checksum field, and the data.

Listing 8 takes advantage of a program I developed for testing the CS8900 Ethernet engine. The test program is actually a test panel containing fields for incoming and outgoing text, buttons to send values to Port A of the PIC16F877 on the PICDEM.net, a destination IP port box, and a destination UDP port box. The test panel application is hard coded to point at UDP port 0x07, which is a well-known Echo port. Anything typed into the test panel outgoing box is echoed by the PICDEM.net/Packet Whacker combination and is seen in the test panel incoming box. Thus, the upper part of the code in Listing 8 simply turns the IP addresses and UDP ports around, echoing the data back to the sender.

Listing 8ýThis chunk of code is really a demo, but using the basic UDP and IP protocol rules in this code, you can construct a working UDP application. The button decode at the bottom of the listing turns the PICDEM.net System LED on and off.

To use this routine to send your own data, all that would have to be done is to modify the UDP length (UDP_len) to match the UDP datagram length. This is easily done because the IP header contains the total datagram length, and all that would be necessary to do would be to subtract the IP header length from the IP datagram length to get the UDP datagram length.

The buttons on the test panel are hard coded to a UDP destination address of 5000 decimal. One button sends a single data byte of 0xFF and the other button sends 0x00. The lower part of Listing 8 simply picks off the data byte in the UDP datagram and forwards the value to Port A of the PICDEM.netýs PIC. This clearly demonstrates how text and control data can be easily sent and received using the UDP protocol, the Packet Whacker, and basic PIC hardware found on the PICDEM.net. I reinstalled resistor R12 on the PICDEM.net to enable the PICDEM.netýs System LED to be controlled by the test panel application.

Photo 8 demonstrates that UDP is more than adequate for most appliance applications that need to move data on an Ethernet LAN. When it becomes necessary to ensure the data arrives just as it was sent, the big dog has to be turned loose.

 

Photo 8ýThis is a shot of the test panel and the Sniffer capture of the data transfer in the test panel boxes.

 

PREVIOUS NEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ýCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
 
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ