1 / 18

Understand IPv4 Addressing

Understand IPv4 Addressing. 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

Download Presentation

Understand IPv4 Addressing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. 223.1.0.0/16 Subnet 223.1.1.0/24 223.1.2.0/24 • Network address IP address && mask • Network ID 223.1.1.1 223.1.2.1 223.1.1.2 223.1.2.9 223.1.1.4 223.1.2.2 223.1.1.3 223.1.3.27 subnet 223.1.3.2 223.1.3.1 223.1.3.0/24 network consisting of 3 subnets • CIDR (Classless Inter-Domain Routing) • Subnetting + suppernetting

  4. Tip: Develop and Use Application “Skeletons”

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

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

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

  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 thatTCP 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) 메시지를 읽을 user buffer의 크기 즉, 최대로 읽을 수 있는 크기 #include <sys/socket.h> /* UNIX */ #include <winsock2.h> /* 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 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 lib/readvrec: Network byte order lib/readn.c: Header size len cnt bp #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 Record Length Other Header Data Variable Data

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

More Related