Chabot College Fall 2002 Removed Fall 2006 Course Outline for Computer Science 18D LINUX SOCKETS PROGRAMMING I Catalog Description: Computer Science 18D - Linux Sockets Programming I 2 units Introduction to data communications programming with TCP/IP sockets under Linux. Introduction to the TCP/IP protocol suite, circuit and packet switching, error detection and handling, host and domain name resolution. Selected topics in telecommunications and data communications, such as the ISO/OSI 7-layer model for communications. Development of client/server and peer-to-peer network applications. Prerequisite: Computer Science 18B (completed with a grade of C or higher). Strongly Recommended: Computer Science 18C and Computer Science 15 or Computer Science 19A (may be taken concurrently). 1.5 hours lecture, 1.5 hours laboratory. Prerequisite Skills: Before entering the course the student should be able to: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. identify the differences between the C standard libraries and Linux libraries; design, write, debug and document well-structured programs of small- to medium- length in the C language, using Linux system resources and the Linux libraries; demonstrate familiarity with processes under Linux and create, signal, and kill processes; demonstrate familiarity with Linux multitasking and describe, at a high level, how multitasking is done in Linux; demonstrate familiarility with semaphores in Linux and write C programs that correctly use semaphores; demonstrate familiarity with interprocess communication (IPC) signals in Linux and write C programs that correctly send and handle signals; demonstrate familiarity with shared resources (such as shared memory) in Linux and write C programs that correctly use shared resources; demonstrate familiarity with other Linux IPC tools, such as pipes and message queues, and write C programs that use these tools; identify parent and child processes, and user and group ids of processes; demonstrate familiarity with the internal workings of a simple shell, and write a simple shell; demonstrate familiarity with daemons and write a simple daemon; handle runtime errors from within C programs; demonstrate familiarity with networks as a user. Expected Outcomes for Students: Upon completion of the course the student should be able to: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. demonstrate familiarity with the TCP/IP protocol suite and the general history of how it came to exist; demonstrate familiarity with the general history of the Internet and networking in general; create and manipulate a socket in a C program under Linux; describe a client-server and a peer-to-peer network relationship; resolve domain and address families using system calls in Linux; work with both big-endian and little-endian hardware byte orders; form a socket address; work with an abstract local address; identify when socket addresses are not required; manipulate IP addresses and do address conversion, if needed; use an IP netmask; identify private and reserved IP numbers; Chabot College Course Outline for Computer Science 18D Linux Socket Programming I Fall Semester 2002 Page 2 Expected Outcomes for Students: continued 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. use Linux system calls that convert IP numbers; identify the classes of IP addresses and be able to identify address of each class; use the domain, socket type and protocol arguments for socket functions; bind an IP address to a socket; get a local socket address from a socket that already has an existing address; get the socket address from a peer socket; use bind() to choose a network interface to use for communication; use connectionless protocols (UDP) over a socket connection; use connection-oriented protocols (TCP) over a socket connection; demonstrate knowledge of how and when to use either type of protocol. Course Content: 1. 2. . 3. 4. 5. 6. 7. 8. 9. Introduce sockets a. Brief history of sockets and the Internet b. What is a socket? c. Referencing sockets under Linux in C programs d. Client-server and peer-to-peer paradigms Socket addresses a. Nameless sockets b. Domains c. Socket addresses -- generic, local, abstract local, Internet (Ipv4), wild, X.25, others d. Network byte order, big- and little-endian conversions Address conversions a. Classes of Internet addresses b. IP netmasks c. Private and reserved IP addresses d. Functions to convert IP addresses Socket types and protocols a. Protocol families, specific protocols within a family (IP family and TCP, UDP, etc.) b. Socket types (SOCK_STREAM, SOCK_DGRAM, etc.) c. How to choose a protocol Binding addresses to a socket a. The bind() system call and how to use it b. Getting the local address from a socket c. Getting the peer socket address d. Choosing a network interface for communication using bind() Connectionless protocols a. Differences between connection-oriented and connectionless communication b. Performing connectionless I/O with UDP c. Datagrams and datagram clients and servers Connection-oriented protocols a. Advantages and disadvantages of connection-oriented protocols b. The etc/services and etc/protocols files and support routines c. Connect() function d. TCP/IP connection-oriented clients TCP/IP connection-oriented servers a. Steps a connection-oriented server must go through b. Bind(), listen(), and accept() system calls c. How to write a connection-oriented server program Hostname and network name lookup a. Determining your local hostname b. Hostname-IP address resolution c. IP address-hostname resolution Chabot College Course Outline for Computer Science 18D Linux Socket Programming I Fall Semester 2002 Page 3 Methods of Presentation: 1. 2. Lecture In-class example programs with explanations and demonstrations Assignments and Methods of Evaluating Student Progress: 1. 2. Typical Assignments a. Write a program of main points illustrated in lecture. 1) A small peer-to-peer socket program, e.g., a chat 2) A small client-server socket program, e.g., a file server b. Non-programming homework to reinforce concepts from lecture and reading 1) Show the IP addresses allowed as local addresses using various netmasks 2) Describe the types of tasks performed at various levels in the TCP/IP protocol stack 3) Show how a message could be routed through a multi-path network Methods of Evaluating Student Progress a. Midterm exam b. Optional short quizzes c. Final exam Textbook(s) (Typical): Linux Socket Programming by Example, Warren Gay, Que Corporation, 2000 Special Student Materials: Computer lab fee Diskettes Optional zip disk Revised: July 2001 Keith Mehl CS 18D Outline Fall 2002 hps