Sei sulla pagina 1di 2

Fall 2008 Embedded Systems

Lab 5. Ethernet Network Programming


1. Purpose
Understand how to program a typical network program using sockets, and implement a TFTP (Trivial File Transfer Protocol) server and client.

2. Hardware connection
User I/O (keyboard and display) -- PC -- Serial/Ethernet connections -- Embedded board.

3. Problem 5 (TFTP server and client)


Design and implement two socket programs using the UDP. The TFTP server program in the PC is a server program waiting for service request. The TFTP client program in the EZ-X5 is a client program, which requests a file download to the TFTP server. The server reads the requested file from the disk, makes packets, and then sends to the client using the TFTP protocol. The client receives packets and writes to a file in ramdisk.

4. Hints
EZ-X5 board has one Ethernet port whose speed is 10 Mbps max. This Ethernet port can be connected to the Ethernet port in the PC using the provided cross cable. Use the datagram socket for Ethernet communication between PC and EZ-X5 board. Refer to "Socket programming How To" and Beejs Guide to Network Programming in the web. Read and understand about the TFTP protocol, in which packets of read request, data, and acknowledge is required for one-sided transfer.

5. Programming Sequence
1) TFTP (Trivial File Transfer Protocol) algorithm build-up: First, design and implement a combined program named algorithm.c, which contains both server and client. User input can be replaced by getchar(), server output can be replaced by printf. The purpose of this program is to check the algorithm flow of TFTP packet data transfer. Search Internet to find the TFTP packet data transfer. User (~Client) Want to get a file. Send the filename. Serial Algorithm.c (~Server) Mission: Send a file if requested. Get the filename using getchar(). Read the file into memory buffer. Divide the buffer into TFTP packets. Send multiple packets using printf. Send the last packet using printf.

See multiple packets. See the last packet.

For convenience of viewing, assume that the file requested is an ASCII file (source file). Can you see a binary file? In this case, each byte in the packet may be printed using printf with %02x format. 2) Both server and client in the PC Native-compile both listener.c program and talker.c program using datagram socket (from Beejs Guide). In one window, run the listener program. In another window, run the talker program. Test the operation of listener and talker. PC window Talker.c Ethernet Socket datagram Another PC window Listerner.c

3) Server in the Ez-X5 and client in the PC Cross-compile the listener program to build ezlistener for the EZ-X5 board. Download and run the ezlistener program in the Ez-X5 board. In the PC, run the talker program which is native-compiled. Test the operation of this Ez-X5 PC network connection. PC window Talker.c Ethernet Socket datagram EZ-X5 with minicom Listerner.c

4) Both TFTP_server and TFTP_client in the PC Referring the above algorithm and the cross-compiled ezlistener program, program the TFTP_server.c program. Also program the TFTP_client program, by referring the talker program. You can native-compile both programs, and test the operation in the PC. PC window TFTP_client.c Ethernet Socket datagram Another PC window TFTP_server.c

5) TFTP_server in the PC and TFTP_client in the EZ-X5 Native-compile the TFTP_server for the PC, and cross-compile the TFTP_client for the EZ-X5 board. Test using the same method of Step 3. Successive operation of this program should

be demonstrated to TA.
EZ-X5 with minicom TFTP_client.c Ethernet Socket datagram PC window TFTP_server.c

6) Looks complicated? But remember: Step by step, one goes far.

5. Demonstration & Report


Demonstration: To TA, 12/1 Mon. 4 PM - 6 PM Report: To TA, Due 12/4 Thu. 6 PM

Each student should prepare his own report containing: Purpose Experiment sequence Experimental results Discussion: should be different even for each member of the same team. References

GOOD LUCK!
2

Potrebbero piacerti anche