1 / 201

TCP/IP 协议及应用

TCP/IP 协议及应用. 第七章. 主要内容. 协议栈 IP 地址 TCP/IP 协议 IPv6. 1 、 TCP/IP 协议栈. Application. 7. Presentation. 6. Session. 5. Transport. 4. Network. 3. Data link. 2. Physical. 1. 2 、 IP 地址. IPv4. 2.1 IPv4. 2.1 IPv4 逻辑地址分类. 2.1 IPv4 地址范围. 2.1 IPv4- 特殊地址. 网络地址. 2.1 IPv4- 特殊地址.

grazia
Download Presentation

TCP/IP 协议及应用

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. TCP/IP协议及应用 第七章

  2. 主要内容 • 协议栈 • IP地址 • TCP/IP协议 • IPv6

  3. 1、TCP/IP协议栈 Application 7 Presentation 6 Session 5 Transport 4 Network 3 Data link 2 Physical 1

  4. 2、IP地址 • IPv4

  5. 2.1 IPv4

  6. 2.1 IPv4逻辑地址分类

  7. 2.1 IPv4地址范围

  8. 2.1 IPv4-特殊地址 网络地址

  9. 2.1 IPv4-特殊地址 指定网络广播地址(路由器可转发)

  10. 2.1 IPv4-特殊地址 受限广播地址(路由器不转发)

  11. 2.1 IPv4-特殊地址 回环地址

  12. 2.1 IPv4-特殊地址 公共地址 IETF分别从A、B、C三类地址中取出一段地址范围保留用作内部网络地址,他们分别是: 10.0.0.0 ~ 10.255.255.255 172.16.0.0 ~ 172.31.255.255 192.168.0.0 ~ 192.168.255.255 这些地址范围是专门用来标识内部网络的,不能用来访问Internet,因为Internet上路由器不会转发目标地址在上述三个范围内的数据包。

  13. Internet 公共IP地址库 源地址 a3.b3.c3.d3 a1.b1.c1.d1 a2.b2.c2.d2 … an.bn.cn.dn NAT 源地址 x1.x2.x3.x4 专用网 源地址 x1.x2.x3.x4 本地主机 x1.x2.x3.x4 2.1 IPv4-特殊地址 公共地址与Internet的互连

  14. 2.1 IPv4-特殊地址 物理地址(48bits) Ipconfig /all Route Print

  15. 特殊地址小结 • 特殊地址 • 网络地址,不可以用作主机地址 • 广播地址,不可以用作主机地址 • 回环地址 • 公共地址 • 内部地址

  16. 一个主机发送一个分组时如何发现目的地在那里?一个主机发送一个分组时如何发现目的地在那里? • 网络掩码

  17. 2.2 IPv4 Network Mask • Def. 网络掩码:用于标志网络地址和主机地址的代码。 • 不同类型的网络(A、B、C)具有不同的网络掩码 • 255.0.0.0 255.255.0.0 255.255.255.0 • 网络地址的获取:逻辑“与”

  18. 2.2 Sub-Network Mask • 划分网络号和主机边界 • 对子网进行精确的划分,减小子网络空间 • 子网掩码就是将Hostid的一部分作为网络Netid的延伸 • 掩码地址的格式:前N位1+后M位0=32 • 掩码地址“与”IP地址 = 对应子网的“实际网络地址”

  19. 2.2 Sub-Network Mask • 路由特点 • 子网划分对外部的路由器是透明的 • 对子网内部的路由器是不透明的

  20. 202.183.56.xxxxxxxxx 202.183.56.1xxxxxxx 路由器 路由器 202.183.56.0xxxxxxx 子网掩码举例

  21. 子网掩码举例 • 学校将 202.183.56.0(C类地址)分配给两个系,每个系约有120台计算机。 • 掩码地址可定义为:255.255.255.128 • 系1地址范围:202.183.56.1—202.183.56.126 子网地址:11001010 10110111 00111000 0xxxxxxx • 系2地址范围:202.183.56.129—202.183.56.254 子网地址:11001010 10110111 00111000 1xxxxxxx

  22. 思考题: • 已知网络地址202.112.11.0 • 今有A、B、C三个机构需要的ip地址分别为120、60和62个,如何划分子网,子网掩码、地址和ip地址范围是多少?

  23. 3 TCP/IP协议 • 网络层协议: ICMP IGMP ARP RARP • 传输层协议: UDP TCP • 应用层协议: SMTP/POP HTTP DNS FTP…

  24. 不同层次的协议

  25. 数据帧的分用过程

  26. 3.1 网络层协议 • 网络层协议格式头格式 • ARP/RARP • ICMP • IGMP

  27. Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram IPv4 header structure Version (4 bits): tells that this is IP Version 4 (IPv4)

  28. Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram IPv4 header structure Header length (4 bits) is needed since Options+Padding can vary in length. Options:Security (packet classification), Strict source routing (the whole routing list), Loose source routing (the mandatory routing list), Record route (record the IP address of each hop), Timestamp (record the IP address and timestamp of each hop).

  29. IPv4 header structure Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram ToS = Type of Service (8 bits) is used for QoS management purposes. The first 3 bits of TOS indicate priorities, 0 being low (normal packet) and 7 being high (network control packet); the next 3 bits indicate service types, being delay, throughput, and reliability; the last 2 bits are reserved. Source could use service type bits to indicate the routing metrics to be used.

  30. IPv4 header structure Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram Datagram length (16 bits): since this field is 16 bits long, the IP datagram can contain up to 216 = 65535 bytes (in theory). Most routers, however, cannot handle such large datagrams.

  31. IPv4 header structure Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address All fragments contain the same number Has value zero in last fragment Position of fragment in original datagram Destination IP address Options Padding Payload of IP datagram IP fragmentation: a large IP datagram may be fragmented (in any router along the path) and will be reassembled at the destination. Flags: 1st bit – reserved; 2nd bit – DF, 0=fragment yes, 1=fragment no; 3rd bit – MF, 0=last fragment, 1=more fragment. SEU31

  32. IPv4 header structure Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram Time-to-live (8 bits): this number is decreased by one in each router along the path. If number zero is reached in a router, IP datagram is discarded and router sends an ICMP message (TTL expired) to the source of the datagram.

  33. IPv4 header structure Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram Starts here ... Protocol field (8 bits): describes which higher layer protocol is used (TCP, UDP, SCTP ...). The header of this upper protocol is located at the beginning of the IP datagram payload. e.g. 6=TCP, 17=UDP, 1=ICMP, 89=OSPF, etc. SEU33

  34. IPv4 header structure Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram Header checksum (16 bits): used for error control (if used, routers along the path have to recalculate the checksum). This kind of error control is not used in IPv6 (since the same error control function is offered by TCP - and even UDP). SEU34

  35. IPv4 header structure Version IHL Type of Service Total length of IP datagram Identification Flags Fragment offset Time-to-live Protocol Header checksum (for error control) Source IP address Destination IP address Options Padding Payload of IP datagram Source and destination IP address (32 bits each): note that these addresses are not changed in routers along the route. SEU35

  36. 通过捕获的分组查看IP头格式

  37. 地址解析协议(ARP/RARP)

  38. ARP/RARP

  39. ARP帧格式

  40. ARP分组格式 IP 0800 以太网为1 硬件地址长度 协议地址长度

  41. ARP

  42. example broadcast unicast

  43. 使用ARP协议的四种情况

  44. ARP缓存-cache • Arp –a –g –s –d • 主机内设置缓冲区,是为了快速查找 通过主机演示 • Arp -a • Arp –d • Arp –s

  45. C:\Documents and Settings\Administrator>PING 172.18.12.199 Pinging 172.18.12.199 with 32 bytes of data: Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Ping statistics for 172.18.12.199: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Documents and Settings\Administrator>ARP -D C:\Documents and Settings\Administrator>ARP -A No ARP Entries Found C:\Documents and Settings\Administrator>ARP -S 172.18.12.199 00-88-88-88-88-88 C:\Documents and Settings\Administrator>APR -A 'APR' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

  46. C:\Documents and Settings\Administrator>ARP -A • Interface: 172.18.12.192 --- 0x10005 • Internet Address Physical Address Type • 172.18.12.199 00-88-88-88-88-88 static • C:\Documents and Settings\Administrator>PING 172.18.12.199 • Pinging 172.18.12.199 with 32 bytes of data: • Request timed out. • Request timed out. • Request timed out. • Request timed out. • Ping statistics for 172.18.12.199: • Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), • C:\Documents and Settings\Administrator>ARP -D • C:\Documents and Settings\Administrator>ARP -A • No ARP Entries Found

  47. C:\Documents and Settings\Administrator>PING 172.18.12.199 Pinging 172.18.12.199 with 32 bytes of data: Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Reply from 172.18.12.199: bytes=32 time<1ms TTL=128 Ping statistics for 172.18.12.199: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Documents and Settings\Administrator>

More Related