Chapter 2. UNP configuration, MAKEFILE, Echo program 2006. 3. 7 백 일 우

Slides:



Advertisements
Similar presentations
Sockets Tutorial Ross Shaull cs146a What we imagine Network request… response… The packets that comprise your request are orderly.
Advertisements

The make Utility Programming Tools and Environments Winter 2006.
Separate compilation Large programs are generally separated into multiple files, e.g. tuples.h, ray.h, ray.c, tuples.c main.c With several files, we can.
COEN 445 Communication Networks and Protocols Lab 4
Understanding Makefiles COMP 2400, Fall 2008 Prof. Chris GauthierDickey.
Compilation & linkage.h read.h.c read.c.c main.c.c list.c.h list.h prog1 Linkage: g++ read.o main.o list.o –o prog1.o main.o.o list.o.o read.o Compilation:
1 The Makefile Utility ABC – Chapter 11,
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Guide To UNIX Using Linux Third Edition
CS465 - Unix C Programming (cc/make and configuration control)
NovaBACKUP 10 xSP Technical Training By: Nathan Fouarge
Lecture 8  make. Overview: Development process  Creation of source files (.c,.h,.cpp)  Compilation (e.g. *.c  *.o) and linking  Running and testing.
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
Process-to-Process Delivery:
1 Lab 3 Transport Layer T.A. Youngjoo Han. 2 Transport Layer  Providing logical communication b/w application processes running on different hosts 
SOCKS Group: Challenger Member: Lichun Zhan. Agenda Introduction SOCKS v4 SOCKS v5 Summary Conclusion References Questions.
CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
Unix Makefiles COP 3330 Lecture Notes Dr. David A. Gaitros.
LWIP TCP/IP Stack 김백규.
LWIP TCP/IP Stack 김백규.
Programming Tools gcc make utility Open Source code Static and Shared Libraries gdb Memory debugging tools.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
리눅스 : Lecture 5 UNIX 유틸리티 : text editor, compilation (make), …
Jump to first page (C) 1998, Arun Lakhotia 1 Software Configuration Management: Build Control Arun Lakhotia University of Southwestern Louisiana Po Box.
1 Linux Command. Advanced Compiler Laboratory2 Simple linux cmds ls List information about FILEs, by default the current directory. pwd Print Working.
Adv. UNIX: large/131 Advanced UNIX v Objectives of these slides: –learn how to write/manage large programs consisting of multiple files, which.
Lecture 2 Linux Basic Commands,Shell and Make September 8, 2015 Kyu Ho Park.
Transport Layer: TCP and UDP. Overview of TCP/IP protocols Comparing TCP and UDP TCP connection: establishment, data transfer, and termination Allocation.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
Week 2-3 Control flow (review) Conditional statements If, else, else if, switch-case, break Loop constructs for, while, do-while, break, continue, label--go;
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
PostgreSQL Installation By: Keerthi Nelaturu Previous version by Ahmed Jeddah & Miguel Garzon.
Tools – Ant-MakeEtc 1 CSCE 747 Fall 2013 CSCE 747 Software Testing and Quality Assurance Tools 12 – Hamcrest 10/02/
Makefiles CARYL RAHN. Separate compilation Large programs are generally separated into multiple files, e.g. main.c addmoney.c removemoney.c money.h With.
Lecture 8  make. Using make for compilation  With medium to large software projects containing many files, it’s difficult to: Type commands to compile.
1 Tips for the assignment. 2 Socket: a door between application process and end- end-transport protocol (UDP or TCP) TCP service: reliable transfer of.
Emacs, Compilation, and Makefile C151 Multi-User Operating Systems.
C code organization CSE 2451 Rong Shi. Topics C code organization Linking Header files Makefiles.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
4343 X2 – The Transport Layer Tanenbaum Ch.6.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
CSc 352 An Introduction to make Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
UNIX Development: g++ and make CS 2204 Class meeting 8 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
 Prepared by: Eng. Maryam Adel Abdel-Hady
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
Week Seven Agenda Link of the week Review week six lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Multiple file project management & Makefile
The make utility (original presentation courtesy of Alark Joshi)
Lecture 2 Linux Basic Commands,Shell and Make
CSE 303 Lecture 17 Makefiles reading: Programming in C Ch. 15
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
Brief Intro to Make CST494/ Gannod.
Makefiles Caryl Rahn.
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Makefiles and the make utility
Process-to-Process Delivery:
Data Structures and Programming Techniques
CMPSC 60: Week 4 Discussion
CSc 352 An Introduction to make
Makefiles and the make utility
Process-to-Process Delivery: UDP, TCP
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
The make utility (original presentation courtesy of Alark Joshi)
Presentation transcript:

Chapter 2. UNP configuration, MAKEFILE, Echo program 백 일 우

2 UNP library (1/2) W. Richard Stevens Solaris, Linux, FreeBSD 등에 설치 가능 Libunp.a, libfree.a, libroute.a, libxti.a 로 구성 ※ XTI [ X/Open Transport Interface ] OSI 기본 참조 모델의 제 4 계층 (transport layer) 에서의 응용 프로그램 인터페이스 (API) 에 대한 X/Open 의 규정. 이 API 를 사용하면 제 3 계층 이하의 어떤 망 방식을 사용하든 관계없이 망 응용 프로그램을 작성할 수 있다. 사용자가 쉽게 사용할 수 있도록 만든 Wrapper function

3 UNP library (2/2) 예제  기본함수 정의  UNP library 에서의 정의 [page 11] 사용법 #include int socket(int domain, int type, int protocol); 설명 : Socket 은 통신을 위한 종점 (endpoint) 를 생성하고 디스크립터를 반환한다. 반환값 : 에러시, -1 이 반환된다 ; 그 밖의 반환값은 디스크립터 참조소켓이다. int Socket(int family, int type, int protocol) { int n; if ( (n = socket(family, type, protocol)) < 0) err_sys("socket error"); return(n); }

4 UNP library - install 압축해제 gunzip unpv13e.tar.gz tar xvf unpv13e.tar 설치방법./configure # try to figure out all implementation differences cd lib # build the basic library that all programs need make # use "gmake" everywhere on BSD/OS systems cd../libfree # continue building the basic library make cd../libroute # only if your system supports 4.4BSD style routing sockets make # only if your system supports 4.4BSD style routing sockets cd../libxti # only if your system supports XTI make # only if your system supports XTI cd../intro # build and test a basic client program make daytimetcpcli./daytimetcpcli tar xvfz unpv13e.tar.gz

5 실습시 주의사항 (1/3) 실습용 서버주소 : amg.hufs.ac.kr [Allocation of port numbers] 자신에게 정해진 port 만 사용 port number : ‘ 5xxxx ’ 부터 +10 까지 학번 뒤에 4 자리 ex) 학번이 일때  50128~50138 까지

6 실습시 주의사항 (2/3) 불필요한 process 가 있지 않도록 관리 Zombie process  process 가 종료할 때 parent process 에 의해 지워지기 위해 대기중인 상태의 process  memory, disk, IO, CPU time 등의 자원은 사용하지 않고, process table 의 용량을 차지함 [process transition diagram for Linux]  zombie process 의 누적  한계치 수준의 process 생성  system crash

7 실습시 주의사항 (3/3) 해결방법  ‘ ps ’ 명령어로 사용중인 process 확인  ‘ Kill ’ 명령어로 해당 process 삭제

8 Hello by using UNP You can enjoy UNP libraries, implementing any kinds of programs. Now, Implement “Hello World” on condition as below, Use UNP libraries,.. Whatever type of compile, No problem.  gcc –o xxxx.c  gcc -o Hello xxx.c Should be done in a minute!!! What about Make? What is ‘make’? why should we use it?  Advantages  Efficiency  Easy to read, and fabulous!!

9 Concept of MAKE Make from ‘man’ GNU make utility to maintain groups of programs. The purpose of the make utility is to determine automatically which pieces of a large program need to be recompiled, and issue the commands to recompile them. Necessity Of many files, when we should modify or update some lines, we might have many faults in their relationship If we make make files, we can miss one of them, take useless time to type

10 Structure - Basic Basic Structure – Example1 test : main.o read.o write.o gcc –o test main.o read.o write.o main.o : io.h main.c read.o : io.h read.o write.o : io.h write.o Note : Must use ‘TAB’ key!!! TAB test io.h main.c main.o read.c read.o write.c write.o

11 MACRO OBJECTS = main.o read.o write.o test : $(OBJECTS) gcc -o test $(OBJECTS) main.o : io.h main.c gcc –c main.c All kinds of Shell commands can be used! read.o : io.h read.c gcc –c main.c write.o : io.h write.c gcc –c main.c clean : rm –r $(OBJECTS) Can use ${..}, $(..), $.., but $(..) is recommended Can swap letter OBJECTS with yours

12 Pre-Defined MACRO ‘make –p’, see the rules, macro, environment of make ASFLAGS = ‘as’ Option setting AS = as CFLAGS = ‘gcc’ Option setting CC = cc (= gcc ) CPPFLAGS =‘g++’ Option setting CXX = g++ LDLFAGS =‘ld’ Option setting LD = ld LFLAGS = ‘lex’ Option setting LEX = lex YFLAGS = ‘yacc’ Option setting YACC = yacc MAKE_COMMAND = make RM = rm -f

13 MACRO Using Previous Predefined MACRO OBJECTS = main.o read.o write.o SRCS = main.c read.c write.c Not neccesary CC = gcc CFLAGS = -g –cAdd option : –g TARGET = test $(TARGET) : $(OBJECTS) $(CC) -o $(TARGET) $(OBJECTS) clean : rm -rf $(OBJECTS) $(TARGET) core main.o : io.h main.c read.o : io.h read.c write.o: io.h write.c

14 Suffix Rule Execute reasonable operations according to their Suffixes Command Ex.SUFFIXES :.c.o OBJECTS = main.o read.o write.o SRCS = main.c read.c write.c Not neccesary CC = gcc CFLAGS = -g –cAdd option : –g TARGET = test $(TARGET) : $(OBJECTS) $(CC) -o $(TARGET) $(OBJECTS). % make gcc –g –c main.c –o main.o $(CC) $(CFLAGS) –c $< -o

15 Internal MACRO Can’t define or change as you please $* : Target File having No suffix : Current Target File $< : File Updated newly than current Target File (= $?) main.o : main.c io.h gcc –c $*.cresult : $* => main test : $(OBJS) gcc –o $S.cresult : = test.c.o : gcc –c $< (or gcc –c $*.c) Result : if update main.c after main.o, main.c will be compiled by ‘$<‘

16 Macro Substitution Usage : $(MACRO_NAME : OLD = NEW) MY_NAME = Micheal Jackson YOUR_NAME = $(MY_NAME : Jack = Jook) >Result : Jookson OBJS = main.o read.o write.o SRCS = $(OBJS :.o =.c) >Result : SRCS = main.c read.c write.c In fact, Very comfortable to change 100(File.o into File.c)

17 gccmakedep Check automatically dependencies of Files, and add result to end of Makefile.SUFFIXES :.c.o CFLAGS = -O2 –g OBJS = main.o read.o write.o SRCS = $(OBJS :.o =.c) test : $(OBJS) $(CC) –o test $(OBJS) dep : gccmakedep $(SRCS) % make dep % vi Makefile # DO NOT DELETE main.o: main.c /usr/include/stdio.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/libio.h \ /usr/include/_G_config.h io.h read.o: read.c io.h write.o: write.c io.h

18 Multiple Targets.SUFFIXES =.c.o CC = gcc CFLAGS = -O2 -g OBJS1 = main.o test1.o Define each Macro! OBJS2 = main.o test2.o OBJS3 = main.o test3.o SRCS = $(OBJS1:.o=.c) $(OBJS2:.o=.c) $(OBJS3:.o=.c) all : test1 test2 test3 test1 : $(OBJS1) $(CC) -o test1 $(OBJS1) test2 : $(OBJS2) $(CC) -o test2 $(OBJS2) test3 : $(OBJS3) $(CC) -o test3 $(OBJS3) dep : gccmakedep $(SRCS)

19 Recursive Make For Big Program and Project Want to execute ‘make’ in each folders.SUFFIXES =.c.o CC = gcc CFLAGS = -O2 -g all : DataBase Test DataBase: cd db ; $(MAKE) Move Folder db and execute ‘make’ Test: cd test ; $(Make) Move Folder test and execute ‘make’ % make cd db ; make make[1] : Entering directory`/home/raxis/TEST/src' gcc -O2 -g -c DBopen.c -o DBopen.o gcc -O2 -g -c DBread.c -o DBread.o gcc -O2 -g -c DBwrite.c -o DBwrite.o make[1] : Leaving directory `/home/windows/TEST/src' cd test ; make make[1] : Entering directory `/home/raxis/TEST/test' gcc -O2 -g -c test.c -o test.o make[1] : Leaving directory `/home/windows/TEST/test'

20 Stop useless Compile If modify not to affect other files and any dependency, time waste that try to re-compile Suppose add new line : #define PI 3.14 in header file, surely No side- effect to others and No usage!! At this time, Use Command ‘make –t’  Meaning is touch  Not compile and just ‘Update_DATE’ is updated newly instead of compile

21 TIPs for Make Usage Favorite Option for Usage -C dir : First of all, Move as direction and do next command -d : Print all of make process information  NOTE : Amount is tremendous -f file : treat file as Makefile -h : help -t : touch -v : Show version of Makefile -p : Print internal values set in Makefile  Meaning : print_data_base -k : Never stop even if makefile has errors  Meaning : keep_going

22 Makefile : target, 의존성 (dependency), 명령 (command) 로 이루어진 compile 규칙들의 나열 target : 명령 (command) 이 수행되어서 나온 결과 파일을 지정 dependency : dependency 를 갖는 파일을 지정 command : dependency 부분에 정의된 파일의 내용이 변경되거나 object 부분에 해당하는 파일이 없을 때 이곳에 정의된 것들이 차례대로 실행 (command 는 반드시 TAB 으로 시작해야함 ) make – Makefile in UNP target … : dependency … command …

23 UNP library 의 directory 구조 config*.* : library 설치관련 파일 ex> config.h, config.h.in, config.log, config.status, configure.in 등 libunp.a : UNP library archive 파일 lib, libfree : library 에서 추가한 함수들의 object 파일 make - UNP library 의 Makefile (1/2) 각 chapter 의 source code ( ex> intro, select… ) unpv13e libunp.a lib libfree config*.*

24 make - UNP library 의 Makefile (2/2) unpv13e/mcast/Makefile

25 APPENDIX(I).SUFFIXES =.c.o CC = gcc INC = …-I/home/….Add header files’ Paths which might be included LIBS = ….Add libraries needed CFLAGS = -g $(INC) ….Add Options Needed OBJS = …Object file Names SRCS = …Source file Names TARGET = ….Executable file Name : Target File all : $(TARGET) $(TARGET) : $(OBJS) $(CC) -o $(OBJS) $(LIBS) dep : gccmakedep $(INC) $(SRCS) clean : rm -rf $(OBJS) $(TARGET) core new : $(MAKE) clean $(MAKE)

26 APPENDIX(II) Errors and Handing Makefile :17: *** missing separator. Stop.  Maybe miss letter TAB in 17th line  Command line must be started with letter TAB. NOTE!!! Make: *** NO rule to make target ‘io.h’, neede by ‘read.o’. Stop.  Problem is dependency. Miss the file io.h  Handle : First, find out the file. If not exist, ……….what about ‘make dep’ Makefile:10: *** commands commence before first target. Stop.  Meaning is as above  Handle : If you use ‘\’, Must check whether ‘\’ is end of line or not.  ‘\’ Must be end of line, so if you add space letter after ‘\’ carelessly, it cause error without doubt Makefile do nothing, or something strange  Makefile think first target is its result file, so if locate something like ‘make clean’ at first target line, makefile do wrong.

27 Socket Address Structures Could be a specific and real example

Echo Server & Client Program

29 About TCP Features of TCP Transport Layer present on all TCP/IP hosts Provides reliable, unicast, Connection-Oreiented service Adapts sending rate to Network Capacity and Provides fair access Most Internet Traffic still rides over TCP Application Throughput problems may be due to TCP performance(and implementaions) and not the Network RFC 793 You can also others about TCP in RFC 793 

30 Protocols and API

31 TCP with Buffers, Variable Socket Programing with TCP Host or Server Process Socket Internet TCP with Buffers, Variable Host or Server Process Socket Controlled By application developer Controlled By operating system Controlled By application developer Controlled By operating system * Socket is door between the application process and TCP

32 Socket Programing with TCP Client, welcoming socket, and connection socket Client processServer process bytes Connection socket Client socket Three-way handshake

33 TCP : Compare with version C socket() bind() listen() accept() read() write() read() write() connect() socket() TCP ServerTCP Client Passive Open Blocks until connection from client Data(request) Connection establishment Data(reply) Active Open close() read() close() EOF notification (3-way handshake)

34 Echo Client

35 Assignment #1 : Echo Server Conditions Use UNP libraries Use 2 Linux Servers supported in NP(140, 142) Do it by yourselves