26
Chapter 1 Introduction 소소 소소소소소

Chapter 1 Introduction

  • Upload
    twyla

  • View
    39

  • Download
    0

Embed Size (px)

DESCRIPTION

Chapter 1 Introduction. 소켓 프로그래밍. Introduction. TCP/IP 모델 프로토콜과 포트 IP 주소 지정 스키마 클라이언트 / 서버 모델 소켓 윈도우 소켓 .NET 소켓 클래스. TCP/IP 모델. 컴퓨터 간 통신 네트워크에 연결된 컴퓨터 유선 또는 무선으로 연결 Low level 통신을 제어하는 네트워크 장치 컴퓨터는 네트워크 장치를 통해 네트워크에 연결되어 통신을 하게 됨. TCP/IP 모델. 프로토콜을 이용한 통신 - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 1 Introduction

Chapter 1Introduction

소켓 프로그래밍

Page 2: Chapter 1 Introduction

TCP/IP 모델 프로토콜과 포트 IP 주소 지정 스키마 클라이언트 / 서버 모델 소켓 윈도우 소켓 .NET 소켓 클래스

Introduction

Page 3: Chapter 1 Introduction

컴퓨터 간 통신◦ 네트워크에 연결된 컴퓨터

유선 또는 무선으로 연결◦ Low level 통신을 제어하는 네트워크 장치

컴퓨터는 네트워크 장치를 통해 네트워크에 연결되어 통신을 하게 됨

TCP/IP 모델

Network

Computer Computer

Network Device Network Device

Page 4: Chapter 1 Introduction

TCP/IP 모델

Program

InternetProtocol

Suite

Router

Network

Program

InternetProtocol

Suite

Router

프로토콜을 이용한 통신◦ 서로 통신을 하기 위해서는 각 호스트 시스템이 표준적인

방법이나 규칙을 따라야 함

Page 5: Chapter 1 Introduction

TCP/IP 모델

Application Layer

Transport Layer

Internet Layer

Link Layer

RFC 1122 에 정의됨 계층화된 모델 4 개의 계층으로 구성 각 계층은 그 계층만의

프로토콜을 가지고 있음 융통성 있는 프로토콜 디자인 데이터는 한 계층에서 다른

계층으로 이동

Page 6: Chapter 1 Introduction

응용 계층 (Application layer)◦ 최상위 계층◦ 최종 사용자 프로그램과 그 하위 계층과의

인터페이스를 위해 존재◦ Example

HTTP (Hypertext Transfer Protocol) SMTP (Simple Mail Transfer Protocol) POP3 (Post Office Protocol Version 3) FTP (File Transfer Protocol) Telnet

TCP/IP 모델Application Layer

Transport Layer

Internet Layer

Link Layer

Page 7: Chapter 1 Introduction

전송 계층 (Transport layer)◦ 두 호스트간의 end-to-end 통신을 처리◦ TCP 와 UDP

Transmission Control Protocol (TCP) 신뢰성 있는 연결 지향형 프로토콜

User Datagram Protocol (UDP) 비 연결 형 프로토콜

◦ 주소지정을 위해 포트번호를 사용 송신측 포트번호 수신측 포트번호

TCP/IP 모델Application Layer

Transport Layer

Internet Layer

Link Layer

Page 8: Chapter 1 Introduction

인터넷 계층 (Internet layer)◦ 인터넷 프로토콜 (IP)

VoIP 와 IPTV 에서 사용됨 IP 주소를 이용하여 송신측에서 수신

측까지 데이터를 운반◦ 기타 프로토콜

Internet Group Management Protocol (IGMP)

Internet Control Message Protocol (ICMP)

TCP/IP 모델Application Layer

Transport Layer

Internet Layer

Link Layer

Page 9: Chapter 1 Introduction

링크 계층 (Link layer)◦ 미디어 접근 계층으로도 알려져 있음◦ 네트워크의 하드웨어적인 부분을 담당◦ 소프트웨어와 하드웨어간의

인터페이스를 처리◦ 하드웨어에 따른 장치 드라이버가 필요◦ Example

Address Resolution Protocol (ARP)

TCP/IP 모델Application Layer

Transport Layer

Internet Layer

Link Layer

Page 10: Chapter 1 Introduction

프로토콜◦ 데이터 통신을 위해 종단점 간에 사용되는 규칙 또는 표준의

집합◦ 데이터의 구조나 형식을 정의◦ 통신이 어떻게 이뤄져야 하는지를 정의◦ 각 계층은 그 계층만의 프로토콜을 포함◦ IETF 에서 인터넷에 사용되는 프로토콜을 표준화

Release Request for Comment (RFC) 문서

프로토콜과 포트

Page 11: Chapter 1 Introduction

프로토콜과 포트

Protocol Name RFC Purpose

HTTPHypertext Transfer Protocol

RFC 2616 Web page browsing

FTP File Transfer Protocol RFC 959File sending & receiving

Telnet Telnet Protocol RFC 854Remote terminal access

SMTPSimple Mail Transfer Protocol

RFC 5321 Email sending

POP3Post Office Protocol Ver. 3

RFC 1939 Email receiving

Page 12: Chapter 1 Introduction

포트 번호◦ 호스트 시스템 내에서 어플리케이션을 식별하는데 유용◦ TCP 와 UDP 에서 사용됨◦ 16 비트의 길이를 가짐◦ 0 – 65535 의 범위◦ Internet Assigned Numbers Authority (IANA) 에서

포트번호를 할당 Well known port [0 – 1023] Registered port [1024 – 49151] Dynamic and/or private port [49152 – 65535]

프로토콜과 포트

Page 13: Chapter 1 Introduction

Protocol Name Port

HTTP Hypertext Transfer Protocol 80

HTTPS Hypertext Transfer Protocol (Secure) 443

FTP File Transfer Protocol (Data) 20

FTP File Transfer Protocol (Control) 21

Telnet Telnet Protocol 23

SMTP Simple Mail Transfer Protocol 25

POP3 Post Office Protocol - Version 3 110

IMAP Internet Message Access Protocol 143

SSH Secure Shell Remote Login Protocol 22

프로토콜과 포트

Page 14: Chapter 1 Introduction

IP 주소◦ 인터넷 프로토콜을 이용하는 모든 호스트는 IP 주소라는

유일한 식별자를 가짐◦ Ipconfig 명령을 이용하여 IP 주소 확인 가능

IP 주소 지정 스키마

Page 15: Chapter 1 Introduction

IPv4 데이터 그램 헤더 (RFC 791)

IP 주소 지정 스키마

VersionHeader Length

Type of Service Total Length

Identification Flags Fragment Offset

Time to Live Protocol Header Checksum

Source Address

Destination Address

Options

4 bits 4 bits 8 bits 13 bits3 bits

Page 16: Chapter 1 Introduction

IPv4◦ 32 비트 주소 표현◦ 총 4,294,967,296 개의 유일한 주소를 가짐◦ 10 진수와 구분점으로 표현◦ 각각 8 비트로 4 개의 부분으로 나뉘어짐

IP 주소 지정 스키마

11000000 10101000 01110000 01011011

192 168 112 91. . .

Binary

Dotted Decimal

Page 17: Chapter 1 Introduction

IP Address Range Description

0.0.0.0 – 0.255.255.255

Hosts at current network

10.0.0.0 – 10.255.255.255

For use in private network, e.g. Intranet

127.0.0.0 – 127.255.255.255

Loopback addresses

192.168.0.0 – 192.168.255.255

For use in private network, e.g. Intranet

IP 주소 지정 스키마 특수목적으로 사용되는 IPv4 주소

Page 18: Chapter 1 Introduction

IPv6 데이터 그램 헤더 (RFC 2460)

IP 주소 지정 스키마

Version Traffic Class Flow Label

Payload Length Next Header Hop Limit

Source Address

Destination Address

4 bits 8 bits 8 bits4 bits 8 bits

Page 19: Chapter 1 Introduction

IPv6◦ IPv4 의 주소한계 문제점을 해결◦ 프로토콜의 효율성 향상을 위해 설계됨◦ 128 비트의 주소 길이◦ 총 2128 ≈3.40 × 1038 의 유일한 주소를 가짐◦ IPv6 주소는 콜론과 함께 16 진수로 표현

IP 주소 지정 스키마

0010000000000001

2001 :

Binary

Hexadecimal

0000010111000000 0001000000000000 0000000000001011 0000000000000000 0000000000000000 0000000000000000 0010001111011111

05C0 1000 000B 0000 0000 0000 23DF: : : : : :

Page 20: Chapter 1 Introduction

IPv6 주소 (RFC 4291)◦ 단축 표현

앞에 오는 0 은 생략가능 모두 0 으로 된 부분은 한 개의 0 으로 표현 모두 0 으로 된 부분이 연속으로 올 경우 더블콜론 (::) 으로 표현 Example

2001:05C0:1000:000B:0000:0000:0000:23DF 2001:5C0:1000:B:0:0:0:23DF 2001:5C0:1000:B::23DF

IP 주소 지정 스키마

Page 21: Chapter 1 Introduction

IPv6 의 특수 주소

IP 주소 지정 스키마

IP Address Description

0:0:0:0:0:0:0:0 or :: Unspecified address

0:0:0:0:0:0:0:1 or ::1 Loopback address

FF00::/8 Multicast addresses

Page 22: Chapter 1 Introduction

도메인 네임 시스템 (DNS)◦ DNS 검색을 통해서 도메인 이름을 IP 주소로 번역◦ Ping 명령으로 IP 주소 검색

IP 주소 지정 스키마

Page 23: Chapter 1 Introduction

서버◦ 서비스를 제공하는 머신

클라이언트◦ 서버에 의해 제공되는 서비스를 이용

다양한 네트워크 형태의 기초 Example

◦ Web browser, email application 클라이언트는 서버에 요청을 보내고 난 후 서버로부터 응답을

기다림 서버는 클라이언트의 요청을 처리한 후 다시 클라이언트에게

응답

클라이언트 / 서버 모델

Page 24: Chapter 1 Introduction

IP 네트워크를 통해 데이터가 흘러갈 수 있도록 하는 프로세스에 대한 통신 종단점

서버와 클라이언트 간에 two-way 통신을 용이하게 함 Inter Process Communication (IPC) 을 위해 흔히

사용됨 소켓 구성 요소 :

◦ 프로토콜◦ 송신측 IP 주소◦ 송신측 포트 번호◦ 수신측 IP 주소◦ 수신측 포트 번호

소켓

Page 25: Chapter 1 Introduction

윈도우 네트워크 어플리케이션 프로그래밍을 위한 Application Programming Interface (API)

Berkeley sockets API 에 기초 현재 버전은 Winsock 2 서로 다른 호스트와 프로세스들 간의 통신을 가능하게

함 다른 운영체제에서의 IPC 또한 용이하게 할 수 있음

윈도우 소켓 (Winsock)

Page 26: Chapter 1 Introduction

.NET 프레임 워크는 Windows Sockets API 의 전문화된 버전을 포함

System.Net.Sockets 네임스페이스◦ Winsock 과 비슷한 기능을 제공하는 Socket 클래스를

제공◦ 또한 다음과 같은 높은 레벨의 소켓 추상 클래스를 제공

TcpListener TcpClient UdpClient

.NET 소켓 클래스