Presentation is loading. Please wait.

Presentation is loading. Please wait.

Understand IPv4 Addressing. IPv4: originally Classfull Addressing  Special address  Host ID = 0: network address  Network ID = 0, host ID = 0  i.e.

Similar presentations


Presentation on theme: "Understand IPv4 Addressing. IPv4: originally Classfull Addressing  Special address  Host ID = 0: network address  Network ID = 0, host ID = 0  i.e."— Presentation transcript:

1 Understand IPv4 Addressing

2 IPv4: originally Classfull Addressing  Special address  Host ID = 0: network address  Network ID = 0, host ID = 0  i.e 0.0.0.0 means this network  127.x.y.z : “looped back”  Host ID = all 1s : broadcasting  NAT address  10/8  172.16/12  192.168/12  Broadcast address  255.255.255.255  Limited broadcast  router 밖에는 나가지 못함  190.50.255.255  Network-directed broadcast  그 네트워크까지 가서 네트워크 내에 broadcast  190.50.1.255/24  Subnet-directed broadcast  190.50.1.0/24 subnet 내에 broadcast IPv4 address 는 host 의 address 가 아니라 interface 의 address 이다.

3 Subnet  Network address  IP address && mask  Network ID 223.1.1.1 223.1.1.2 223.1.1.3 223.1.1.4 223.1.2.9 223.1.2.2 223.1.2.1 223.1.3.2 223.1.3.1 223.1.3.27 network consisting of 3 subnets subnet 223.1.1.0/24 223.1.2.0/24 223.1.3.0/24 223.1.0.0/16 CIDR (Classless Inter-Domain Routing)  Subnetting + suppernetting

4 Tip: Develop and Use Application “Skeletons”

5 Simple TCP Client and Server Client: simplec.c Server: simples.c

6 Making UNIX/Windows Compatible UNIX: bsd/skel.hWindows: win/skel.h wincompat.c: Window 에서 socket 을 생성전에 call 해야

7 TCP Server Skeleton tcpserver.skel: “mclab.hufs.ac.kr” or “203.254.68.114” or “” -- server “http” or “80”

8 TCP Server Skeleton - Cont’d Usage: % myserver [local_addr | local_name] {local_port | service} Example: %myserver 15000 %myserver localhost http

9 TCP Client Skeleton tcpclient.skel: Usage: % myclient {peer_addr | peer_name} {peer_port | service} Example: % myclient 203.253.70.5 15000 % myclient www.hufs.ac.kr http

10 UDP Server & Client Skeleton udpserver.skel:udpclient.skel:

11 Build Your Own Library and Use It ! etcp.h

12 TCP Client & Server Starting Functions Host name or IP addr or “” (my addr for server) “http” or “80”

13 UDP Client & Server Starting Functions

14 Remember that TCP is a Stream Protocol

15 TCP is a Stream Protocol  No message boundary, just a byte stream  TCP application 에서 하나의 message 를 send() 했다고 해서 recevier application 에서 그 message 를 한 덩어리로 recv() 되는 것이 아니다.  Message 를 send() 했어도 TCP segment 에 언제, 어떻게 실릴지 모른다. (buffering 되기 때문 )  Recv() 하면 몇 byte 읽힐지 모른다.  If you want to read exactly n bytes ??  If you want to make a record ???  Use end-of-record mark. e.g) new line  Handle variable records (using fixed header) #include /* UNIX */ #include /* Windows */ int recv (SOCKET s, void *buf, size_t bufsize, int flags); int read (SOCKET s, void *buf, size_t bufsize);/* UNIX */ Returns: # of bytes read (>0), 0 if received FIN and no more data, -1 on failure int send (SOCKET s, const void *buf, size_t len, int flags); int write (SOCKET s, const void *buf, size_t len);/* UNIX */ Returns: # of bytes transferred on success, -1 on failure 메시지를 읽을 user buffer 의 크기 즉, 최대로 읽을 수 있는 크기 Socket send buffer 에 저장할 메시지 길이

16 Use End-of-record mark: read a line lib/readline.c:

17 Read n bytes and Read a variable-length record Record Length Other Header Data Variable Data lib/readn.c: lib/readvrec: #include “etcp.h” int readn (SOCKET s, char *buf, size_t len); Returns: # of bytes read, -1 on failure int readvrec (SOCKET s, char *buf, size_t len); Returns: # of bytes read, -1 on failure len cnt bp Header size Network byte order

18 Example: Client/Server using variable records vrc.c: vrs.c:


Download ppt "Understand IPv4 Addressing. IPv4: originally Classfull Addressing  Special address  Host ID = 0: network address  Network ID = 0, host ID = 0  i.e."

Similar presentations


Ads by Google