当前位置:文档之家› MPLS域中TRACEROUTE分析

MPLS域中TRACEROUTE分析

MPLS域中TRACEROUTE分析
MPLS域中TRACEROUTE分析

MPLS 域中TRACEROUTE 分析

1. 网络图如下:

R1 是CE ,R2 是PE1,R3,R4,R5,皆是CORE 路由器,R6是PE2。 R1与R2运行的EBGP ,R2与R6运行的是IBGP 。 R2,R3,R4,R5,R6之间运行OSPF 协议。 地址表如下

2.2.2.2 ,

3.3.3.3 ,

4.4.4.4,

5.5.5.5,

6.6.6.6 23.23.23.0 34.34.34.0 45.45.45.0

56.56.56.0

BGP 通告的地址有:

1.1.1.1,

2.2.2.2, 6.6.6.6, 66.66.66.66

用LOOPBACK0 作为SOURCE 源地址: 2. 下面是每个路由器的路由表:

R1

R1#show ip route

Codes: C - connected, S - static, I - IGRP , R - RIP , M - mobile, B - BGP D - EIGRP , EX - EIGRP external, O - OSPF , IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route

R1

R2 R3

R4 R5

R6

Gateway of last resort is not set

1.0.0.0/32 is subnetted, 1 subnets

C 1.1.1.1 is directly connected, Loopback0

2.0.0.0/32 is subnetted, 1 subnets

S 2.2.2.2 is directly connected, Serial1/0

66.0.0.0/32 is subnetted, 1 subnets

B 66.66.66.66 [20/0] via 2.2.2.2, 00:03:46

6.0.0.0/32 is subnetted, 1 subnets

B 6.6.6.6 [20/0] via 2.2.2.2, 00:03:46

12.0.0.0/24 is subnetted, 1 subnets

C 12.12.12.0 is directly connected, Serial1/0

R2

R2#show mpls forwarding-table

Local Outgoing Prefix Bytes tag Outgoing Next Hop tag tag or VC or Tunnel Id switched interface

16 Untagged 1.1.1.1/32 0 Se1/0 point2point

17 Pop tag 3.3.3.3/32 0 Se1/1 point2point

18 17 4.4.4.4/32 0 Se1/1 point2point

19 Pop tag 34.34.34.0/24 0 Se1/1 point2point

20 18 45.45.45.0/24 0 Se1/1 point2point

21 19 5.5.5.5/32 0 Se1/1 point2point

22 21 6.6.6.6/32 0 Se1/1 point2point

23 20 56.56.56.0/24 0 Se1/1 point2point R2#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default, U - per-user static route, o - ODR

P - periodic downloaded static route

Gateway of last resort is not set

34.0.0.0/24 is subnetted, 1 subnets

O 34.34.34.0 [110/128] via 23.23.23.2, 00:04:14, Serial1/1

1.0.0.0/32 is subnetted, 1 subnets

S 1.1.1.1 is directly connected, Serial1/0

2.0.0.0/32 is subnetted, 1 subnets

C 2.2.2.2 is directly connected, Loopback0

3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/65] via 23.23.23.2, 00:04:14, Serial1/1

4.0.0.0/32 is subnetted, 1 subnets

O 4.4.4.4 [110/129] via 23.23.23.2, 00:04:14, Serial1/1

5.0.0.0/32 is subnetted, 1 subnets

O 5.5.5.5 [110/193] via 23.23.23.2, 00:04:14, Serial1/1

66.0.0.0/32 is subnetted, 1 subnets

B 66.66.66.66 [200/0] via 6.6.6.6, 00:03:52

6.0.0.0/32 is subnetted, 1 subnets

O 6.6.6.6 [110/257] via 23.23.23.2, 00:04:16, Serial1/1

23.0.0.0/24 is subnetted, 1 subnets

C 23.23.23.0 is directly connected, Serial1/1

56.0.0.0/24 is subnetted, 1 subnets

O 56.56.56.0 [110/256] via 23.23.23.2, 00:04:16, Serial1/1

12.0.0.0/24 is subnetted, 1 subnets

C 12.12.12.0 is directly connected, Serial1/0

45.0.0.0/24 is subnetted, 1 subnets

O 45.45.45.0 [110/192] via 23.23.23.2, 00:04:16, Serial1/1

R3

R3#show mpls forwarding-table

Local Outgoing Prefix Bytes tag Outgoing Next Hop tag tag or VC or Tunnel Id switched interface

16 Pop tag 2.2.2.2/32 256 Se1/0 point2point

17 Pop tag 4.4.4.4/32 0 Se1/1 point2point

18 Pop tag 45.45.45.0/24 0 Se1/1 point2point

19 18 5.5.5.5/32 0 Se1/1 point2point

20 20 56.56.56.0/24 0 Se1/1 point2point

21 21 6.6.6.6/32 713 Se1/1 point2point R3#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default, U - per-user static route, o - ODR

P - periodic downloaded static route

Gateway of last resort is not set

34.0.0.0/24 is subnetted, 1 subnets

C 34.34.34.0 is directly connected, Serial1/1

2.0.0.0/32 is subnetted, 1 subnets

O 2.2.2.2 [110/65] via 23.23.23.1, 00:04:32, Serial1/0

3.0.0.0/32 is subnetted, 1 subnets

C 3.3.3.3 is directly connected, Loopback0

4.0.0.0/32 is subnetted, 1 subnets

O 4.4.4.4 [110/65] via 34.34.34.2, 00:04:32, Serial1/1

O 5.5.5.5 [110/129] via 34.34.34.2, 00:04:32, Serial1/1

6.0.0.0/32 is subnetted, 1 subnets

O 6.6.6.6 [110/193] via 34.34.34.2, 00:04:32, Serial1/1

23.0.0.0/24 is subnetted, 1 subnets

C 23.23.23.0 is directly connected, Serial1/0

56.0.0.0/24 is subnetted, 1 subnets

O 56.56.56.0 [110/192] via 34.34.34.2, 00:04:33, Serial1/1

45.0.0.0/24 is subnetted, 1 subnets

O 45.45.45.0 [110/128] via 34.34.34.2, 00:04:33, Serial1/1

R3#

R4

R4#show mpls forwarding-table

Local Outgoing Prefix Bytes tag Outgoing Next Hop tag tag or VC or Tunnel Id switched interface

16 16 2.2.2.2/32 502 Se1/0 point2point

17 Pop tag 3.3.3.3/32 0 Se1/0 point2point

18 Pop tag 5.5.5.5/32 0 Se1/1 point2point

19 Pop tag 23.23.23.0/24 0 Se1/0 point2point

20 Pop tag 56.56.56.0/24 0 Se1/1 point2point

21 21 6.6.6.6/32 943 Se1/1 point2point R4#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default, U - per-user static route, o - ODR

P - periodic downloaded static route

Gateway of last resort is not set

34.0.0.0/24 is subnetted, 1 subnets

C 34.34.34.0 is directly connected, Serial1/0

2.0.0.0/32 is subnetted, 1 subnets

O 2.2.2.2 [110/129] via 34.34.34.1, 00:04:40, Serial1/0

3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/65] via 34.34.34.1, 00:04:40, Serial1/0

4.0.0.0/32 is subnetted, 1 subnets

C 4.4.4.4 is directly connected, Loopback0

5.0.0.0/32 is subnetted, 1 subnets

O 5.5.5.5 [110/65] via 45.45.45.2, 00:04:40, Serial1/1

O 6.6.6.6 [110/129] via 45.45.45.2, 00:04:40, Serial1/1

23.0.0.0/24 is subnetted, 1 subnets

O 23.23.23.0 [110/128] via 34.34.34.1, 00:04:41, Serial1/0

56.0.0.0/24 is subnetted, 1 subnets

O 56.56.56.0 [110/128] via 45.45.45.2, 00:04:41, Serial1/1

45.0.0.0/24 is subnetted, 1 subnets

C 45.45.45.0 is directly connected, Serial1/1

R5

R5#show mpls forwarding-table

Local Outgoing Prefix Bytes tag Outgoing Next Hop tag tag or VC or Tunnel Id switched interface

16 16 2.2.2.2/32 502 Se1/0 point2point

17 17 3.3.3.3/32 0 Se1/0 point2point

18 Pop tag 4.4.4.4/32 0 Se1/0 point2point

19 19 23.23.23.0/24 0 Se1/0 point2point

20 Pop tag 34.34.34.0/24 0 Se1/0 point2point

21 Pop tag 6.6.6.6/32 469 Se1/1 point2point R5#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default, U - per-user static route, o - ODR

P - periodic downloaded static route

Gateway of last resort is not set

34.0.0.0/24 is subnetted, 1 subnets

O 34.34.34.0 [110/128] via 45.45.45.1, 00:04:48, Serial1/0

2.0.0.0/32 is subnetted, 1 subnets

O 2.2.2.2 [110/193] via 45.45.45.1, 00:04:48, Serial1/0

3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/129] via 45.45.45.1, 00:04:48, Serial1/0

4.0.0.0/32 is subnetted, 1 subnets

O 4.4.4.4 [110/65] via 45.45.45.1, 00:04:48, Serial1/0

5.0.0.0/32 is subnetted, 1 subnets

C 5.5.5.5 is directly connected, Loopback0

6.0.0.0/32 is subnetted, 1 subnets

O 6.6.6.6 [110/65] via 56.56.56.2, 00:04:48, Serial1/1

23.0.0.0/24 is subnetted, 1 subnets

O 23.23.23.0 [110/192] via 45.45.45.1, 00:04:49, Serial1/0

56.0.0.0/24 is subnetted, 1 subnets

C 56.56.56.0 is directly connected, Serial1/1

45.0.0.0/24 is subnetted, 1 subnets

C 45.45.45.0 is directly connected, Serial1/0

R6

R6#show mpls forwarding-table

Local Outgoing Prefix Bytes tag Outgoing Next Hop tag tag or VC or Tunnel Id switched interface

16 16 2.2.2.2/32 0 Se1/0 point2point

17 17 3.3.3.3/32 0 Se1/0 point2point

18 18 4.4.4.4/32 0 Se1/0 point2point

19 Pop tag 5.5.5.5/32 0 Se1/0 point2point

20 19 23.23.23.0/24 0 Se1/0 point2point

21 20 34.34.34.0/24 0 Se1/0 point2point

22 Pop tag 45.45.45.0/24 0 Se1/0 point2point R6#show ip cef 1.1.1.1 det

R6#show ip cef 1.1.1.1 detail

1.1.1.1/32, version 17, epoch 0, cached adjacency to Serial1/0

0 packets, 0 bytes

tag information from 2.2.2.2/32, shared

local tag: 16

fast tag rewrite with Se1/0, point2point, tags imposed: {16}

via 2.2.2.2, 0 dependencies, recursive

next hop 56.56.56.1, Serial1/0 via 2.2.2.2/32

valid cached adjacency

tag rewrite with Se1/0, point2point, tags imposed: {16}

R6#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default, U - per-user static route, o - ODR

P - periodic downloaded static route

Gateway of last resort is not set

34.0.0.0/24 is subnetted, 1 subnets

O 34.34.34.0 [110/192] via 56.56.56.1, 00:05:05, Serial1/0

1.0.0.0/32 is subnetted, 1 subnets

B 1.1.1.1 [200/0] via 2.2.2.2, 00:04:32

2.0.0.0/32 is subnetted, 1 subnets

O 2.2.2.2 [110/257] via 56.56.56.1, 00:05:05, Serial1/0

3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/193] via 56.56.56.1, 00:05:05, Serial1/0

4.0.0.0/32 is subnetted, 1 subnets

O 4.4.4.4 [110/129] via 56.56.56.1, 00:05:05, Serial1/0

5.0.0.0/32 is subnetted, 1 subnets

O 5.5.5.5 [110/65] via 56.56.56.1, 00:05:05, Serial1/0

66.0.0.0/32 is subnetted, 1 subnets

C 66.66.66.66 is directly connected, Loopback1

6.0.0.0/32 is subnetted, 1 subnets

C 6.6.6.6 is directly connected, Loopback0

23.0.0.0/24 is subnetted, 1 subnets

O 23.23.23.0 [110/256] via 56.56.56.1, 00:05:06, Serial1/0

56.0.0.0/24 is subnetted, 1 subnets

C 56.56.56.0 is directly connected, Serial1/0

45.0.0.0/24 is subnetted, 1 subnets

O 45.45.45.0 [110/128] via 56.56.56.1, 00:05:06, Serial1/0

R1#traceroute

Protocol [ip]:

Target IP address: 66.66.66.66

Source address: 1.1.1.1

Numeric display [n]:

Timeout in seconds [3]:

Probe count [3]:

Minimum Time to Live [1]:

Maximum Time to Live [30]:

Port Number [33434]:

Loose, Strict, Record, Timestamp, V erbose[none]: v

Loose, Strict, Record, Timestamp, V erbose[V]:

Type escape sequence to abort.

Tracing the route to 66.66.66.66

1 12.12.12.

2 64 msec 60 msec 24 msec

2 23.23.23.2 [MPLS: Label 21 Exp 0] 180 msec 152 msec 160 msec

3 34.34.34.2 [MPLS: Label 21 Exp 0] 216 msec 180 msec 14

4 msec

4 * * *

5 56.56.56.2 188 msec * 204 msec

R1#

下面以R3回答进行分析:

R1 的发出TRACEROUTE 包TTL=2, 经过R2之后TTL=1,到达R3时TTL减去1,变成0, 此包丢弃,R3产生ICMP Time-to-live exceeded (Time to live exceeded in transit)给R1

由于R3并没有到达R1的路由, 借助MPLS 的LABEL 将ICMP Time-to-live exceeded包发给R6,再从R6再通过R3给R1.

下面是包的分析:

R1产生TRACEROUTE 包:注意此包的标记Identification: 0x0024 (36)

No. Time Source Destination Protocol Info

53 167.687000 1.1.1.1 66.66.66.66 UDP Source port: 38895 Destination port: 33437

Frame 53: 32 bytes on wire (256 bits), 32 bytes captured (256 bits)

Arrival Time: Jul 22, 2011 21:14:58.030750000 中国标准时间

Epoch Time: 1311340498.030750000 seconds

[Time delta from previous captured frame: 0.016000000 seconds]

[Time delta from previous displayed frame: 0.016000000 seconds]

[Time since reference or first frame: 167.687000000 seconds]

Frame Number: 53

Frame Length: 32 bytes (256 bits)

Capture Length: 32 bytes (256 bits)

[Frame is marked: False]

[Frame is ignored: False]

[Protocols in frame: chdlc:ip:udp:mp2t]

[Coloring Rule Name: TTL low or unexpected]

[Coloring Rule String: ( ! ip.dst == 224.0.0.0/4 && ip.ttl < 5 && !pim) || (ip.dst == 224.0.0.0/24 && ip.ttl != 1)]

Cisco HDLC

Address: Unicast (0x0f)

Protocol: IP (0x0800)

Internet Protocol, Src: 1.1.1.1 (1.1.1.1), Dst: 66.66.66.66 (66.66.66.66)

V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)

0000 00.. = Differentiated Services Codepoint: Default (0x00)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 28

Identification: 0x0024 (36)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 2

[Expert Info (Note/Sequence): "Time To Live" only 2]

[Message: "Time To Live" only 2]

[Severity level: Note]

[Group: Sequence]

Protocol: UDP (17)

Header checksum: 0x3228 [correct]

[Good: True]

[Bad: False]

Source: 1.1.1.1 (1.1.1.1)

Destination: 66.66.66.66 (66.66.66.66)

User Datagram Protocol, Src Port: 38895 (38895), Dst Port: 33437 (33437)

Source port: 38895 (38895)

Destination port: 33437 (33437)

Length: 8

Checksum: 0x5ecb [validation disabled]

[Good Checksum: False]

[Bad Checksum: False]

到达R3时: R3看到LABEL 是21,同时TTL是1,TTL减去1,变为0,丢弃,产生产生ICMP Time-to-live exceeded (Time to live exceeded in transit)给R1.注意地址有所改变,

No. Time Source Destination Protocol Info 125 121.297000 1.1.1.1 66.66.66.66 UDP Source port: 38895 Destination port: 33437

Frame 125: 36 bytes on wire (288 bits), 36 bytes captured (288 bits)

Arrival Time: Jul 22, 2011 21:14:58.042750000 中国标准时间

Epoch Time: 1311340498.042750000 seconds

[Time delta from previous captured frame: 1.313000000 seconds]

[Time delta from previous displayed frame: 1.313000000 seconds]

[Time since reference or first frame: 121.297000000 seconds]

Frame Number: 125

Frame Length: 36 bytes (288 bits)

Capture Length: 36 bytes (288 bits)

[Frame is marked: False]

[Frame is ignored: False]

[Protocols in frame: chdlc:mpls:pwethheuristic:pwethcw:ip:udp:mp2t]

[Coloring Rule Name: TTL low or unexpected]

[Coloring Rule String: ( ! ip.dst == 224.0.0.0/4 && ip.ttl < 5 && !pim) || (ip.dst == 224.0.0.0/24 && ip.ttl != 1)]

Cisco HDLC

Address: Unicast (0x0f)

Protocol: MPLS unicast (0x8847)

MultiProtocol Label Switching Header, Label: 21, Exp: 0, S: 1, TTL: 1

MPLS Label: 21

MPLS Experimental Bits: 0

MPLS Bottom Of Label Stack: 1

MPLS TTL: 1

Internet Protocol, Src: 1.1.1.1 (1.1.1.1), Dst: 66.66.66.66 (66.66.66.66)

V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)

0000 00.. = Differentiated Services Codepoint: Default (0x00)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 28

Identification: 0x0024 (36)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 1

[Expert Info (Note/Sequence): "Time To Live" only 1]

[Message: "Time To Live" only 1]

[Severity level: Note]

[Group: Sequence]

Protocol: UDP (17)

Header checksum: 0x3328 [correct]

[Good: True]

[Bad: False]

Source: 1.1.1.1 (1.1.1.1)

Destination: 66.66.66.66 (66.66.66.66)

User Datagram Protocol, Src Port: 38895 (38895), Dst Port: 33437 (33437)

Source port: 38895 (38895)

Destination port: 33437 (33437)

Length: 8

Checksum: 0x5ecb [validation disabled]

[Good Checksum: False]

[Bad Checksum: False]

到达R3时: R3看到LABEL 是21,同时TTL是1,TTL减去1,变为0,丢弃,产生产生ICMP Time-to-live exceeded (Time to live exceeded in transit)给R1.注意地址有所改变,

同时以进入LABEL 是21,去查找MPLS表.得出口SERIAL1/1 标签为21

同时TTL=255,我们假定此包叫A包.我们观察它的路经. 注意A包Identification: 0x027a

(634)

它是Identification: 0x0024包的回答.

No. Time Source Destination Protocol Info

142 135.281000 23.23.23.2 1.1.1.1 ICMP

Time-to-live exceeded (Time to live exceeded in transit)

Frame 142: 176 bytes on wire (1408 bits), 176 bytes captured (1408 bits)

Arrival Time: Jul 22, 2011 21:14:58.057750000 中国标准时间

Epoch Time: 1311340498.057750000 seconds

[Time delta from previous captured frame: 0.047000000 seconds]

[Time delta from previous displayed frame: 0.047000000 seconds]

[Time since reference or first frame: 135.281000000 seconds]

Frame Number: 142

Frame Length: 176 bytes (1408 bits)

Capture Length: 176 bytes (1408 bits)

[Frame is marked: False]

[Frame is ignored: False]

[Protocols in frame: chdlc:mpls:pwethheuristic:pwethcw:ip:icmp:ip:udp]

[Coloring Rule Name: ICMP errors]

[Coloring Rule String: icmp.type eq 3 || icmp.type eq 4 || icmp.type eq 5 || icmp.type eq 11] Cisco HDLC

Address: Multicast (0x8f)

Protocol: MPLS unicast (0x8847)

MultiProtocol Label Switching Header, Label: 21, Exp: 6, S: 1, TTL: 255

MPLS Label: 21

MPLS Experimental Bits: 6

MPLS Bottom Of Label Stack: 1

MPLS TTL: 255

Internet Protocol, Src: 23.23.23.2 (23.23.23.2), Dst: 1.1.1.1 (1.1.1.1)

V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0xc0 (DSCP 0x30: Class Selector 6; ECN: 0x00) 1100 00.. = Differentiated Services Codepoint: Class Selector 6 (0x30)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 168

Identification: 0x027a (634)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 255

Protocol: ICMP (1)

Header checksum: 0x8800 [correct]

[Good: True]

[Bad: False]

Source: 23.23.23.2 (23.23.23.2)

Destination: 1.1.1.1 (1.1.1.1)

Internet Control Message Protocol

Type: 11 (Time-to-live exceeded)

Code: 0 (Time to live exceeded in transit)

Checksum: 0x7b9f [correct]

Internet Protocol, Src: 1.1.1.1 (1.1.1.1), Dst: 66.66.66.66 (66.66.66.66) V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) 0000 00.. = Differentiated Services Codepoint: Default (0x00)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 28

Identification: 0x0024 (36)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 1

[Expert Info (Note/Sequence): "Time To Live" only 1]

[Message: "Time To Live" only 1]

[Severity level: Note]

[Group: Sequence]

Protocol: UDP (17)

Header checksum: 0x3328 [correct]

[Good: True]

[Bad: False]

Source: 1.1.1.1 (1.1.1.1)

Destination: 66.66.66.66 (66.66.66.66)

User Datagram Protocol, Src Port: 38895 (38895), Dst Port: 33437 (33437) Source port: 38895 (38895)

Destination port: 33437 (33437)

Length: 8

Checksum: 0x5ecb [validation disabled]

[Good Checksum: False]

[Bad Checksum: False]

MPLS Extensions

V ersion: 2

Reserved: 0x000

Checksum: 0x8df4 [correct]

MPLS Stack Entry

Length: 0x0008

Class: 1

C-Type: 1

Label: 21, Exp: 0, S: 1, TTL: 1

0000 0000 0000 0001 0101 .... = Label: 21

.... .... .... .... .... 000. = Experimental: 0

.... .... .... .... .... ...1 = Stack bit: Set

Time to live: 1

A包到达R4.R4通过入LABEL =21检查MPLS FORWARD TABLE.

得到出LABEL=21,

No. Time Source Destination Protocol Info 103 100.297000 23.23.23.2 1.1.1.1 ICMP Time-to-live exceeded (Time to live exceeded in transit)

Frame 103: 176 bytes on wire (1408 bits), 176 bytes captured (1408 bits)

Arrival Time: Jul 22, 2011 21:14:58.104750000 中国标准时间

Epoch Time: 1311340498.104750000 seconds

[Time delta from previous captured frame: 0.640000000 seconds]

[Time delta from previous displayed frame: 0.640000000 seconds]

[Time since reference or first frame: 100.297000000 seconds]

Frame Number: 103

Frame Length: 176 bytes (1408 bits)

Capture Length: 176 bytes (1408 bits)

[Frame is marked: False]

[Frame is ignored: False]

[Protocols in frame: chdlc:mpls:pwethheuristic:pwethcw:ip:icmp:ip:udp]

[Coloring Rule Name: ICMP errors]

[Coloring Rule String: icmp.type eq 3 || icmp.type eq 4 || icmp.type eq 5 || icmp.type eq 11] Cisco HDLC

Address: Unicast (0x0f)

Protocol: MPLS unicast (0x8847)

MultiProtocol Label Switching Header, Label: 21, Exp: 6, S: 1, TTL: 254

MPLS Label: 21

MPLS Experimental Bits: 6

MPLS Bottom Of Label Stack: 1

MPLS TTL: 254

Internet Protocol, Src: 23.23.23.2 (23.23.23.2), Dst: 1.1.1.1 (1.1.1.1)

V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0xc0 (DSCP 0x30: Class Selector 6; ECN: 0x00) 1100 00.. = Differentiated Services Codepoint: Class Selector 6 (0x30)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 168

Identification: 0x027a (634)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 255

Protocol: ICMP (1)

Header checksum: 0x8800 [correct]

[Good: True]

[Bad: False]

Source: 23.23.23.2 (23.23.23.2)

Destination: 1.1.1.1 (1.1.1.1)

Internet Control Message Protocol

Type: 11 (Time-to-live exceeded)

Code: 0 (Time to live exceeded in transit)

Checksum: 0x7b9f [correct]

Internet Protocol, Src: 1.1.1.1 (1.1.1.1), Dst: 66.66.66.66 (66.66.66.66) V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) 0000 00.. = Differentiated Services Codepoint: Default (0x00)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 28

Identification: 0x0024 (36)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 1

[Expert Info (Note/Sequence): "Time To Live" only 1]

[Message: "Time To Live" only 1]

[Severity level: Note]

[Group: Sequence]

Protocol: UDP (17)

Header checksum: 0x3328 [correct]

[Good: True]

[Bad: False]

Source: 1.1.1.1 (1.1.1.1)

Destination: 66.66.66.66 (66.66.66.66)

User Datagram Protocol, Src Port: 38895 (38895), Dst Port: 33437 (33437) Source port: 38895 (38895)

Destination port: 33437 (33437)

Length: 8

Checksum: 0x5ecb [validation disabled]

[Good Checksum: False]

[Bad Checksum: False]

MPLS Extensions

V ersion: 2

Reserved: 0x000

Checksum: 0x8df4 [correct]

MPLS Stack Entry

Length: 0x0008

Class: 1

C-Type: 1

Label: 21, Exp: 0, S: 1, TTL: 1

0000 0000 0000 0001 0101 .... = Label: 21

.... .... .... .... .... 000. = Experimental: 0

.... .... .... .... .... ...1 = Stack bit: Set

Time to live: 1

A包到达R5.R5通过入LABEL =21检查MPLS FORWARD TABLE.

得到出LABEL=POP TAG ,从SERIAL 1/1 送出.

No. Time Source Destination Protocol Info

85 79.047000 23.23.23.2 1.1.1.1 ICMP Time-to-live exceeded (Time to live exceeded in transit)

Frame 85: 172 bytes on wire (1376 bits), 172 bytes captured (1376 bits)

Arrival Time: Jul 22, 2011 21:14:58.104625000 中国标准时间

Epoch Time: 1311340498.104625000 seconds

[Time delta from previous captured frame: 0.343000000 seconds]

[Time delta from previous displayed frame: 0.343000000 seconds]

[Time since reference or first frame: 79.047000000 seconds]

Frame Number: 85

Frame Length: 172 bytes (1376 bits)

Capture Length: 172 bytes (1376 bits)

[Frame is marked: False]

[Frame is ignored: False]

[Protocols in frame: chdlc:ip:icmp:ip:udp]

[Coloring Rule Name: ICMP errors]

[Coloring Rule String: icmp.type eq 3 || icmp.type eq 4 || icmp.type eq 5 || icmp.type eq 11] Cisco HDLC

Address: Unicast (0x0f)

Protocol: IP (0x0800)

Internet Protocol, Src: 23.23.23.2 (23.23.23.2), Dst: 1.1.1.1 (1.1.1.1)

V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0xc0 (DSCP 0x30: Class Selector 6; ECN: 0x00) 1100 00.. = Differentiated Services Codepoint: Class Selector 6 (0x30)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 168

Identification: 0x027a (634)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 253

Protocol: ICMP (1)

Header checksum: 0x8a00 [correct]

[Good: True]

[Bad: False]

Source: 23.23.23.2 (23.23.23.2)

Destination: 1.1.1.1 (1.1.1.1)

Internet Control Message Protocol

Type: 11 (Time-to-live exceeded)

Code: 0 (Time to live exceeded in transit)

Checksum: 0x7b9f [correct]

Internet Protocol, Src: 1.1.1.1 (1.1.1.1), Dst: 66.66.66.66 (66.66.66.66) V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) 0000 00.. = Differentiated Services Codepoint: Default (0x00)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 28

Identification: 0x0024 (36)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 1

[Expert Info (Note/Sequence): "Time To Live" only 1]

[Message: "Time To Live" only 1]

[Severity level: Note]

[Group: Sequence]

Protocol: UDP (17)

Header checksum: 0x3328 [correct]

[Good: True]

[Bad: False]

Source: 1.1.1.1 (1.1.1.1)

Destination: 66.66.66.66 (66.66.66.66)

User Datagram Protocol, Src Port: 38895 (38895), Dst Port: 33437 (33437) Source port: 38895 (38895)

Destination port: 33437 (33437)

Length: 8

Checksum: 0x5ecb [validation disabled]

[Good Checksum: False]

[Bad Checksum: False]

MPLS Extensions

V ersion: 2

Reserved: 0x000

Checksum: 0x8df4 [correct]

MPLS Stack Entry

Length: 0x0008

Class: 1

C-Type: 1

Label: 21, Exp: 0, S: 1, TTL: 1

0000 0000 0000 0001 0101 .... = Label: 21

.... .... .... .... .... 000. = Experimental: 0

.... .... .... .... .... ...1 = Stack bit: Set

Time to live: 1

A包到达R6时,R6检查目的地为1.1.1.1,通过IP CEF 表查得压入LABEL=16,

从SERIAL1/0送出.

No. Time Source Destination Protocol Info

60 53.813000 23.23.23.2 1.1.1.1 ICMP Time-to-live exceeded (Time to live exceeded in transit)

Frame 60: 176 bytes on wire (1408 bits), 176 bytes captured (1408 bits)

Arrival Time: Jul 22, 2011 21:14:58.120625000 中国标准时间

Epoch Time: 1311340498.120625000 seconds

[Time delta from previous captured frame: 0.016000000 seconds]

[Time delta from previous displayed frame: 0.016000000 seconds]

[Time since reference or first frame: 53.813000000 seconds]

Frame Number: 60

Frame Length: 176 bytes (1408 bits)

Capture Length: 176 bytes (1408 bits)

[Frame is marked: False]

[Frame is ignored: False]

[Protocols in frame: chdlc:mpls:pwethheuristic:pwethcw:ip:icmp:ip:udp]

[Coloring Rule Name: ICMP errors]

[Coloring Rule String: icmp.type eq 3 || icmp.type eq 4 || icmp.type eq 5 || icmp.type eq 11] Cisco HDLC

Address: Unicast (0x0f)

Protocol: MPLS unicast (0x8847)

MultiProtocol Label Switching Header, Label: 16, Exp: 6, S: 1, TTL: 252

MPLS Label: 16

MPLS Experimental Bits: 6

MPLS Bottom Of Label Stack: 1

MPLS TTL: 252

Internet Protocol, Src: 23.23.23.2 (23.23.23.2), Dst: 1.1.1.1 (1.1.1.1) V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0xc0 (DSCP 0x30: Class Selector 6; ECN: 0x00) 1100 00.. = Differentiated Services Codepoint: Class Selector 6 (0x30)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 168

Identification: 0x027a (634)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 252

Protocol: ICMP (1)

Header checksum: 0x8b00 [correct]

[Good: True]

[Bad: False]

Source: 23.23.23.2 (23.23.23.2)

Destination: 1.1.1.1 (1.1.1.1)

Internet Control Message Protocol

Type: 11 (Time-to-live exceeded)

Code: 0 (Time to live exceeded in transit)

Checksum: 0x7b9f [correct]

Internet Protocol, Src: 1.1.1.1 (1.1.1.1), Dst: 66.66.66.66 (66.66.66.66) V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) 0000 00.. = Differentiated Services Codepoint: Default (0x00)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 28

Identification: 0x0024 (36)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 1

[Expert Info (Note/Sequence): "Time To Live" only 1]

[Message: "Time To Live" only 1]

[Severity level: Note]

[Group: Sequence]

Protocol: UDP (17)

Header checksum: 0x3328 [correct]

[Good: True]

[Bad: False]

Source: 1.1.1.1 (1.1.1.1)

Destination: 66.66.66.66 (66.66.66.66)

User Datagram Protocol, Src Port: 38895 (38895), Dst Port: 33437 (33437)

Source port: 38895 (38895)

Destination port: 33437 (33437)

Length: 8

Checksum: 0x5ecb [validation disabled]

[Good Checksum: False]

[Bad Checksum: False]

MPLS Extensions

V ersion: 2

Reserved: 0x000

Checksum: 0x8df4 [correct]

MPLS Stack Entry

Length: 0x0008

Class: 1

C-Type: 1

Label: 21, Exp: 0, S: 1, TTL: 1

0000 0000 0000 0001 0101 .... = Label: 21

.... .... .... .... .... 000. = Experimental: 0

.... .... .... .... .... ...1 = Stack bit: Set

Time to live: 1

A包反向经过R5,R4,到达R3, LABEL=16,TTL=250.

R3查MPLS FORWARD 表,得到LABEL=POP TAG, 从SERIAL1/0送出.

No. Time Source Destination Protocol Info 143 135.406000 23.23.23.2 1.1.1.1 ICMP Time-to-live exceeded (Time to live exceeded in transit)

Frame 143: 176 bytes on wire (1408 bits), 176 bytes captured (1408 bits)

Arrival Time: Jul 22, 2011 21:14:58.182750000 中国标准时间

Epoch Time: 1311340498.182750000 seconds

[Time delta from previous captured frame: 0.125000000 seconds]

[Time delta from previous displayed frame: 0.125000000 seconds]

[Time since reference or first frame: 135.406000000 seconds]

Frame Number: 143

Frame Length: 176 bytes (1408 bits)

Capture Length: 176 bytes (1408 bits)

[Frame is marked: False]

[Frame is ignored: False]

[Protocols in frame: chdlc:mpls:pwethheuristic:pwethcw:ip:icmp:ip:udp]

[Coloring Rule Name: ICMP errors]

[Coloring Rule String: icmp.type eq 3 || icmp.type eq 4 || icmp.type eq 5 || icmp.type eq 11] Cisco HDLC

Address: Unicast (0x0f)

Protocol: MPLS unicast (0x8847)

MultiProtocol Label Switching Header, Label: 16, Exp: 6, S: 1, TTL: 250

MPLS Label: 16

MPLS Experimental Bits: 6

MPLS Bottom Of Label Stack: 1

MPLS TTL: 250

Internet Protocol, Src: 23.23.23.2 (23.23.23.2), Dst: 1.1.1.1 (1.1.1.1)

V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0xc0 (DSCP 0x30: Class Selector 6; ECN: 0x00) 1100 00.. = Differentiated Services Codepoint: Class Selector 6 (0x30)

.... ..0. = ECN-Capable Transport (ECT): 0

.... ...0 = ECN-CE: 0

Total Length: 168

Identification: 0x027a (634)

Flags: 0x00

0... .... = Reserved bit: Not set

.0.. .... = Don't fragment: Not set

..0. .... = More fragments: Not set

Fragment offset: 0

Time to live: 252

Protocol: ICMP (1)

Header checksum: 0x8b00 [correct]

[Good: True]

[Bad: False]

Source: 23.23.23.2 (23.23.23.2)

Destination: 1.1.1.1 (1.1.1.1)

Internet Control Message Protocol

Type: 11 (Time-to-live exceeded)

Code: 0 (Time to live exceeded in transit)

Checksum: 0x7b9f [correct]

Internet Protocol, Src: 1.1.1.1 (1.1.1.1), Dst: 66.66.66.66 (66.66.66.66)

V ersion: 4

Header length: 20 bytes

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)

0000 00.. = Differentiated Services Codepoint: Default (0x00)

.... ..0. = ECN-Capable Transport (ECT): 0

2016Linux程序设计复习题

一、填空题 1、在Linux 系统中,以文件方式访问设备。 2、Linux 内核引导时,从文件/etc/fstab 中读取要加载的文件系统。 3、Linux 文件系统中每个文件用i 节点来标识。 4、全部磁盘块由四个部分组成,分别为引导块、专用块、i 节点表块和数据存储块。 5、链接分为:硬链接和符号链接。 6、超级块包含了i 节点表和空闲块表等重要的文件系统信息。 7、某文件的权限为:drw-r--r-- ,用数值形式表示该权限,则该八进制数为:644 ,该文件属性是目录。 8、前台起动的进程使用Ctrl+C 终止。 9、静态路由设定后,若网络拓扑结构发生变化,需由系统管理员修改路由的设置。 10、网络管理的重要任务是:控制和监控。 11、安装Linux 系统对硬盘分区时,必须有两种分区类型:文件系统分区和交换分区。 12、编写的Shell 程序运行前必须赋予该脚本文件执行权限。 13、系统管理的任务之一是能够在分布式环境中实现对程序和数据的安全 保护、备份、恢复和更新。 14、系统交换分区是作为系统虚拟存储器的一块区域。 15、内核分为进程管理系统、内存管理系统、I/O 管理系统和文件管理系统等四个子系统。 16、内核配置是系统管理员在改变系统配置硬件时要进行的重要操作。 17、在安装Linux 系统中,使用netconfig 程序对网络进行配置,该安装程序会一步步提示用 户输入主机名、域名、域名服务器、IP 地址、网关地址和子网掩码等必要信息。 18、唯一标识每一个用户的是用户ID 和用户名。 19、RIP 协议是最为普遍的一种内部协议,一般称为动态路由选择协议。 20、在Linux 系统中所有内容都被表示为文件,组织文件的各种方法称为文件系统。 21、DHCP可以实现动态IP 地址分配。 22、系统网络管理员的管理对象是服务器、用户和服务器的进程以及系统的各种资源。 23、网络管理通常由监测、传输和管理三部分组成,其中管理部分是整个网络管理的 中心。 24、当想删除本系统用不上的设备驱动程序时必须编译内核,当内核不支持系统上的 设备驱动程序时,必须对内核升级。 25、Ping 命令可以测试网络中本机系统是否能到达一台远程主机,所以常常用于测试网络 的连通性。 26、vi 编辑器具有三种工作模式:命令模式、底行模式和输入模式。 27、可以用ls –al 命令来观察文件的权限,每个文件的权限都用10 位表示,并分为四段, 其中第一段占 1 位,表示文件类型,第二段占 3 位,表示文件所有者对该文件的权限。 28、进程与程序的区别在于其动态性,动态的产生和终止,从产生到终止进程可以具有的基 本状态为:运行态、就绪态和等待态(阻塞态)。 29、DNS实际上是分布在internet 上的主机信息的数据库,其作用是实现IP地址和主

常用的网络工具命令解析

如果你玩过路由器的话,就知道路由器里面那些很好玩的命令缩写。 例如,"sh int" 的意思是"show interface"。 现在Windows 2000 也有了类似界面的工具,叫做netsh。 我们在Windows 2000 的cmd shell 下,输入netsh 就出来:netsh> 提示符, 输入int ip 就显示: interface ip> 然后输入dump ,我们就可以看到当前系统的网络配置: # ---------------------------------- # Interface IP Configuration # ---------------------------------- pushd interface ip # Interface IP Configuration for "Local Area Connection" set address name = "Local Area Connection" source = static addr = 192.168.1.168 mask = 255.255.255.0 add address name = "Local Area Connection" addr = 192.1.1.111 mask = 255.255.255.0 set address name = "Local Area Connection" gateway = 192.168.1.100 gwmetric = 1 set dns name = "Local Area Connection" source = static addr = 202.96.209.5 set wins name = "Local Area Connection" source = static addr = none

5、学会使用Ping、Traceroute、Telnet、SSH

学会使用Ping 、Traceroute 、Telnet 、SSH (测试和网络连接的小工具测试和网络连接的小工具)) 功能描述: 使用Ping 命令是用于检测网络设备可达性,它使用ICMP 有echo 信息来决定 远程设备是否可用,与远程主机通信来回的延迟delay,或是数据包的丢失情况. 使用Traceroute 跟踪从源到目的地所经过的路径跟踪从源到目的地所经过的路径。。 使得telnet , ssh (Secure Shell)远程控制设备. 1. 使用PING 命令 注:本实验使用R1,R2,R3,SW1四台设备测试四台设备测试,,配置好R1,R2,R3,SW1的IP 地址地址,,检查接口状检查接口状态为态为up 后再测试后再测试。。 在R1上测试到R2,R3的连通性 R1#ping 12.1.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds: !!!!! //5个!表明网络是通的 Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms R1#ping 13.1.1.3

Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 13.1.1.3, timeout is 2 seconds: !!!!! //5个!表明网络是通的 Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms R1# 在SW1上检查到R1的连通性的连通性:: SW1#ping 11.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.1.1.1, timeout is 2 seconds: !!!!! //5个!表明网络是通的 Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms SW1# 通常通常在路由器或是交换机里使用在路由器或是交换机里使用ping 命令命令时常碰到的问题时常碰到的问题时常碰到的问题。。 a. 叹号(!):表示成功收到响应信息. b. 句号(.):表示在等待应答超时. c. U :表示目标主机不可达. d. Q :表示目标主机繁忙. e. M :代表不能分片(fragment). f. ?:表示未知数据包类型. g. & :表示数据包已没有生存期(lifetime) 2.使用traceroute 命令,检查从源检查从源到目的地经过的路由器的个数到目的地经过的路由器的个数.(或是数据包经过的路径) 注:本实验先确认R2到3 3.1.1.3是否有路由,和R3是否有到12.1.1.2的路由,可以用show ip route 命令检查,如果没有,分别在R1,R2,R3上配置路由: R1: ip route 33.1.1.0 255.255.255.0 13.1.1.3 R2: ip route 0.0.0.0 0.0.0.0 12.1.1.1 R3: ip route 0.0.0.0 0.0.0.0 13.1.1.1 在R2上使用traceroute 命令: R2#traceroute 33.1.1.3 Type escape sequence to abort. Tracing the route to 33.1.1.3 1 12.1.1.1 4 msec 4 msec 4 msec 2 13.1.1. 3 4 msec 4 msec * R2# 从以上可以看出从R2 到达33.1.1.3经过了12.1.1.1和13.1.1.3两个路由器 3.在PC 上是使用的是tracert 命令命令((路由器或是交换机使用的是traceroute ): 例如:跟踪从PC 到厦门电信DNS (202。101。103。55)所经过的路径所经过的路径((所经过的路由器个 数,相应IP 地址地址))

linux下 实现traceroute

1.#include 2.#include 3.#include 4.#include 5.#include 6.#include 7.#include 8.#include 9.#include 10.#include 11.#include 12.#include 13.#include 14. 15.struct ip 16.{ 17.#if __BYTE_ORDER == __LITTLE_ENDIAN 18. unsigned int ip_hl:4; /* little-endian IP头长度(单位 为32位)4位 */ 19. unsigned int ip_v:4; /* 版本号4 IP4用4 */ 20.#endif 21.#if __BYTE_ORDER == __BIG_ENDIAN 22. unsigned int ip_v:4; /* version */ 23. unsigned int ip_hl:4; /* header length */ 24.#endif 25. u_int8_t ip_tos; /* 服务类型一般为0 */ 26. u_short ip_len; /* 数据总长度 (单位为32位) */ 27. u_short ip_id; /* 标识16 */ 28. u_short ip_off; /* 分段偏移*/ 29.#define IP_RF 0x8000 /* reserved fragment标 志 */ 30.#define IP_DF 0x4000 /* dont fragment flag */ 31.#define IP_MF 0x2000 /* more fragments flag */ 32.#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ 33. u_int8_t ip_ttl; /* 生存时间 */ 34. u_int8_t ip_p; /* 传输协议 tcp是6 */ 35. u_short ip_sum; /* 头校验和 */ 36.struct in_addr ip_src, ip_dst; /* 源地址目标地址 */ 37.}; 38. 39.struct icmp 40.{ 41.u_int8_t type; /* 消息类型 */

常见网络故障的分析及排除方法

常见网络故障的分析及排除方法 【摘要】计算机网络是一个复杂的综合系统,网络故障十分普遍,故障种类也极其繁杂。本文在对具体的网络故障分析基础上,给出了相应的排除方法。 【关键词】网络故障;常见故障;分类诊断;物理故障;逻辑故障 一、网络故障的分类 网络故障的成因无非是硬件和软件两个方面。按照网络故障的性质,网络故障可划分为物理故障与逻辑故障两类。物理故障也叫硬件故障,是指由硬件设备所引发的网络故障。在硬件故障中线路故障、端口故障、集线器或路由器故障及主机物理故障是较为常见的几种故障。 逻辑故障又称为软故障,表现特征为网络不通,或者同一个链路中有的网络服务通,有的网络服务不通。究其根源,是由于设备配置错误或者软件安装错误所致。路由器逻辑故障、主机逻辑故障、病毒故障是几种常见的逻辑故障。 二、排除故障的具体方法 排除故障的方法是不外乎从软件设置和硬件损坏两个方面来考虑: ㈠物理故障及排除方法 1、线路故障最普遍的情况是线路不通,是网络中常见的故障。线路损坏或线路受到严重电磁干扰时最容易引发该故障。诊断此故障时,若线路很短,最直接的方法是将该网络线一端插入一台能够正常连入局域网的主机的RJ45插空内,另一端插入正常的集线器端口中,然后在DOS环境下,使用PING命令在本主机上检测线路另一端主机(或路由器)的端口能否响应,用TRACEROUTE命令检查路由器配置是否正确,根据检测结果进行判断;若线路稍长,不方便移动,可使用网线测试仪器进行线路检测;若线路太长,或线路由电信供应商提供,则需要与提供商协同检查线路,确认是否线路中间出现了故障。 对于存在严重电磁干扰的检测,可以使用屏蔽性能很强的屏蔽线在该线路上进行通信测试,若通信正常,表明存在电磁干扰。若问题依旧,可排除电磁干扰故障。 2、端口故障分为插头松动及端口本身的物理故障。此类故障一般会直接影响到与其相连的其他设备的信号灯状态。信号灯较直观,通过信号灯大体上可以判断出故障的发生范围及有可能存在的因素。检测时,首先应检查RJ45插头是否松动或检查RJ45接口是否制作完好,然后查看集线器或交换机的接口,如果某个接口存在问题,可以更换接口后再进行验证是否真的存在端口故障。 3、路由器或集线器故障会直接导致网络不通。这类故障也是网络上一种常见的故障,故障的现象与线路故障很相近,在诊断此种故障时,必须用专门的诊断工具来收集路由器的端口流量、路由表、路由器CPU温度、负载及路由器的内存余量、计费数据等数据。检测时,可采用替换排除法,用通信正常的网线和主机来连接路由器或集线器,若通信正常,表明路由器或集线器没有故障;反之则应调换路由器(或集线器)的端口来确认故障;很多情况下,路由器(或集线器)的指示灯表明了其本身是否存在故障,正常的情况下对应端口的指示灯为绿色指示灯。通过以上测试后,若问题依旧,可断定路由器或集线器上存在故障。 4、主机物理故障包括网卡物理故障,网卡插槽故障,网卡松动及主机本身故障。对于网卡插槽故障和网卡松动的诊断可通过更换网卡插槽来进行。如果更换插槽仍不能解决故障,可将网卡放到其他正常工作的主机上测试,若正常通信,是主机本身故障,若无法工作,是网卡物理物理故障,更换网卡故障可排除。

【实验一】常用网络管理命令的使用

实验1 常用网络管理命令的使用 一.实验目的 1.掌握各种主要命令的作用。 2.掌握各种网络命令的主要测试方法。 3.理解各种网络命令主要参数的含义。 二.实验环境 1.安装有Windows 2003 Server操作系统的计算机二台。 2.至少有两台机器通过交叉双绞线相连或通过集线器相连。 三.实验理论基础 在网络调试的过程中,常常要检测服务器和客户机之间是否连接成功、希望检查本地计算机和某个远程计算机之间的路径、检查TCP/IP的统计情况以及系统使用DHCP分配IP地址时掌握当前所有的TCP/IP网络配置情况,以便及时了解整个网络的运行情况,以确保网络的连通性,保证整个网络的正常运行。在Windows 2003中提供了以下命令行程序。 (1) ping:用于测试计算机之间的连接,这也是网络配置中最常用的命令; (2) ipconfig:用于查看当前计算机的TCP/IP配置; (3) netstat:显示连接统计; (4) tracert:进行源主机与目的主机之间的路由连接分析; (5) arp:实现IP地址到物理地址的单向映射。 四.实验参考步骤 1.Ping命令 Ping用于确定网络的连通性。命令格式为:Ping 主机名/域名/IP地址 一般情况下,用户可以通过使用一系列Ping命令来查找问题出在什么地方,或检验网络运行的情况时。典型的检测次序及对应的可能故障如下: (1)ping 127.0.0.1:如果测试成功,表明网卡、TCP/IP协议的安装、IP地址、子网掩码的设置正常。如果测试不成功,就表示TCP/IP的安装或运行存在某些最基本的问题。 (2)ping 本机IP:如果测试不成功,则表示本地配置或安装存在问题,应当对网络设备和通讯介质进行测试、检查并排除。 (3)ping 局域网内其它IP:如果测试成功,表明本地网络中的网卡和载体运行正确。但如果收到0个回送应答,那么表示子网掩码不正确或网卡配置错误或电缆系统有问题。 (4)ping 网关IP:这个命令如果应答正确,表示局域网中的网关或路由器正在运行并能够做出应答。 (5)ping 远程IP:如果收到正确应答,表示成功的使用了缺省网关。对于拨号上网用户则表示能够成功的访问Internet。 (6) ping localhost:localhost是系统的网络保留名,它是127.0.0.1的别名,每台计算机都应该能够将该名字转换成该地址。如果没有做到这点,则表示主机文件(/Windows/host)存在问题。 (7)Ping https://www.doczj.com/doc/e13675735.html,(一个著名网站域名):对此域名执行Ping命令,计算机必须先将域名转换成IP地址,通常是通过DNS服务器。如果这里出现故障,则表示本机DNS服务器的IP地址配置不正确,或DNS服务器有故障。 如果上面所列出的所有Ping命令都能正常运行,那么计算机进行本地和远程通信基本上就

traceroute程序设计与实现

Traceroute程序设计与实现 学生姓名: 莫小锋指导老师:龙计征 摘要本文主要讲述了路由追踪的基本程序设计与实现,并给出了一种基于IP网络的路由追踪命令Tr acert,详细分析了实现路由追踪的基本原理,归纳了路由追踪的基本流程。Tr acert通过ICMP协议和IPheader中TTL(存活时间)利用路由器对数据报存活时间的处理方式来实现路由探测的。首先根据任务书设计好流程图,然后编写程序代码,运行得到Traceroute的命令窗口。提取tracert 的输出,再结合现有IP数据库及自建地名- 坐标数据库对路由中各节点IP进行定位,最终实现了动态显示追踪的详细信息和路径。 关键词: IP 地址,ICMP协议,TTL,Tracert路由追踪

1 引言 Internet,是目前世界上最大的计算机网络,更确切的说是网络中的网络,它由遍布全球的几万局域网和数百万台计算机组成,并通过用于异构网络的TCP/IP协议进行网间通信。互联网中,信息的传送是通过网中许多段的传输介质和设备从一端到达另一端。每一个连接在Internet上的设备,如主机、路由器、接入服务器等一般情况下都会有一个独立的IP地址。通过Traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路劲。当然每次数据包由某一同样的出发点到达某一同样的目的地走的路劲可能会不同,但基本上来说大部分时候所走的路由是相同的。随着Internet(国际互联网)的发展,越来越多的服务通过网络提供给大众,与此同时,针对互联网的攻击事件也越来越频繁。所谓路由追踪实际上就是在IP网络上判断从源到达目的所经过的路由器的IP地址,其基本的实现手段都是向目的地发送数据包以获取经过的路由器的IP。由于Internet上的路由协议是动态的,所以每次形成的数据包从同一个出发点到达目的地的路由可能会不一样,但由于路由算法有一定的稳定性,在大部分时侯所走的路由会是相同的。 1.1 课程设计目的 1.这次课程设计,主要为了加深同学们对计算机网络网络的理解和认识 2.了解信息在计算机网络与网络之间的传送和接收 3.进一步加深了解网络与网络之间的协议 4.理解网络中的IP地址以及路由之间的相关命令。 1.2 课程设计内容 1.已知参数:输入:目的节点IP地址或主机名;输出:从控制台屏幕输出IP 报文由本机出发到达目的主机所经过的路由信息。 2.设计要求:通过原始套接字编程,实现Tracert的基本功能

Ping命令详解

Ping (Packet Internet Gopher) 網路封包測試相關資料 可用來測試遠端的主機是否存在,判斷網路是否正常 測試方法: 啟動DOS模式> 輸入PING 210.70.11.249 指令名稱ping 使用權限任何有效之使用者 使用方式ping [-dfnqrRv] [-c <完成次數>] [-ig<間隔秒數>] [-I <網路介面>][-l <前置載入>] [-p <筥本樣式>] [-s <封包大小>] [-t <存活數值>] [主機名稱或IP位址] 說明使用ICMP(Internet Control Message Protocol) 傳輸協定,偵測遠端主機的網路功能是否正常,而給予回應訊息。 參數 -c 設定完成要求回應的次數。此指令會反覆發出訊息,直到完成的次數為止。 -q 不顯示指令執行過程,除開始和結束之相關訊息外。 -s 設定封包大小。 -v 顯示指令執行詳細過程,包括非回應訊息的資訊皆會被列出。 筥例1.偵測192.168.1.1的網路功能是否正常: * ping 192.168.1.1 Windows網路管理 -------------------------------------------------------------------------------- 作者:李忠憲mailto:shane@https://www.doczj.com/doc/e13675735.html,.tw -------------------------------------------------------------------------------- 前言 過去系統管理師主要負責業務是校務行政系統的管理、訓練,有些學校系統管理師尚且兼管電腦教室,TANet到中小學後,系統管理師又兼網路管理師,部分教室電腦試行學校,系統管理師另須負責教室電腦的管理維護之責。簡單的說,目前系統管理師一人所負責的業務,幾近於一家社區電腦公司的工作量,這當然不是一般人能夠做的事。因此除非有濃厚的興趣,否則系統管理師通常都做不長久,在這樣的環境中,系統管理師還必須努力求新知,以免被工作淘汰。 筆者也當過系統管理師,所以能夠體認系統管理師的辛苦,希望此文能對系統管理師微有幫助! 網路規劃

网络协议分析实验报告

课程设计 课程设计题目网络协议分析实验报告学生姓名: 学号: 专业: 2014年 6 月 29日

实验1 基于ICMP的MTU测量方法 实验目的 1)掌握ICMP协议 2)掌握PING程序基本原理 3)掌握socket编程技术 4)掌握MTU测量算法 实验任务 编写一个基于ICMP协议测量网络MTU的程序,程序需要完成的功能: 1)使用目标IP地址或域名作为参数,测量本机到目标主机经过网络的MTU; 2)输出到目标主机经过网络的MTU。 实验环境 1)Linux系统; 2)gcc编译工具,gdb调试工具。 实验步骤 1.首先仔细研读ping.c例程,熟悉linux下socket原始套接字编程模式,为实验做好准备; 2.生成最大数据量的IP数据报(64K),数据部分为ICMP格式,ICMP报文为回送请求报 文,IP首部DF位置为1;由发送线程发送; 3.如果收到报文为目标不可达报文,减少数据长度,再次发送,直到收到回送应答报文。 至此,MTU测量完毕。

ICMP协议是一种面向无连接的协议,用于传输出错报告控制信息。它是一个非常重要的协议,它对于网络安全具有极其重要的意义。[1] 它是TCP/IP协议族的一个子协议,属于网络层协议,主要用于在主机与路由器之间传递控制信息,包括报告错误、交换受限控制和状态信息等。当遇到IP数据无法访问目标、IP路由器无法按当前的传输速率转发数据包等情况时,会自动发送ICMP消息。ICMP报文在IP帧结构的首部协议类型字段(Protocol 8bit)的值=1.

ICMP原理 ICMP提供一致易懂的出错报告信息。发送的出错报文返回到发送原数据的设备,因为只有发送设备才是出错报文的逻辑接受者。发送设备随后可根据ICMP报文确定发生错误的类型,并确定如何才能更好地重发失败的数据包。但是ICMP唯一的功能是报告问题而不是纠正错误,纠正错误的任务由发送方完成。 我们在网络中经常会使用到ICMP协议,比如我们经常使用的用于检查网络通不通的Ping命令(Linux和Windows中均有),这个“Ping”的过程实际上就是ICMP协议工作的过程。还有其他的网络命令如跟踪路由的Tracert命令也是基于ICMP协议的。 ICMP(Internet Control Message,网际控制报文协议)是为网关和目标主机而提供的一种差错控制机制,使它们在遇到差错时能把错误报告给报文源发方.是IP层的一个协议。但是由于差错报告在发送给报文源发方时可能也要经过若干子网,因此牵涉到路由选择等问题,所以ICMP报文需通过IP协议来发送。ICMP数据报的数据发送前需要两级封装:首先添加ICMP 报头形成ICMP报文,再添加IP报头形成IP数据报 通信术语最大传输单元(Maximum Transmission Unit,MTU)是指一种通信协议的某一层上面所能通过的最大数据包大小(以字节为单位)。最大传输单元这个参数通常与通信接口有关(网络接口卡、串口等)。 实验2 基于UDP的traceroute程序 实验目的 1)掌握UDP协议 2)掌握UDP客户机/服务器编程模式 3)掌握socket编程技术 4)掌握traceroute算法

PING和TRACEROUTE命令详解

本文转载自56CTO 引言:这个文档介绍了ping和traceroute命令的用法。借助于一些debug命令,此文档捕获了一个关于这些命令如何工作的更多相关细节的视图。 注意:在产品路由器上启用任何debug命令都将引起一系列问题。我们建议你在实行debug 命令之前先仔细阅读Use the Debug Command 章节。 前提条件:在本文档中没有特别的要求。 组件:使用本文档没有特殊软件或者是硬件版本的限制。 本文档中的信息是由一个具体的实验环境设备产生的。文档中所有设备的使用都是从默认配置开始的。如果你的网络是活动的,请确保你能够了解任何命令产生的潜在影响。 协定:关于文档协定的更多信息,请浏览相关Cisco Technical Tips Conventions. 关于本文档的背景信息,我们使用如下的基本配置作为我们的例子的基础。 PING命令 Ping命令是一个很常见的命令,用于排除设备可访问性的故障。它使用一系列的ICMP响应消息来确定: ·一个远程主机是否处于活动状态。 ·主机通信的往返路程延迟。 ·包丢失。 Ping命令首先发送一个响应请求到一个地址,然后等待答复。要ping成功,只有: ·响应请求到达目的地址,并且 ·目的地址在一个称作超时(time out)的预设时间内能够获得一个响应应答返回给源地址,在Cisco路由器上,这个超时的默认值是2秒。 关于此命令的所有选项,在Troubleshooting Commands中,见“Ping”。 警告:在产品路由器中使用debug ip packet detail命令会引致CPU的高利用率。这样可能会导致一个严重的性能降级或者网络中断。我们建议你在实行debug命令前仔细阅读Use the Debug Command。 Router1#debug ip packet detail IP packet debugging is on (detailed)Router1#ping 12.0.0.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.0.0.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/8 ms Router1# Jan 20 15:54:47.487: IP: s=12.0.0.1 (local), d=12.0.0.2 (Serial0), len 100, sendingJan 20 15:54:47.491: ICMP type=8, code=0!--- This is the ICMP packet 12.0.0.1 sent to 12.0.0.2. !--- ICMP type=8 corresponds to the echo message. Jan 20 15:54:47.523: IP: s=12.0.0.2 (Serial0), d=12.0.0.1 (Serial0), len 100, rcvd 3Jan 20 15:54:47.527: ICMP type=0, code=0!--- This is the answer we get from 12.0.0.2. !--- ICMP type=0 corresponds to the echo reply message.

福州大学网络程序设计考试随堂习题答案

1、socket()、bind()、connect()、listen()、accept()、close()在套接口编程中的作用各是什么? socket():执行网络通信,进程调用socket函数,指定期望的通信协议 bind():将一个本地协议地址赋予一个套接口 connect():TCP客户端与服务器建立连接用connect函数 connect的三种出错返回 [1] 若TCP客户没有收到SYN分节的响应(ACK)——返回ETIMEOUT错误 [2] 若对客户的SYN响应是RST,则表示该服务器主机在指定端口上没有进程在等待与之连接 [3]称为硬错(hard error),客户收到RST立即返回 ECONNREFUSED错误 listen():监听端口: 未连接的套接口-- 被动套接口 内核应该接收指向该套接口的连接请求 套接口状态:CLOSED -- LISTEN 服务端在socket和bind后,accept前调用 accept(): TCP服务器调用 从已完成连接队列头返回下一个已完成连接 已完成队列为空,则进程睡眠 close():用来关闭套接口,终止TCP连接 2、Ping程序、Traceroute程序和ICMP消息守护程序的工作原理。 ping程序的工作原理是:向网络上的另一个主机系统发送ICMP报文,如果指定系统得到了报文,它将把报文一模一样地传回给发送者. Traceroute程序工作原理 1、向目的地发送一个TTL为1的UDP数据报 2、该数据报导致第一跳路由返送一个ICMP错误 3、每递增TTL一次发送一个UDP数据报,逐步确定下一跳路由器 4、当UDP数据报(TTL增加到一定大小后)到达最终目的地时,目标主机返送一个ICMP 错误 ICMP消息守护程序工作原理 1、UDP应用程序使用Unix域套接口的描述字传递机制,通过Unix域连接把自身的UDP套接口传递给icmpd共享 2、icmpd得到该套接口的拷贝后通过getsockname获取绑定在此套接口上的端口号,随即关闭该套接口的本地拷贝 3、icmpd一旦收到了由UDP应用进程通过绑定在它的UDP套接口上的端口发送的UDP数据报所引发的任何ICMP错误,就可以通过Unix域连接向该应用进程发送一个消息 4、UDP应用进程需要使用多路复用方式等待其UDP套接口和Unix域套接口中任何一个有数据到达而变为可读

实验六常用网络命令使用

实验六常用网络命令使用 一、实验目的: ?了解系统网络命令及其所代表的含义,以及所能对网络进行的操作。 ?通过网络命令了解网络状态,并利用网络命令对网络进行简单的操作。 二、实验设备 实验机房,计算机安装的是 Windows 2000 或 XP 操作系统 三、背景知识 windows 操作系统本身带有多种网络命令,利用这些网络命令可以对网络进行简单的操作。需要注意是这些命令均是在 DOS 命令行下执行。本次实验学习两个最常用的网络命令。 1 、 ARP: 显示和修改 IP 地址与物理地址之间的转换表 ARP -s inet_addr eth_addr [if_addr] ARP -d inet_addr [if_addr] ARP -a [inet_addr] [-N if_addr] -a 显示当前的 ARP 信息,可以指定网络地址,不指定显示所有的表项 -g 跟 -a 一样 . -d 删除由 inet_addr 指定的主机 . 可以使用 * 来删除所有主机 . -s 添加主机,并将网络地址跟物理地址相对应,这一项是永久生效的。 eth_addr 物理地址 . if_addr 网卡的 IP 地址 InetAddr 代表指定的 IP 地址 2 、 Ping 验证与远程计算机的连接。该命令只有在安装了 TCP/IP 协议后才可以使用。

ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-v tos] [-r count] [-s count] [[-j computer-list] | [-k computer-list]] [-w timeout] destination-list 参数 -t Ping 指定的计算机直到中断。 -a 将地址解析为计算机名。 -n count 发送 count 指定的 ECHO 数据包数。默认值为 4 。 -l length 发送包含由 length 指定的数据量的 ECHO 数据包。默认为 32 字节;最大值是 65,527 。 -f 在数据包中发送“不要分段”标志。数据包就不会被路由上的网关分段。 -i ttl 将“生存时间”字段设置为 ttl 指定的值。 -v tos 将“服务类型”字段设置为 tos 指定的值。 -r count 在“记录路由”字段中记录传出和返回数据包的路由。 count 可以指定最少 1 台,最多 9 台计算机。 -s count 指定 count 指定的跃点数的时间戳。 -j computer-list 利用 computer-list 指定的计算机列表路由数据包。连续计算机可以被中间网关分隔(路由稀疏源) IP 允许的最大数量为 9 。 -k computer-list 利用 computer-list 指定的计算机列表路由数据包。连续计算机不能被中间网关分隔(路由严格源) IP 允许的最大数量为 9 。 -w timeout 指定超时间隔,单位为毫秒。 destination-list 指定要 ping 的远程计算机。 较一般的用法是 ping –t https://www.doczj.com/doc/e13675735.html, 四、实验内容和要求 ?利用 Ping 命令检测网络连通性 ?利用 Arp 命令检验 MAC 地址解析 五、实验步骤:

linux c网络网络编程面试题收集

[转] linux c/网络/网络编程面试题收集 基础部份: 1.下列程序在32位linux或unix中的结果是什么? func(char *str) { printf("%d",sizeof(str)); printf("%d",strlen(str)); } main() { char a[]="123456789"; printf("%d",sizeof(a)); func(a); } 答: 10 4 9 网络/网络编程部份: 1、connect方法会阻塞,请问有什么方法可以避免其长时间阻塞? 答:最通常的方法最有效的是加定时器;也可以采用非阻塞模式。 2、网络中,如果客户端突然掉线或者重启,服务器端怎么样才能立刻知道? 答:若客户端掉线或者重新启动,服务器端会收到复位信号,每一种tcp/ip得实现不一样,控制机制也不一样。 3.在子网210.27.48.21/30种有多少个可用地址?分别是什么? 答: 简: 30表示的是网络号(network number)是30位,剩下2位中11是广播(broadcast)地址,00是multicast 地址,只有01和10可以作为host address。 详:

210.27.48.21/30代表的子网的网络号是30位,即网络号是210.27.48.21 & 255.255.255.251=210.27.48.20,此子网的地址空间是2位,即可以有4个地址:210.27.48.20, 210.27.48.21, 210.27.48.22, 210.27.48.23。第一个地址的主机号(host number/id)是0,而主机号0代表的是multicast地址。最后一个地址的最后两位是11,主机号每一位都为1代表的是广播(broadcast)地址。所以只有中间两个地址可以给host使用。其实那个问题本身不准确,广播或multicast地止也是可以使用的地址,所以回答4也应该正确,当然问的人也可能是想要你回答2。我个人觉得最好的回答是一个广播地址,一个multicast地址,2个unicast地址。 4.TTL是什么?有什么用处,通常那些工具会用到它?(ping? traceroute? ifconfig? netstat?) 答: 简:TTL是Time To Live,一般是hup count,每经过一个路由就会被减去一,如果它变成0,包会被丢掉。它的主要目的是防止包在有回路的网络上死转,浪费网络资源。ping和traceroute用到它。 详:TTL是Time To Live,目前是hup count,当包每经过一个路由器它就会被减去一,如果它变成0,路由器就会把包丢掉。IP网络往往带有环(loop),比如子网A和子网B有两个路由器相连,它就是一个loop。TTL的主要目的是防止包在有回路的网络上死转,因为包的TTL最终后变成0而使得此包从网上消失(此时往往路由器会送一个ICMP包回来,traceroute就是根据这个做的)。ping会送包出去,所以里面有它,但是ping不一定非要不可它。traceroute则是完全因为有它才能成的。ifconfig是用来配置网卡的,netstat -rn 是用来列路由表的,所以都用不着它 5.路由表示做什么用的?在linux环境中怎么来配置一条默认路由? 答: 简:路由表是用来决定如何将包从一个子网传送到另一个子网的,换局话说就是用来决定从一个网卡接收到的包应该送的哪一张网卡上的。在Linux上可以用“route add default gw <默认路由器IP>”来配置一条默认路由。详:路由表是用来决定如何将包从一个子网传送到另一个子网的,换局话说就是用来决定从一个网卡接收到的包应该送的哪一张网卡上的。路由表的每一行至少有目标网络号、netmask、到这个子网应该使用的网卡。当路由器从一个网卡接收到一个包时,它扫描路由表的每一行,用里面的netmask和包里的目标IP地址做并逻辑运算(&)找出目标网络号,如果此网络号和这一行里的网络号相同就将这条路由保留下来做为备用路由,如果已经有备用路由了就在这两条路由里将网络号最长的留下来,另一条丢掉,如此接着扫描下一行直到结束。如果扫描结束任没有找到任何路由,就用默认路由。确定路由后,直接将包送到对应的网卡上去。在具体的实现中,路由表可能包含更多的信息为选路由算法的细节所用。题外话:路由算法其实效率很差,而且不scalable,解决办法是使用IP交换机,比如MPLS。

常用网络命令使用技巧详解

常用网络命令使用技巧详解 我想大家不会忘记Windows是从简单的DOS字符界面发展过来的。虽然我们平时在使用Windows操作系统的时候,主要是对图形界面进行操作,但是DOS命令我们仍然非常有用,下面就让我看来看看这些命令到底有那些作用,同时学习如何使用这些命令的技巧。 一、Ping命令的使用技巧 Ping是个使用频率极高的实用程序,用于确定本地主机是否能与另一台主机交换(发送与接收)数据报。根据返回的信息,我们就可以推断TCP/IP参数是否设置得正确以及运行是否正常。需要注意的是:成功地与另一台主机进行一次或两次数据报交换并不表示TCP/IP配置就是正确的,我们必须执行大量的本地主机与远程主机的数据报交换,才能确信TCP/IP的正确性。 简单的说,Ping就是一个测试程序,如果Ping运行正确,我们大体上就可以排除网络访问层、网卡、MODEM的输入输出线路、电缆和路由器等存在的故障,从而减小了问题的范围。但由于可以自定义所发数据报的大小及无休止的高速发送,Ping也被某些别有用心的人作为DDOS(拒绝服务攻击)的工具,例如许多大型的网站就是被黑客利用数百台可以高速接入互联网的电脑连续发送大量Ping数据报而瘫痪的。 按照缺省设置,Windows上运行的Ping命令发送4个ICMP(网间控制报文协议)回送请求,每个32字节数据,如果一切正常,我们应能得到4个回送应答。 Ping能够以毫秒为单位显示发送回送请求到返回回送应答之间的时间量。如果应答时间短,表示数据报不必通过太多的路由器或网络连接速度比较快。Ping还能显示TTL(Time To Live存在时间)值,我们可以通过TTL值推算一下数据包已经通过了多少个路由器:源地点TTL起始值(就是比返回TTL略大的一个2的乘方数)-返回时TTL值。例如,返回TTL值为119,那么可以推算数据报离开源地址的TTL起始值为128,而源地点到目标地点要通过9个路由器网段(128-119);如果返回TTL值为246,TTL起始值就是256,源地点到目标地点要通过9个路由器网段。 1、通过Ping检测网络故障的典型次序 正常情况下,当我们使用Ping命令来查找问题所在或检验网络运行情况时,我们需要使用许多Ping命令,如果所有都运行正确,我们就可以相信基本的连通性和配置参数没有问题;如果某些Ping命令出现运行故障,它也可以指明到何处去查找问题。下面就给出一个典型的检测次序及对应的可能故障: ·ping 127.0.0.1

常见的9个网络命令详解(图)

实验:常见的9个网络命令 1.ping命令 ping是个使用频率极高的实用程序,主要用于确定网络的连通性。这对确定网络是否正确连接,以及网络连接的状况十分有用。简单的说,ping就是一个测试程序,如果ping 运行正确,大体上就可以排除网络访问层、网卡、Modem的输入输出线路、电缆和路由器等存在的故障,从而缩小问题的范围。 ping能够以毫秒为单位显示发送请求到返回应答之间的时间量。如果应答时间短,表示数据报不必通过太多的路由器或网络,连接速度比较快。ping还能显示TTL(Time To Live,生存时间)值,通过TTL值可以推算数据包通过了多少个路由器。 (1) 命令格式 ping 主机名 ping 域名 ping IP地址 如图所示,使用ping命令检查到IP地址210.43.16.17的计算机的连通性,该例为连接正常。共发送了四个测试数据包,正确接收到四个数据包。 (2) ping命令的基本应用 一般情况下,用户可以通过使用一系列ping命令来查找问题出在什么地方,或检验网

络运行的情况。 下面就给出一个典型的检测次序及对应的可能故障: ① ping 127.0.0.1 如果测试成功,表明网卡、TCP/IP协议的安装、IP地址、子网掩码的设置正常。如果测试不成功,就表示TCP/IP的安装或设置存在有问题。 ② ping 本机IP地址 如果测试不成功,则表示本地配置或安装存在问题,应当对网络设备和通讯介质进行测试、检查并排除。 ③ ping局域网内其他IP 如果测试成功,表明本地网络中的网卡和载体运行正确。但如果收到0个回送应答,那么表示子网掩码不正确或网卡配置错误或电缆系统有问题。 ④ ping 网关IP 这个命令如果应答正确,表示局域网中的网关路由器正在运行并能够做出应答。 ⑤ ping 远程IP 如果收到正确应答,表示成功的使用了缺省网关。对于拨号上网用户则表示能够成功的访问Internet(但不排除ISP的DNS会有问题)。 ⑥ ping localhost local host是系统的网络保留名,它是127.0.0.1的别名,每台计算机都应该能够将该名字转换成该地址。否则,则表示主机文件(/Windows/host)中存在问题。 ⑦ ping https://www.doczj.com/doc/e13675735.html,(一个著名网站域名) 对此域名执行Ping命令,计算机必须先将域名转换成IP地址,通常是通过DNS服务器。如果这里出现故障,则表示本机DNS服务器的IP地址配置不正确,或它所访问的DNS服务器有故障 如果上面所列出的所有ping命令都能正常运行,那么计算机进行本地和远程通信基本上就没有问题了。但是,这些命令的成功并不表示你所有的网络配置都没有问题,例如,某些子网掩码错误就可能无法用这些方法检测到。 (3)ping命令的常用参数选项 ping IP -t:连续对IP地址执行ping命令,直到被用户以Ctrl+C中断。 ping IP -l 2000:指定ping命令中的特定数据长度(此处为2000字节),而不是缺

相关主题
文本预览
相关文档 最新文档