Вы находитесь на странице: 1из 299

- . . . .

TCP/IP


...
<inebaev[at]spbgut.ru>
MIME-Version: 1.0
E-Mail
RFC-791
http://Sendmail
BSD Sockets
APACHE
ICMPv6
tcpdump
URL ~>ping
host -e -XX -l -n -vvv -ttt -i
10.0.0.0/8
172.16.100.87/22
loopback 127.0.0.1
0x0000: ffff ffff ffff 001f d059 4eb5 0806
0001
RFC-793
IPv4/IPv6
0x0010: 0800 0604 0001 001f d059 4eb5 0a0a 0c09
inebaev@spbgut.ru
0x0020: 0000 0000
ifconfig
0000
lo0 0a0a 0c03
192.168.0.0/16
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST>
224.0.0.1
Received: from mail-qa0-f67.mailhost.com

TCP/IP

options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV


20122014 .

I
1
2
3

6
7
8


-

TCP/IP

IEEE 802 Ethernet
SLIP

TCP/IP :

2/299

II
PPP

9 IP



10 Internet


IPv4
IP
IP
IPv4
IP
11 Internet v6

: IPv5
v6 v4


IPv6
TCP/IP :

3/299

III
12 Internet ICMP


ICMP
ICMP
ICMPv6: IPv6
ICMP
13 Internet



TCP:
14 TCP/IP


Internet


15 : GNS3


TCP/IP :

4/299

IV

16 :

TCP/IP :

5/299

I
I

opds.sut.ru ;
opds.sut.ru
Internet;
opds.sut.ru
Internet R. Stevens . . . ;
opds.sut.ru
();

TCP/IP :

6/299

:
1960- .
DARPA
.

1980- 1990- .
.

2000- .
,
TCP/IP ,
Internet.

1993 .
Lynch, D. C., Historical Perspective, in Internet System Handbook, eds. D. C. Lynch
and M. T. Rose, pp. 3-14. Addison-Wesley, Reading, Mass.
TCP/IP :

7/299

TCP/IP API

(API application programming interface)
, TCP/IP:
I

Berkeley sockets
4.2BSD (1983). API
TCP/IP , Unix domain
sockets, (IPC)
. classic BSD API.

POSIX sockets Portable Operating System Interface,


API .
1988. IEEE 1003 ( ISO/IEC 9945).
API Berkley Sockets.

TLI - Transport Layer Interface .


API AT&T, XTI (X/Open Transport
Interface), .
. XTI
TLI, BSD.

TCP/IP :

8/299

BSD
1. 4.2BSD 1983 TCP/IP.
2. 4.3BSD 1986
TCP/IP.
3. 4.3BSD Tahoe 1988 ,
. ..
4. 4.3BSD Reno 1990 CSLIP,
.
5. 4.3BSD Tahoe 1988 ,
. ..
6. 4.4BSD 1993 ,
. .

BSDi, AIX, SunOS, SVR4 . .


. .

TCP/IP :

9/299


internet
:
I

Internet Society (ISOC) ,


Internet
.

Internet Engineering Task Force (IETF) ,


Internet. 9 (,
, , . . . ).

Internet Research Task Force (IRTF)


.


Internet
Request for Comment, RFC.
C RFC, .
. RFC 1
200 . .
TCP/IP :

10/299

Request for Comment


RFC,
RFC.
RFC:
I Assigned Numbers RFC ,
Internet.
I Internet Official Protocol Standards
Internet.
.

RFC
, , ,
, , .
.

RFC
, , , ,
.
TCP/IP :

11/299

Requirements RFC

RFC
.
I

Host Requirements RFC ().


,
: ,
, , .

Router Requirements RFC RFC RFC


,
Internet.

RFC
http://www.rfc-editor.org/rfc.html
http://www.ietf.org/rfc.html
http://rfc2.ru/
TCP/IP :

12/299


ISO/OSI, TCP/IP
.
I

(TELNET, FTP, IMAP...)

(TCP, UDP, SCTP...)

(IP, ICMP, IGMP...)

( )

(link layer)
.
.

(
). .

TCP/IP :

13/299

(network layer)
.
(. . )
.

.
TCP/IP:
I

Internet Protocol - Internet, RFC-791

Internet Control Message Protocol -


Internet, RFC-792

Internet Group Management Protocol -


Internet, RFC-3376

TCP/IP :

14/299

(transport layer)

.
.
I

TCP (Transmission Control Protocol)


. (),
,
, , -,
, . .
,
. RFC-793
UDP (User Datagram Protocol)
. ,
(datagram) .
,
. ,
. RFC-768

,
.
TCP/IP :

15/299

(application layer)
.
TCP/IP,
.
:
I

TELNET (Teletype Network)


RFC-854

FTP (File Transfer Protocol) RFC-959

SMTP (Simple Mail Transfer Protocol)


RFC-5321

SNMP (Simple Network Management Protocol)


RFC-1155

TCP/IP :

16/299

FTP

FTP

FTP

TCP

TP

TCP

IP

IP

IP

Ethernet

. 1: TCP/IP
TCP/IP :

17/299

TCP

UDP

ICMP

IP

IGMP

ARP

RARP

. 2:
TCP/IP :

18/299

,
(
, peer-partner).

,
.


, .
,
.


, , -
(Ethernet,
Token ring, . .),
(FTP, Telnet, . .).

TCP/IP :

19/299

(, ,
- . . . )

80-
, ,
.
I ?
I ?
I ?
I ?
I ()?
TCP/IP :

20/299

1980- .
()
(intranetworking).
.
()
.

1990- .
,
.

Internet
internetworking
( ). Internet
(intranet) ,
, TCP/IP (Internet Protocol Suite).

TCP/IP :

21/299

Internet internet
Internet
Internet () ,
TCP/IP. Internet
internet . Internet.

Internet
,
.
:
I

( ,
milnet . .)

(https://ru.wikipedia.org/wiki/Runet)

TCP/IP :

22/299



,
,
.
(internetworking)

(router) - . internet
IP IP (IP
router).

?
(gateway),
,
.
: Fast Ethernet WiFi, Gigabit Ethernet
Point-to-Point, . . : TCP/IP IBM
SNA, TCP/IP IPX/SPX . .
TCP/IP :

23/299

FTP

FTP

FTP

TP

TCP

IP

TCP

IP

IP

IP

Ethernet

Ethernet

Ethernet

Ethernet

IP

Token Ring

Token Ring

Token Ring

Token Ring

. 3:
TCP/IP :

24/299


(end system)
FTP
,
(end-to-end).
.

(intermediate system)

,
(--, hop-by-hop),
.
, ,
( ).
(multihomed).
TCP/IP :

25/299

?
, ,
, .

(Soft router)
TCP/IP
.
,
.
(),
FTP Telnet, ,
.

. . .
-
(bridge). ,
.
TCP/IP :

26/299


TCP/IP,
, ,
.
.

?
INTERNET TCP/IP
(octet) . ,
8 .


TCP/IP .
.
:
I


TCP/UDP ( 16 )

IP (8 )

Ethernet (16 )

TCP/IP :

27/299

TCP

TCP

TCP

IP

IP

TCP

IP

Ethernet

Ethernet

IP

TCP

14

20

20

Ethernet

46-1500

. 4: Ethernet

TCP/IP :

28/299

Ethernet

Ethernet
14

IP
20

TCP
20

Ethernet

46-1500
: 0x0800
IP

IP

TCP

IP

TCP
: 0x0006

TCP

: 0x1f9a

TCP

. 5: Ethernet

TCP/IP :

29/299

-
,
(client), - (server).

.


:
I

(iterative)

(concurrent)

TCP/IP : -

30/299

. 6:
TCP/IP : -

31/299


( ).
. .


,
.
. ,

.
, .


, TCP , UDP
.

TCP/IP : -

32/299

. 7:
TCP/IP : -

33/299


TCP/IP

.

TCP/IP:
1. IP IP ;
2. xARP IP ;
TCP/IP ,
: Ethernet,
Token ring, FDDI (Fiber Distributed Data Interface),
RS-232, . .
:
I

Ethernet IEEE 802;

(SLIP PPP);

loopback.

TCP/IP : TCP/IP

34/299

IEEE 802 Ethernet

Ethernet , 1982
Digital Equipment Corp., Intel Corp., Xerox Corp (DIX).

. . .

TCP/IP.
I

CSMA/CD (Multiple Access)


(Collision Detection)
(Carrier Sense);

101000 /;

48- .

TCP/IP : TCP/IP

35/299

IEEE 802.3
(Institute of
Electrical and Electronics Engineers) DIX
.
802.3 CSMA/CD, 802.2
(LLC Logical link control),
802.

802.2 802.3
Ethernet.

RFC
TCP/IP IP
RFC-894(Ethernet) RFC-1042(IEEE 802).

TCP/IP : TCP/IP

36/299

Ethernet (Host Requirements RFC):


1. ,
RFC-894(Ethernet).
2. RFC-1042(IEEE
802), RFC-894.
3.
RFC-1042.

,
, -
RFC-894.
, RFC-894.

TCP/IP : TCP/IP

37/299

46-1500
802.3 MAC

802.2 LLC

DSAP

SSAP

802.2 SNAP
.

.
3

2
38-1492

0x0800

IP

2
38-1492

0x0806

ARP

2
28

0x0835

RARP

10

2
28

10

. 8: IP IEEE 802.2/802.3

TCP/IP : TCP/IP

38/299

Ethernet

4
46-1500

0x0800

IP

2
46-1500

0x0806

ARP

2
28

0x0835

RARP

18

2
28

18

. 9: IP Ethernet
TCP/IP : TCP/IP

39/299

IEEE 802

(length) 802
;
(LLC Logical link
control) 3 ;
I

DSAP ( Destination Service


Access Point) 0xAA;
SSAP ( Source Service Access
Point) 0xAA;
0x03 (1 ).

(SNAP Sub-Network Access


Protocol) 5 ;
I
I

0x00 (3 );
2 .

TCP/IP : TCP/IP

40/299

Ethernet IEEE 802

48- (6-)
(
hardware addresses) 00:00:00:00:00:00;

(CRC) ,
(4 );

38 802.3

46 Ethernet.

, .

TCP/IP : TCP/IP

41/299

SLIP
IP (Serial
Line IP). SLIP RFC-1055.

SLIP
SLIP 1984 4.2BSD.


SLIP
Internet ,
RS-232,
.

CSLIP
Compressed SLIP (SLIP )
SLIP 2000- .
.
TCP/IP : TCP/IP

42/299

SLIP
SLIP
:
1. IP END (
0xC0).
2. , IP ,
END, 0xDB, 0xDC (2
). 0xDB SLIP ESC .
3. IP SLIP ESC,
0xDB, 0xDD (2 ).
IP
0xC0

0xDB

END

ESC

ESC

END

0xC0

0xDB 0xDC

0xDB 0xDD

0xC0

1 1

1 1

. 10: IP SLIP
TCP/IP : TCP/IP

43/299

SLIP

1. IP .
,
IP , ;
2. ( Ethernet).
SLIP,
- ;
3. SLIP .

.

TCP/IP : TCP/IP

44/299

PPP
PPP (Point-to-Point Protocol)
.
:
I

IP . PPP
(8
, ), -
;

(LCP Link Control Protocol),



PPP;

(NCP Network Control Protocol),


(IP,
Apple Talk, DECnet).

PPP RFC-1548.
IP RFC-1332.

TCP/IP : TCP/IP

45/299

PPP:
I 0x7E;
I , 0xFF;
I , 0x03;
I ,
Ethernet;
I CRC.

0x7E

0xFF

.
0x03

0x7E

1500

0x0021

IP

0x021


LCP

0x8021


NCP

. 11: IP PPP
TCP/IP : TCP/IP

46/299

PPP ISO HDLC


PPP ISO HDLC
(High-level Data Link Control).
0x7E , .
I

(bit
stuffing);

:
I
I

0x7E 0x7D, 0x5E;


0x7D 0x7D, 0x5D;

-, 0x20 (. . 32
ASCII) . ,
0x01 0x7D, 0x21,
.

TCP/IP : TCP/IP

47/299

PPP
1. PPP
( IP );
2. PPP (CRC)
;
3. IP
( IP (NCP));
4. TCP/IP;
5. (LCP)

.

PPP vs. SLIP


IP PPP IP SLIP
. , SLIP

.
TCP/IP : TCP/IP

48/299

loopback

() ,

TCP/IP. IP , loopback,
() . IP
loopback
, IP ,
IP .

lo, loopback0, lo0 ...


TCP/IP
(loopback).

loopback
127 (0111 1111). -, loopback
IP 127.0.0.1 ( (hostname) localhost).

TCP/IP : TCP/IP

49/299


1: loopback (Linux 3.12.13)
~> sudo ifconfig lo
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 0 (Local Loopback)
RX packets 101588 bytes 5843906 (5.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 101588 bytes 5843906 (5.5 MiB)
TX errors 0 dropped 0overruns 0 carrier 0 collisions 0

loopback : lo;

(): UP,LOOPBACK,RUNNING;

IP : 127.0.0.1/8;

MTU: 65536.

TCP/IP : TCP/IP

50/299

2: loopback (FreeBSD 9.3)


~> ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet 127.0.0.1 netmask 0xff000000

loopback : lo0;

(): UP,LOOPBACK,RUNNING,MULTICAST;

: RXCSUM,TXCSUM, ...;

IP : 127.0.0.1/8;

MTU: 16384.

TCP/IP : TCP/IP

51/299



( ).
I

loopback (127.0.0.1),
IP;

,
, loopback.

IP ,
loopback.

TCP/IP : TCP/IP

52/299


, ,
.

MTU

(MTU Maximum
Transmission Unit).

IP , MTU
, (fragmentation).
, MTU.

Path MTU
MTU MTU ,
.
TCP/IP : TCP/IP

53/299

RFC 1191

Hyperchannel
Token Ring 16 /c
Token Ring 4 /c
FDDI
Ethernet
IEEE 802.3/802.2
X.25
PPP, SLIP

MTU ()
65535
17914
4464
4352
1500
1492
576
296

MTU (path MTU) 296


MTU=296

Ethernet
A

MTU=1500

802.3/802.2

C
PPP

MTU=1492

. 12: MTU
TCP/IP : TCP/IP

54/299

ARP

IP TCP/IP.
.
I

Ethernet, Token ring, . . . (


48- );

Ethernet,
;


48- .
IP ,
IP .
TCP/IP : IP

55/299


: 32- IP -
.
I

( );

( ).


ARP (Address Resolution Protocol) RARP (Reverse Address Resolution Protocol

RFC-826
ARP RFC-826.

ARP: IP ( ) MAC ( );

RARP: MAC ( ) IP ( );

TCP/IP : IP

56/299

invARP
xARP .
invARP.

xARP invARP
I

ARP (
) IPL !MACL ! : IPR !MACR ?;

RARP
MACL !IPL ?;

invARP
MACL !IPL ! : MACR !IPR ?.

PtP
- ARP.
( ), IP
.
.
TCP/IP : IP

57/299

(2)

(1)

DNS
hosts

IP: A:A:A:A
MAC: A:A:A:A:A:A

(5)
(6)

(7)
(12)

ARP

(15)
FTP

FTP

TCP

IP

(3)

(4)

IP: B:B:B:B
MAC: B:B:B:B:B:B

(10)

ARP

(9)

TCP

IP

(14)

(13)


(8)

IP: B:B:B:B
MAC: B:B:B:B:B:B

IP: B:B:B:B
MAC: ???

(9)

(10)

(11)

ARP

IP: C:C:C:C
MAC: C:C:C:C:C:C

. 13: ARP ( )
TCP/IP : IP

58/299

:
1. FTP ftpserver.net;
2. DNS (/etc/hosts) IP
ftpserver.net;
3. TCP IP B:B:B:B
TCP 21;
4. IP IP A:A:A:A
B:B:B:B;
5. Ethernet MAC
. ARP - ARP;
6. MAC , ARP
;
7. ARP
(MAC FF::FF);
8. ARP : MACL ! : IPL !; IPR !MACR ?;
9. ;

TCP/IP : IP

59/299

10. ARP ,
,
;
11. ARP ,
B::B;
12. , ,
;
13. IP, IP B::B
TCP;
14. TCP ;
15. FTP.

TCP/IP : IP

60/299

Ethernet
0

5
Destination MAC

HW Len

PT Len

.. ..

11
Source MAC


PT Type


Opcode

Target MAC

Sender MAC

Target IP

12

13

14

Type

15
HW Type

Sender IP

Padding
16

ARP

. 14: ARP
I
I
I
I
I
I
I
I
I

Ethernet 14 ( CRC);
ARP 28 ( 16 );
. . 2 ;
. . 1 ;
2 ;
. . 6 ;
. . 4 ;
. 6 ;
. 4 ;

TCP/IP : IP

61/299

5
Destination MAC

0xFF:FF:FF:FF:FF:FF
PT Type

HW Len

PT Len

Opcode

0x0800 0x06 0x04 0x0001


Target MAC

0x00:00:00:00:00:00

11
Source MAC

0x1E:2A:3B:4E:5C:DA
Sender MAC

0x1E:2A:3B:4E:5C:DA
Target IP

0x0A:0A:0C:01

12

13
Type

0x0806

14

15
HW Type

0x0001

Sender IP

0x0A:0A:0C:09
Padding

0x000000000000

. 15: ARP

Ethernet (14 ) ARP (28 );

Ethernet (FF:FF:FF:FF:FF:FF);
Ethernet: ARP (0x0806);

I
I
I
I
I

: Ethernet MAC (0001);


: IP (0800);
: MAC 6 (06), IP 4 (04);
: (0001);
. (00:00:00:00:00:00);

TCP/IP : IP

62/299

5
Destination MAC

0xFF:FF:FF:FF:FF:FF
PT Type

HW Len

PT Len

Opcode

0x0800 0x06 0x04 0x0001


Target MAC

0x00:00:00:00:00:00

Destination MAC

0x1E:2A:3B:4E:5C:DA
PT Type

HW Len

PT Len

Opcode

0x0800 0x06 0x04 0x0002


Target MAC

0x1E:2A:3B:4E:5C:DA

11
Source MAC

0x1E:2A:3B:4E:5C:DA
Sender MAC

0x1E:2A:3B:4E:5C:DA
Target IP

0x0A:0A:0C:01

0x2F:33:F6:DF:F8:99
0x0A:0A:0C:09

14

15
HW Type

0x0001

Sender IP

0x0A:0A:0C:09

0x000000000000

Source MAC

Target IP

13
Type

0x0806

Padding

0x2F:33:F6:DF:F8:99
Sender MAC

12

Type

0x0806

HW Type

0x0001

Sender IP

0x0A:0A:0C:01
Padding

0x000000000000

. 16: ARP ( )

Ethernet;
I
I
I

: (0002);
Sender MAC Sender IP
Target MAC Target IP .

TCP/IP : IP

63/299

5
Destination MAC

0x1E:2A:3B:4E:5C:DA
PT Type

HW Len

PT Len

Opcode

0x0800 0x06 0x04 0x0001


Target MAC

0x00:00:00:00:00:00

11
Source MAC

0x2F:33:F6:DF:F8:99
Sender MAC

0x2F:33:F6:DF:F8:99
Target IP

0x0A:0A:0C:09

12

13
Type

0x0806

14

15
HW Type

0x0001

Sender IP

0x0A:0A:0C:01
Padding

0x000000000000

. 17: ARP

Ethernet;
I

Target MAC .


-
ARP.
TCP/IP : IP

64/299

Destination MAC

HW Len

PT Len

Opcode

Target IP

0x00:00:00:00:00:00
5

Destination MAC

PT Type

HW Len

PT Len

Target MAC

Target IP

0x0A:0A:0C:01
5

Destination MAC

0x2F:33:F6:DF:F8:99
PT Type

HW Len

PT Len

Opcode

0x0800 0x06 0x04 0x0002


Target MAC

0x2F:33:F6:DF:F8:99

11

12

0xEF:12:33:77:AA:B9
Sender MAC

0xEF:12:33:77:AA:B9
Target IP

0x0A:0A:0C:01

14

15
HW Type

0x0806

0x0001

Sender IP

0x0A:0A:0C:0A
Padding

0x000000000000
11

Source MAC

13
Type

0x1E:2A:3B:4E:5C:DA

0x2F:33:F6:DF:F8:99
0

Padding

Sender MAC

0x0800 0x06 0x04 0x0002

0x0001

0x000000000000

0x1E:2A:3B:4E:5C:DA

Opcode

15
HW Type

0x0A:0A:0C:01

Source MAC

0x2F:33:F6:DF:F8:99

0x0A:0A:0C:0A

14

Sender IP

0x2F:33:F6:DF:F8:99

Target MAC

13

0x0806

Sender MAC

0x0800 0x06 0x04 0x0001

12
Type

0x2F:33:F6:DF:F8:99

0xFF:FF:FF:FF:FF:FF
PT Type

11
Source MAC

12

13
Type

0x0806

14

15
HW Type

0x0001

Sender IP

0x0A:0A:0C:0A
Padding

0x000000000000

. 18: ARP
TCP/IP : IP

65/299

3: tcpdump
~> sudo tcpdump -e -XX -l -n -vvv -ttt -i eth0 arp
00:1f:d0:59:4e:b5 > ff:ff:ff:ff:ff:ff,
ethertype ARP (0x0806)
length 42: Ethernet (len 6), IPv4 (len 4),
Request who-has 10.10.12.3 tell 10.10.12.9, length 28
0x0000: ffff ffff ffff 001f d059 4eb5 0806 0001
0x0010: 0800 0604 0001 001f d059 4eb5 0a0a 0c09
0x0020: 0000 0000 0000 0a0a 0c03
----------------------------------90:2b:34:8e:ad:83 > 00:1f:d0:59:4e:b5,
ethertype ARP (0x0806)
length 60: Ethernet (len 6), IPv4 (len 4),
Reply 10.10.12.3 is-at 90:2b:34:8e:ad:83, length 46
0x0000: 001f d059 4eb5 902b 348e ad83 0806 0001
0x0010: 0800 0604 0002 902b 348e ad83 0a0a 0c03
0x0020: 001f d059 4eb5 0a0a 0c09 0000 0000 0000
0x0030: 0000 0000 0000 0000 0000 0000

TCP/IP : IP

66/299

4: arp -
~>sudo arp -ve
Address
HWtype
skoll.radiocoder.net
ether
atlas.radiocoder.net
ether
titan.radiocoder.net
ether
Entries: 3 Skipped: 0 Found: 3

HWaddress
f4:ec:38:d0:1a:77
14:d6:4d:a7:d4:fe
90:2b:34:8e:ad:83

Flags M
C
C
C


, ARP , -.
I

Berkeley- (BSD) 20 .;

180 .;

TCP/IP : IP

67/299


/etc/ethers:
5: ethers
#Ethernet MAC IP
f4:ec:38:d0:1a:77 10.10.12.1


.
( arp) .


arcnet, dlci, fddi, hippi, irda, x25, infiniband, eui64 . . .

TCP/IP : IP

68/299

IPv6
IPv6 ARP , ICMPv6.

ARP ( ARP);

Proxy ARP.

TCP/IP : IP

69/299

RARP

, IP .
I

. .

1. ;
2. . ;
3. RARP ( );
4. RARP IP
.

RFC-903
RARP RFC-903.

TCP/IP : IP

70/299

ARP
1. 0x8035;
2. :
I
I

0x03 RARP ;
0x04 RARP .


RARP , RARP .
6: arp -
~> sudo tcpdump -e -l -n -i eth0 rarp
8:0:20:3:f6:42 ff:ff:ff:ff:ff:ff rarp 60:
rarp who-is 8:0:20:3:f6:42 tell 8:0:20:3:f6:42
----------------------------------0:0:c0:6f:2d:40 8:0:20:3:f6:42 rarp 42:
rarp reply 8:0:20:3:f6:42 at 0a:0a:0c:09
TCP/IP : IP

71/299


RARP BOOTP DHCP DHCPv6

RARP ;
RARP ;

BOOTP (Bootstrap protocol);

PXE (Preboot Execution Environment).

TCP/IP : IP

72/299

IP: Internet
Connectionless protocol

IP ,
. IP .
.
,
, IP . ,
:
I (datagram drop), IP
ICMP ;
I
(TCP, SCTP . .).

,
I

, . .

TCP/IP : Internet

73/299

/
I

7 . . . 0 Big endian
(). (network
byte order).

0 . . . 7 Little endian .

32 .
IPv4:
1. (4 );
2. (Header Length) 32-x
, (4 ). . 0x5, . 0xF ;
3. (TOS Type of Service) RFC-1349(8 );
4. (Total Length)
(16 ). .
5. (Identification) (16
).
TCP/IP : Internet

74/299

6. (Flags)
(3 );
7. (Fragmentation Offset)
(13 );
8. (Time to Live)
, .

(8 );
9. (Protocol)
(8 );
10. (Header Checksum)
IP , . . ,
(16 );
11. (Source IP address) 32 ;
12. (Destination IP address) 32 ;

TCP/IP : Internet

75/299

13. (Options)
.

, .
32 . (0x0),
.
:
I
I
I

(RFC-1108);
IP ;

;
IP ,
;
IP ,

TCP/IP : Internet

76/299

4
0

4
3 4

IP

8
7

IP

16

15

20

18

19

31

IP

16

IP

IP

( )

. 19: IPv4

TCP/IP : Internet

77/299

~> sudo
0x0000:
0x0010:
0x0020:
0x0030:
0x0040:

7: IP
tcpdump -i wlan0 -lvvvn -e -XX ip
14d6 4da7 d4fe 6817 2989 222c 0800
003c cffa 4000 4011 3e9d 0a0a 0c05
0c01 b745 0035 0028 6617 c36b 0100
0000 0000 0000 0a72 6164 696f 636f
7203 6e65 7400 0001 0001

4500
0a0a
0001
6465

I 0x4 (4), 0x5 (20 );


I 0x00 TOS;
I 0x003C (60 ), 0xCFFA (53242);
I 0x4000 ();
I 0x40 TTL (64);
I 0x11 UDP (17);
I 0xCFFA (53242);
I 0x3E9D ;
I 0x0A0A0C05 IP (10.10.12.5);
I 0x0A0A0C01 IP (10.10.12.1);
TCP/IP : Internet

78/299



IPv4
IP.

RFC
RFC-1071, RFC-1141
1. 0x0000;
2. , . .
;
3.
;
4. IP
;
5. 0xFFFF
;
6. 0xFFFF, . .
, .
TCP/IP : Internet

79/299

8: IP
4500 003c cffa 4000 4011 [0000] 0a0a 0c05 0a0a 0c01


4500
453C
1537
5537
9548
9F52
AB57
B561
+ 003C + CFFA + 4000 + 4011 + 0A0A + 0C05 + 0A0A + 0C01
453C 11536
5537
9548
9F52
AB57
B561
C162
1537
0xC162 1100 0001 0110 0010
0011 1110 1001 1101 0x3E9D


4500
453C
1537 ...
B561
3E9D
+ 003C + CFFA + 4000 ... + 0C01 + C162
453C 11536
5537 ...
C162
FFFF
1537
TCP/IP : Internet

80/299

IPv4
RFC
RFC-950.
InterNIC
( IP ), ,
, ,
.

IP
I


Internet.


IPv4 232 = 4294967296 IP.
TCP/IP : Internet

81/299

:
1. ( ),
IP . : 10.10.12.1;
2. IP ,
. : 255.0.0.0.


() 32-x ,
,
, , 0 .
255.255.255.0 1111 1111.1111 1111.1111 1111.0000 0000
n

32-n+k

32
. 20: IPv4
TCP/IP : Internet

82/299

IPv4 :
I

: 10.10.12.1 168430593;

BIN : 0000 1010.0000 1010.0000 1100.0000 0001;

HEX : 0x0A.0A.0C.01 0x0A0A0C01;

OCT : 012.012.014.001 01202406001;

()
IPv4:
1. ();
2. (Variable Length
Subnet Mask);
3. (Classles Interdomain
Routing);
4. VLSM CIDR.


:
172.16.101.87 255.255.252.0
TCP/IP : Internet

83/299


. , 10.10.12.0 255.255.255.240
CIDR 10.10.12.0/28:
10.10.12.0 0000 1010.0000 1010.0000 1100.0000 0000
255.255.255.240 1111 1111.1111 1111.1111 1111.1111 0000

CIDR:

A
B
C

TCP/IP : Internet


1.0.0.0126.0.0.0 255.0.0.0
128.0.0.0191.255.0.0 255.255.0.0
192.0.0.0223.255.255.0 255.255.255.0

CIDR
/8
/16
/24

84/299

RFC
RFC-5735 IPv4.

TCP/IP : Internet


0.0.0.0/8
10.0.0.0/8
127.0.0.0/8
169.254.0.0/16
172.16.0.0/12
192.168.0.0/16
224.0.0.0/4
255.255.255.255/32

RFC
1122
1918
1122
3927
1918
1918
3171
919

85/299

IP

I

: 172.100.30.0/23 (255.255.254.0);

: 12;

: 17;

1. 12 4 24 = 16 IP
;
2. 17 5 25 = 32 IP
;
3.
29 = 512 IP .

TCP/IP : Internet

86/299

172.100.30.0 1010 1100.0110 0100.0001 1110.0000 0000


255.255.254.0 1111 1111.1111 1111.1111 1110.0000 0000
I
I

1010 1100.0110 0100.0001 1110.0000 0000


;
.


172.100.30.0/27
1010 1100.0110 0100.0001 111 0.000 00000
172.100.30.32/27
1010 1100.0110 0100.0001 111 0.001 00000
172.100.30.64/27
1010 1100.0110 0100.0001 111 0.010 00000
172.100.30.96/27
1010 1100.0110 0100.0001 111 0.011 00000
172.100.30.128/27 1010 1100.0110 0100.0001 111 0.100 00000
172.100.30.160/27 1010 1100.0110 0100.0001 111 0.101 00000
172.100.30.192/27 1010 1100.0110 0100.0001 111 0.110 00000
172.100.30.224/27 1010 1100.0110 0100.0001 111 0.111 00000
172.100.31.0/27
1010 1100.0110 0100.0001 111 1.000 00000
172.100.31.32/27
1010 1100.0110 0100.0001 111 1.001 00000
172.100.31.64/27
1010 1100.0110 0100.0001 111 1.010 00000
.................................................................
172.100.31.224/27 1010 1100.0110 0100.0001 111 1.111 00000

TCP/IP : Internet

87/299


172.100.31.224/27
IP

172.100.31.225 1010 1100.0110 0100.0001 111 1.111 00001
172.100.31.226 1010 1100.0110 0100.0001 111 1.111 00010
172.100.31.227 1010 1100.0110 0100.0001 111 1.111 00011
172.100.31.228 1010 1100.0110 0100.0001 111 1.111 00100
172.100.31.229 1010 1100.0110 0100.0001 111 1.111 00101
172.100.31.230 1010 1100.0110 0100.0001 111 1.111 00110
172.100.31.231 1010 1100.0110 0100.0001 111 1.111 00111
172.100.31.232 1010 1100.0110 0100.0001 111 1.111 01000
.............................................................
172.100.31.254 1010 1100.0110 0100.0001 111 1.111 11110
172.100.31.255 1010 1100.0110 0100.0001 111 1.111 11111
I

172.100.31.224 ;

172.100.31.255 ;

TCP/IP : Internet

88/299

172.100.30.0/23
172.100.30.0/23

PPP

172.100.30.0/27
30.1


R 30.4

.30.32

R 30.3

.30.64

R 30.2

.31.224

. 21:

TCP/IP : Internet

89/299

9: ifconfig ( nettols)
~> sudo ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>
mtu 1500
inet 10.10.12.5 netmask 255.255.255.240
broadcast 10.10.12.15
ether 68:17:29:89:22:2c txqueuelen 1000 (Ethernet)
RX packets 67626 bytes 65961377 (62.9 MiB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 63980 bytes 26932724 (25.6 MiB)
TX errors 0 dropped 0 overruns 0
carrier 0 collisions 0
10: IP
~> sudo ifconfig wlan0 172.16.101.87/22

TCP/IP : Internet

90/299

11: ip ( iproute2)
~> sudo ip link
1: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP>
mtu 1500 qdisc mq state UP mode DORMANT
group default qlen 1000
link/ether 68:17:29:89:22:2c brd ff:ff:ff:ff:ff:ff
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT
group default qlen 1000
link/ether 2c:d4:44:9f:c3:dc brd ff:ff:ff:ff:ff:ff
12: ip ( iproute2)
~> sudo ip -d addr show wlan0
1: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP>
mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 68:17:29:89:22:2c brd ff:ff:ff:ff:ff:ff
inet 172.16.101.87/22 brd 172.16.103.255
scope global wlan0
valid_lft forever preferred_lft forever
TCP/IP : Internet

91/299

IPv4
IP.

IP
, .

,
, .

IP ,
(daemon) .

Daemon Disk And Execution MONitor


IP
. ( services)
. ,
, . UNIX-like OS:
I routed
I

gated

TCP/IP : Internet

92/299


IP --
(hop-by-hop).
I

(Ethernet
PPP-), IP
;


( ),
;

:
1. IP (
);
2. IP ,
(
);
3. ,
, .
TCP/IP : Internet

93/299

Ns

Ra

Rb

Rd

1
2

Re

Rc

1
2

Nd

. 22: IP

,
, ;

,
, ;

TCP/IP : Internet

94/299

IP (S/IP (AND) S/SN);

IP (D/IP (AND) S/SN);


(S/SN (AND) D/SN);

I
I

, ;
, .

10.10.12.18 0000 1010.0000 1010.0000 1100.0001 0010


255.255.255.240 1111 1111.1111 1111.1111 1111.1111 0000
10.10.12.16 0000 1010.0000 1010.0000 1100.0001 0000
10.10.12.1 0000 1010.0000 1010.0000 1100.0000 0001
255.255.255.240 1111 1111.1111 1111.1111 1111.1111 0000
10.10.12.0 0000 1010.0000 1010.0000 1100.0000 0000
TCP/IP : Internet

95/299

IP :
1. ,
, (
);
I

,

( ). ,
-,
, , IP ;

2. ,
, , ;
I

,

( );

3. ,
" "(default gateway, ).
,
;
4. ,
(
(host unreachable) (network unreachable).
TCP/IP : Internet

96/299

ICMP

TCP

(gated)

route

netstat

UDP

IP-
()

Ethernet
Ethernet

IP-

IP ?

IP

IP-
()

. 23: IP

TCP/IP : Internet

97/299

14: ( ip)
~> sudo ip -d -r route show
unicast default via atlas.radiocoder.net dev wlan0
15: ( netstat)
~> sudo netstat -rn
Kernel IP routing table
Destination Gateway
Genmask
0.0.0.0
10.10.12.1 0.0.0.0
10.10.12.0
0.0.0.0
255.255.255.240

Flags
UG
U

Iface
wlan0
wlan0

10.10.12.1/28;

: U , G ;

wlan0.

TCP/IP : Internet

98/299


Internet

91.122.40.0/30
PPP

G
10.10.12.16/28

10.10.12.0/28
.17

.19

.1

.14

.10

. 24: IP

16: 10.10.12.10
Destination
0.0.0.0
10.10.12.0
10.10.12.16

Gateway
10.10.12.1
0.0.0.0
10.10.12.14

Genmask
0.0.0.0
255.255.255.240
255.255.255.240

Flags
UG
U
UG

Iface
wlan0
wlan0
wlan0

17: 10.10.12.19
Destination
0.0.0.0
10.10.12.16
TCP/IP : Internet

Gateway
Genmask
10.10.12.17 0.0.0.0
0.0.0.0
255.255.255.240

Flags
UG
U

Iface
wlan0
wlan0
99/299

IP

, IP
.
(ip forwarding)
:
1. (. . )
;
2. .
External
Internal

network
network
(int.interface)

Ethernet

(ext.interface)

Ethernet

ip.forwarding=1
packet filter

. 25: IP
TCP/IP : Internet

100/299

IP forwarding
UNIX- ,
(sysctl)
proc (Linux).
18: Linux 3.12.26 FreeBSD 9.3
linux~> sysctl net.ipv4.ip_forward = 1
bsd~> sysctl net.inet.ip.forwarding=1

Packet filter

. :
I

Iptables netfilter Linux;

IPFW, IPF, PF BSD.


, ,
.
TCP/IP : Internet

101/299

IP
19: pf.conf pfctl (FreeBSD 9.3)
# options
set loginterface tun0
set skip on lo
# scrub
scrub in
# nat
nat on tun0 from 10.10.12.0/28 to any -> tun0
# filter rules
block in
pass out
pass quick on vr0
pass in on tun0 proto { tcp, udp } from any to (tun0) port { 30000:65000 }
---TRANSLATION RULES:
nat on tun0 inet from 10.10.12.0/28 to any -> 91.122.40.4
FILTER RULES:
block drop in all
pass out all flags S/SA keep state
pass quick on vr0 all flags S/SA keep state
pass in on tun0 proto tcp from any to (tun0) port 30000:65000 keep state
pass in on tun0 proto udp from any to (tun0) port 30000:65000 keep state
TCP/IP : Internet

102/299

ICMP
ICMP ,
IP ,
.

ICMP :5 :03
ICMP Redirect message (0 ; 1
; 2,3 TOS)
20: Linux 3.12.26 FreeBSD 9.3
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
--net.inet.ip.redirect: 1
net.inet.icmp.drop_redirect: 1
net.inet.icmp.log_redirect: 1

TCP/IP : Internet

103/299

R
10.10.12.16/28
.19

.1

10.10.12.0/28
.17

.14

.10

. 26: ICMP

21:
Destination Gateway
Genmask
Flags
Iface
0.0.0.0
10.10.12.1 0.0.0.0
UG
wlan0
10.10.12.0
0.0.0.0
255.255.255.240 U
wlan0

0.0.0.0
10.10.12.0
10.10.12.16
TCP/IP : Internet

22:
10.10.12.1 0.0.0.0
UG
wlan0
0.0.0.0
255.255.255.240 U
wlan0
10.10.12.14 255.255.255.240 UGD
wlan0
104/299

IP
IP,
( )
.

:
I

IP , IP ,
, MTU
;

IP MTU ,
, .

,
.

TCP/IP : Internet

105/299

, IP ,
. . .
IP . IP,
:
1. (16 )
;
2. (3 ):
I

001 (More Fragmets, MF).


, .
010 (Do not Fragment, DF). IP
;

3. (13 )
. ,

, .

DF,
MTU ,
. ICMP
,
(fragmentation needed but dont fragment bit set).
TCP/IP : Internet

106/299


,
IP ,
. , ,
.


,
. - (
)
.
23: 1528
~> ping -s
PING atlas
1508 bytes
1508 bytes
^C

1500 atlas
(10.10.12.1) 1500(1528) bytes of data.
from atlas (10.10.12.1): icmp_seq=1 ttl=64 time=1.84 ms
from atlas (10.10.12.1): icmp_seq=2 ttl=64 time=1.98 ms

TCP/IP : Internet

107/299

1528
20

1500

IP

UDP

1500

IP

20

UDP

1472
48

IP

UDP

20

28

. 27: (MTU=1500 )
TCP/IP : Internet

108/299

1
14 d6 4d a7 d4 fe 68 17 29 89 22 2c 08 00 45 00
05 dc 11 b0 20 00 40 01 17 58 0a 0a 0c 05 0a 0a
0c 01 .. .. .. .. .. .. .. .. .. .. .. .. .. ..

Flags <<MF>>: 001...


Frag offset: ...0000000000000
ID Frag: 4528
2
14 d6 4d a7 d4 fe 68 17 29 89 22 2c 08 00 45 00
00 30 11 b0 00 b9 40 01 3c 4b 0a 0a 0c 05 0a 0a
0c 01 .. .. .. .. .. .. .. .. .. .. .. .. .. ..

Flags:
000...
Frag offset: ...0000010111001 (1480)
ID Frag: 4528
. 28:
TCP/IP : Internet

109/299

ICMP
ICMP
, ,
010 (DF).

ICMP :3 :4
ICMP fragmentation needed message
.
24: ICMP
~> tcpdump -i wlan0 icmp -vvvlnnn -XX
IP (tos 0x0, ttl 64, id 56976, offset 0, flags [none], proto ICMP (1),\
length 56)
10.10.12.1 > 10.10.12.5:
ICMP 91.122.61.1 unreachable - need to frag (mtu 1492), length 36
IP (tos 0x0, ttl 2, id 0, offset 0, flags [DF], proto UDP (17),\
length 1500)
10.10.12.5.46485 > 91.122.61.1.44446: UDP, length 1472
6817 2989 222c 14d6 4da7 d4fe 0800 4500
0038 de90 0000 4001 701b 0a0a 0c01 0a0a
0c05 0304 786f 0000 05d4 4500 05dc 0000
4000 0211 c487 0a0a 0c05 5b7a 3d01 b595
ad9e 05c8 15bc
TCP/IP : Internet

110/299

: IPv5

IPv5 (Stream protocol) (


)
. ST2
(MPLS Multiprotocol Label Switching, RFC-3031, 2001 .).

IPv5 RFC
I

RFC-1190Experimental Internet Stream Protocol (Version 2 (ST-II),


1990);

RFC-1819Internet Stream Protocol (Version 2 (ST2), 1995).

1. ST2 IPv4;
2. IPv4;
3. ethertype Ethernet: 0x0800;
4. IP version IP: 0x5

TCP/IP : Internet v6

111/299

IPv6: v4
I


2128 = 340 282 366 920 938 463 463 374 607 431 768 211 456 ;


, 8192
;

.
MTU , Path
MTU discovery. MTU 1280 (Min
MTU IPv4 576 );

IP

;

IPv6 (link-local address) RFC-2462;


(-);

IPv6 IPsec
(, );

TCP/IP : Internet v6

112/299

() IPv6 ,
;

IPv4 40 ;

,
IPv6
QoS;

IPv6 ,
;

IPv6 KAME
http://www.kame.net

TCP/IP : Internet v6

113/299

IPv6
IPv6 ()
(40 ) ,
.
IPv6:
1. (4 );
2. (Traffic class)
(6 )
(2 );
3. (Flow label) ,
.
.
(20 );
4. (Payload length)
IPv6 (16 );

TCP/IP : Internet v6

114/299

5. (Next header)
.
IPv6
(8 );
6. (Hop limit)
,
(8 ). TTL
IPv4;
7. (Source address) 128
;
8. (Destination address) 128
.

TCP/IP : Internet v6

115/299

IPv6
4
0

20

3 4

IP

11



( )

12

15 16

31

23 24

Hop limit (TTL)

40

IP

IP

IPv6

. 29: IPv6
TCP/IP : Internet v6

116/299

IPv6
I

I
I

IPv4,


(ICMP, TCP . .);
8;
Next Header
IPv6.
Next header, ;
Next Header
.


.
(Hop-By-Hop options,
.
IPv6,
.
ICMPv6 Parameter Problem ( 4, 1).
TCP/IP : Internet v6

117/299

IPv6

(Hop-by-hop
options)

(Destination options)

(Routing options)

60

(Fragment options)

(Authentification header)

(Encapsulating security
payload)

44

TCP/IP : Internet v6

43

51
50

(IPv4:
)

IPsec

IPv6 (IPsec)
118/299

IPv6

Ethernet
14

IPv6
40

Next header:17

Next header:43

Next header:0

Hop-by-hop
options

Routing options

UDP

IPv6
IPv6

R1

R2

R3

. 30: Hop-by-hop options

TCP/IP : Internet v6

119/299

IPv6

Next header:17
Next header:44

Ethernet
14

IPv6

Hop-by-hop
Fragment options
options

40

IPv6

R1

R2

UDP

R3

. 31: Hop-by-hop options

TCP/IP : Internet v6

120/299

IPv6
IPv6 128 HEX-
X:X:X:X:X:X:X:X. (X:)
16 .

FEBC:A574:382B:23C1:AA49:4592:4EFE:9982

:

FE80::1FE80:0000:0000:0000:0000:0000:0000:0001
FE80::382B:0000:0000:4EFE:0001
FE80:0000:0000:382B:0000:0000:4EFE:0001
IPv4 4
:

FC00:0000:0000:0000:0000:0000:0A0A:0C01FC00::10.10.12.1
TCP/IP : Internet v6

121/299

IPv6
IPv6:
1. (unicast)
,
;
2. (anycast)
. ,
.
, (
) ;
3. (multicast)
,
,
.


,
RFC-3513.
TCP/IP : Internet v6

122/299

(unicast)

2000::/3,
IPv4;

(link-local)
fe80::/10.
169.254.0.0/16;

(Uniquie link-local)
fc00::/7, ()
. IPv4
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16;

TCP/IP : Internet v6

123/299

(multicast)

(assigned multicast address)


.
, ,
, .

(solicited multicast address)


,
. ,

. :
FF02:0:0:0:0:1:FF00::/104, 24
unicast- .

TCP/IP : Internet v6

124/299

IPv6

::
::1
::00:xx:xx:xx:xx

128
128
96


lo

IPv4

::ff:xx:xx:xx:xx

96

fe80::feb::

10

fec0::fef::

10

IPv4

IPv6

()

ff::

0012

TCP/IP : Internet v6

IPv6

IPv4:0.0.0.0
IPv4:127.0.0.1

32


IPv4

IPv6
IPv4:
169.254.0.0/16
IPv4:
10.0.0.0/8,
172.16.0.0/12,
192.168.0.0/16

125/299

25: IPv6 (ifconfig FreeBSD 9.3)


#> ifconfig
rl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,
SIMPLEX,MULTICAST>
mtu 1500
inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255
inet6 fe80::200:21ff:fe03:8e1
ether 00:00:21:03:08:e1
media: Ethernet autoselect (100baseTX)
status: active

IPv6?

.
inet6 fe80::200:21ff:fe03:8e1
ether 00:00:21:03:08:e1

TCP/IP : Internet v6

126/299

: IPv6

- IPv6;
www.sixxs.net;

www.tunnelbroker.net;

6-to-4 (RFC-3068);

(dial-up) freenet6.

TCP/IP : Internet v6

127/299

IPv6
IPv4 IPv6
IPv4 IPv6
.
IPv6
IPv4,
IPv4/IPv6.

RFC-3493
RFC-4038.
26: rc.conf (FreeBSD 9.3)
ipv6_ipv4mapping="YES"

TCP/IP : Internet v6

128/299


() IPv6
.
27: rc.conf (FreeBSD 9.3)
ifconfig_fxp0_ipv6="inet6 2001::5344 prefixlen 64"
ipv6_defaultrouter="2001:db8:4672:6565::1"



IPv6 ICMPv6
() (router advertisment).

()
(router solicitation).
28: rc.conf (FreeBSD 9.3)
ifconfig_re0_ipv6="inet6 accept_rtadv"
rtsold_enable="YES"
TCP/IP : Internet v6

129/299

IPv6
IPv6
.
,
(,
GRE) ,
.

,
.
29: C (FreeBSD 9.3)
gif_interfaces="gif0"
gifconfig_gif0="178.16.100.26 91.122.61.174"
ifconfig_gif0_ipv6="inet6 2001::5344 prefixlen 64"
ipv6_defaultrouter="2001:db8:4672:6565::1"

TCP/IP : Internet v6

130/299

ICMP Internet Control Message Protocol


ICMP TCP/IP.
ICMP
,
. ICMP IP
(TCP UDP). ICMP
,
.

IP

ICMP

. 32: ICMP IP

ICMP RFC
ICMP RFC-792

TCP/IP : Internet ICMP

131/299

16

. 33: ICMP


4 ICMP ,
.
I
I
I

15 (Type),
ICMP ;
ICMP
(Code);
ICMP
.
IP.

TCP/IP : Internet ICMP

132/299

ICMP

ICMP:
I

ICMP (query);

ICMP (error).

IP
C IP 8 IP
, ICMP .
ICMP
, (TCP,
UDP . .) .

TCP/IP : Internet ICMP

133/299


ICMP . . .
I

. . . ICMP ;

. . . ,
IP;

. . . ,
;

. . . IP, (. .
(offset) IP );
. . . ,
(0.0.0.0), loopback (127.0.0.0/8) ,
(224.0.0.0/4).

TCP/IP : Internet ICMP

134/299

ICMP

5
8


0
- (echo reply)
(destination unreachable):
0
(network unreachable)
1
(host unreachable)
2
(protocol unreachable)
3
(port unreachable)
4
,
DF (fragmentation needed but DF bit set)
..........................................................
13

(communication
administratively
prohibited by filtering)
(redirect):
0
(redirect for network)
1
(redirect fot host)
0
- (echo request)

TCP/IP : Internet ICMP

135/299

(router
advertisement)
10
0
(router solicitation)
(time exceeded):
11
0
0
(time-to-live equals 0 during transit)
.................................................................
IP
ICMP
ICMP

Ethernet
14

IP

ICMP

20

IP ,

UDP
8

20

. 34: IP,
TCP/IP : Internet ICMP

136/299

ICMP:
,

() , ICMP
(port unreachable).
30: (atftp)
~> atftp
tftp> connect 10.10.12.1 1000
tftp> get ios_3640.image
timeout: retrying...
timeout: retrying...
tftp: aborting
tftp>

31: ICMP port unreachable (tcpdump)


~> sudo tcpdump -vvvln -i wlan0 icmp
listening on wlan0, link-type EN10MB (Ethernet) capture size 65K bytes
IP(ttl 64,id 34062,offset 0,flags [none],proto ICMP (1),length 56)
10.10.12.1>10.10.12.5: ICMP 10.10.12.1 udp port 1000 unreachable
-:IP(ttl 64,id 15286,offset 0,flags [DF],proto UDP (17),length 51)
-:10.10.12.5.57310 > 10.10.12.1.1000: UDP, length 23
TCP/IP : Internet ICMP

137/299

ICMPv6: IPv6
ICMPv6 RFC
IPv6 RFC-4443.

ICMP IPv4. , ARP, ICMPv6
.
IPv6 Next header 58.

ICMP

(. . 132),
, IPv6.
ICMPv6
:
I

0127 (
0);

128255;

TCP/IP : Internet ICMP

138/299

ICMPv6

0
1
2
3
4
0

4
128
129

0
1
2
0
0

:





(MTU)


(Hop Limit)



Next header
IPv6
-
-

TCP/IP : Internet ICMP

139/299

ICMP I
1. ping
. ICMP -
ICMP -.
ping RTT
Round Trip Time. IPv6 ping6.
man ping, . TCP/IP ( 7);
2. traceroute ,
IP .
TTL IP ICMP
. man traceroute, .
TCP/IP ( 8);
3. tracepath MTU
, MTU
. IP DF, MTU
ICMP , DF.
man tracepath, . TCP/IP
( 11);
TCP/IP : Internet ICMP

140/299

ICMP II
4. mtr my traceroute, traceroute,
.
. man
mtr;
5. tracemap - Perl,
.
traceroute ,
.
graphviz.
...
@prefixes=load_prefixes();
for $dest (@dests)
{
say("Tracing path to $dest");
open (TRACE,"traceroute $traceroute_options $dest|")
or die "Cant run traceroute:$!";
my $hop=;
$ttl=0;
...

TCP/IP : Internet ICMP

141/299

b.root-servers.net

asia.pool.ntp.org

1.08

0.32

12.122.131.94

4.69.155.81

4.69.134.70

140.109.255.214

198.172.117.163

h.root-servers.net

0.58

129.250.5.86

4.69.137.78
138.18.1.3

202.169.174.78
40.86

2.74

221.28

4.69.143.142

152.179.75.130
1.47

4.69.148.193

129.250.4.4
190.220.179.197

6.45 152.63.40.81

0.05

80.64.128.171

9.81

129.250.9.206
4.69.140.1

80.64.128.249

77.52

4.69.154.62

129.250.4.69

4.69.143.138
193.203.0.81

4.69.140.13

202.40.161.227

94.80

128.25

6.29

0.40

0.22

129.250.2.13

193.232.226.250

129.250.4.162

0.03

0.45

72.52.92.81

216.66.84.250

0.06

0.69

213.198.77.213
7.24

194.226.100.33
39.51
59.13

170.04
194.68.123.187

47.05
0.58
0.78

0.62
77.72.228.46

194.68.123.73

0.40
113.69
0.77
198.32.160.214

188.65.69.65
0.66

117.97

k.root-servers.net

195.34.59.49

2.04

2.80

212.188.29.82

195.34.53.193

66.192.241.38

195.66.225.238
188.65.69.82

3.59
2.48
1.61

2.11
0.77

195.34.53.138
0.20

195.66.224.198

206.223.115.205

202.7.162.246

134.23
0.03
66.162.129.150

195.34.59.114

212.188.1.190
195.34.59.45

10.40.91.5

8.05

77.78

77.77

212.188.1.194
188.65.64.77

iana.org
206.132.169.161

203.29.135.33
212.188.1.185

0.78

e.root-servers.net
0.46

ripe.net

212.188.42.90

16.81

3.11

32.29

210.173.176.242

8.92

4.06
92.62.48.162

m.root-servers.net

icann.org

98.172.152.14

188.65.69.45

130.18

192.149.252.131

180.82

30.86
31.12
212.188.42.22

195.34.53.102

203.194.59.191
saturn.darkstar.su

188.65.69.6

opds.sut.ru

193.232.188.17

193.232.87.51

2.56

0.68

87.245.232.118

7.92

206.126.236.198

58.138.80.114

0.18
212.188.42.58

195.34.53.189

darkstar.su

68.1.1.7

11.92

f.root-servers.net
42.66

1.42

72.56
149.20.65.137
206.132.169.249
103.82

0.03

8.31

212.188.28.142

0.15

87.245.233.126

198.32.160.95

kernel.org

212.188.28.174

7.18

193.232.246.140

212.188.18.93

188.65.69.54

1.14

1.30

7.49

j.root-servers.net

0.82

40.26

87.245.233.114

0.68

86.59

206.132.169.206

194.85.40.217

194.85.40.137
194.85.40.146

91.210.16.63

87.245.232.102

55.32
92.62.48.173
14.16
0.58

0.30

198.32.160.42

212.188.29.138

194.190.254.53
12.35

13.88

87.245.251.21

0.15

0.23

3.54

178.18.224.11

87.245.233.134

0.25

i.root-servers.net

0.74

17.47

194.146.105.187
154.54.42.121

38.104.236.106

194.190.255.106

130.09

sut.ru

24.83
149.6.141.9

6.50

1.60

opds.sut.ru

87.245.232.150

100.94
154.54.40.62

75.103.237.110

ripn.net

4.38

193.232.188.17

0.60

72.52.92.45
3.35

2.32

87.245.233.138

87.245.232.138

1.42

194.226.29.34
-129.42

87.245.233.54
129.250.5.217

185.99

3.29

212.162.19.29

3.43

8.38

41.216.193.81

4.69.154.254

l.root-servers.net

africa.pool.ntp.org

128.8.0.229

14.97

129.250.3.20
129.250.2.111

d.root-servers.net

4.69.137.58

3.12

129.250.3.180

6.18

4.68.62.134

82.91

8.05

157.238.179.126

3.12

4.69.143.222 1.44

28.30

11.55

123.35

4.69.158.37

4.69.140.29
0.53

187.174.64.17

138.18.21.54

0.57
138.18.49.25

152.63.36.210

9.03
202.169.174.146

22.45

6.74

75.55

europe.pool.ntp.org

south-america.pool.ntp.org

16.18

1.33

80.81.192.245

apnic.net

195.34.53.58

arin.net

195.69.146.82

2.23

0.66
1.34

201.48.46.174

sut.ru

0.71

194.226.100.33

-0.09
168.209.201.62

201.48.44.6

149.6.141.97

199.7.71.158
5.97

0.29

168.209.1.168

0.74

50.97.18.213

199.16.95.114

2.29

-4.49

3.54

196.37.155.180

a.root-servers.net

10.27

154.54.61.165

50.97.18.210

0.03

0.03

17.47

4.61
201.48.44.14

154.54.36.218

50.97.18.206
130.117.2.222

178.18.224.11

69.53

196.216.3.132

87.245.251.21

11.69

55.32

c.root-servers.net

50.97.18.204

afrinic.net

87.245.232.102
201.48.44.93

0.30

92.62.48.173

187.32.53.69

19.53
173.192.18.132
173.192.18.171

TCP/IP : Internet ICMP

142/299




.
TCP/IP
Internet.


IP
,
. . .
, .

:
I

TCP/IP : Internet

143/299

FTP

FTP

TP

TCP

IP

TCP

IP

IP

IP

Ethernet

Ethernet

FTP

Ethernet

Ethernet

IP

Token Ring

Token Ring

Token Ring

Token Ring

. 35: )
TCP/IP : Internet

144/299



(sockets ).
IP
: IP:port. IPv4 32 ,
16 (065535).
,
:
Source-IP:Source-port::Destination-IP:Destination-Port.


.
, IEEE IETF
IANA (Internet Assigned
Numbers Authority).
()
http://www.iana.org/assignments/port-numbers.

TCP/IP : Internet

145/299

:
1. 01023.
Internet WWW (80), FTP (20, 21),
TELNET (23) . . IANA (Well known
ports),
( ).
;
2. 102449151.
IANA
, WINS (1512),
RADIUS (1812), Subversion (3690) . .

;
3.
4915265535. ,
.

TCP/IP : Internet

146/299

32: /etc/services
# Network services, Internet style
# Some References:
# http://www.iana.org/assignments/port-numbers
# http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/services
# Each line describes one service, and is of the form:
# service-name port/protocol [aliases ...]
[# comment]
#
# IANA Assignments [Well Known Ports]
# The Well Known Ports are assigned by the IANA and on most systems can
# only be used by system (or root) processes or by programs executed by
# privileged users.
# The range for assigned ports managed by the IANA is 0-1023.
#
tcpmux 1/tcp # TCP port service multiplexer
tcpmux 1/udp
...
echo 7/tcp # Echo
echo 7/udp
...
qotd 17/tcp # Quote of the Day
qotd 17/udp
...
ftp-data 20/tcp # File Transfer [Default Data]
ftp-data 20/udp
TCP/IP : Internet

147/299

I
TCP/IP
:
I

UDP (User
Datagram Protocol). ,
RFC-768;

TCP (Transmission
Control Protocol). Internet,
RFC-793;

TCPCrypt TCP
. ,
(internet-draft),
URL:http://www.ietf.org/id/draft-bittau-tcpinc-01.txt;

SCTP (Stream
Control Transmission Protocol). TCP,

, RFC-4690;

TCP/IP : Internet

148/299

II

DCCP (Datagram
Congestion Control Protocol).

UDP . ,
.
,
Linux.
RFC-4340;

RDP (Reliable
Data Protocol).
TCP,
,
. RFC-1151.

TCP/IP : Internet

149/299


UDP
(connectionless).
UDP , IP
. (Protocol)
IP 17.
IP
UDP

Ethernet
14

IP

UDP

20

. 36: UDP

Unreliable Datagram Protocol


UDP
.
TCP/IP : Internet

150/299

Internet UDP

7
53
67
68
69

echo
nameserver
dhcps (bootps)
dhcpc (bootpc)
tftp

88
123

kerberos
ntp

161

snmp



DHCP
DHCP


Kerberos


UDP Domain
Name System Trivial FTP. UDP
. ,
UDP (. 1).
TCP/IP : Internet

151/299

UDP
UDP
:
1. (Source port)
, (16 );
2. (Destination port)
,
(16 ).
;
3. (UDP length) ( )
UDP. 16 .
8 ;
4. (UDP checksum)
( 16 ) UDP UDP.

IP,
UDP.
TCP/IP : Internet

152/299

16

16
15

16

31

. 37: UDP

TCP/IP : Internet

153/299

33: UDP
~> sudo tcpdump -i
0x0000: 14d6 4da7
0x0010: 003c cffa
0x0020: 0c01 b745
0x0030: 0000 0000
0x0040: 7203 6e65

wlan0 -lvvvn -e -XX


d4fe 6817 2989 222c
4000 4011 3e9d 0a0a
0035 0028 6617 c36b
0000 0a72 6164 696f
7400 0001 0001

udp
0800
0c05
0100
636f

4500
0a0a
0001
6465

IP 0x11 UDP
(17);
I

0xb745 (46917);

0x0035 (53);

0x0028 UDP (40 );

0x6617 .

TCP/IP : Internet

154/299

UDP I

IP, UDP
.
I

UDP
IP ( 16 );

UDP ,
,
(
);

UDP IP
12 . ,
;

0,
;

TCP/IP : Internet

155/299

UDP II

0, ,
;

,
, UDP .
.


, UDP
.
, ,
NFS (Network File
System).

TCP/IP : Internet

156/299

78

15 16

31

IP
Source address

IP
Destination address

Zero

Protocol

UDP
UDP Length

. 38: IP UDP

TCP/IP : Internet

157/299

34: UDP
14
00
0c
00
74

d6
3d
01
00
61

4d
8f
ec
00
72

a7
47
16
00
02

d4
40
00
00
73

fe
00
35
00
75

00
40
00
03
00

1f
11
29
66
00

d0
7f
**
74
1c

59
4c
**
70
00

4e
0a
ff
08
01

b5
0a
3f
64

08
0c
01
61

00
08
00
72

45
0a
00
6b

00
0a
01
73

35: IP
45 00 00 3d 8f 47 40 00 40 11
7f 4c 0a 0a 0c 08 0a 0a 0c 01
36: UDP
ec 16 00 35 00 29 ** **
37: UDP
ff 3f 01 00 00 01 00 00 00 00 00 00 03 66 74 70 08
64 61 72 6b 73 74 61 72 02 73 75 00 00 1c 00 01
TCP/IP : Internet

158/299

78

15 16

31

0x0A0A0C08
Source address

0x0A0A0C01
Destination address

0x00

0x11

0x0029

Zero

Protocol

UDP Length

. 39: IP

TCP/IP : Internet

159/299


0a 0a
16 12
20 1c
2c 1d
2c 2e
2c 57 ... dc 06
+ 0c 08 + 0a 0a + 0c 01 + 00 11 + 00 29 + ec 16 ...+ 01 00
16 12
20 1c
2c 1d
2c 2e
2c 57
18 6e ... dd 06
0xDD06 1101 1101 0000 0110
0010 0010 1111 1001 0x22F9


0a 0a
16 12 ... ....
+ 0c 08 + 0a 0a ... ....
16 12 + 20 1c ... FFFF

TCP/IP : Internet

160/299


TCP/IP.
(Protocol) IP 6.

TCP RFC-793.
TCP
(connection oriented) .
, TCP ( ),
,
.


UDP, TCP
() .
(Point to Point).
TCP
.
TCP/IP : Internet

161/299

I
1. ()
. ,
IP;
2. ,
()
. ,
;
3. (
) (
);
4. TCP
. ,
, .
,
. ,
;
TCP/IP : Internet

162/299

II

5. TCP IP,
.
, TCP

;
6. TCP

( buffers).
, ,
.

.

TCP/IP : Internet

163/299

Internet TCP

20

ftp-data

21
22

ftp
ssh

25

smtp

80
110
873

www
pop3
rsync

FTP

FTP


SMTP
(World Wide Web)
(POP3)


TCP Internet.
TCP
. ,
TCP (. 1).
TCP/IP : Internet

164/299

TCP
IP
TCP

Ethernet
14

IP

TCP

20

20

. 40: TCP IP


TCP 20 ,
60 .

TCP/IP : Internet

165/299

1. (Source port)
(16 );
2. (Destination port)
(16 );
3. (Sequence number)
,
. , ,
(32 );
4. (Acknowledgement number)
, .
ACK.
( ) (32 );
5. (Header length)
TCP 32 (4 );
6. (TCP header flags)
,
TCP, (6 );

TCP/IP : Internet

166/299

7. (Window size)
,
,
(16 );
8. (Checksum)
TCP : .

UDP (32 );
9. (Urgent pointer)
,
.
URG;
10. (Options) TCP
.
32 .

TCP/IP : Internet

167/299

9 10

15

16

31

Source port

Destination port


20

Sequence number


Acknowledgment number

Header length

Reserved

U
R
G

A
C
K

P
S
H

R
S
T

S
Y
N

F
I
N


Window size

Checksum

Urgent pointer

Options

Data

. 41: TCP

TCP/IP : Internet

168/299


URG
ACK

PSH
RST
SYN

FIN

,
.
,
,
.
,
.
,
TCP.
,
(three
way handshaking)
(Initial Sequnce Number).
1.
,
TCP.
,
,
.
1.

TCP/IP : Internet

169/299

~> sudo
0x0000:
0x0010:
0x0020:
0x0030:
0x0040:
0x0050:
0x0060:
0x0070:

38: TCP
tcpdump -i wlan0 -lvvvn -XX -c 1 tcp
14d6 4da7 d4fe 6817 2989 222c 0800 4500
0072 711f 4000 4006 711c 0a0a 0c05 5bee
e64d eb38 008f 8ae8 e7fc 371c cda1 5018
0b5b 6113 0000 0101 080a 0004 e3a8 90fe
a26a 3434 2053 5441 5455 5320 494e 424f
5820 284d 4553 5341 4745 5320 5245 4345
4e54 2055 4944 4e45 5854 2055 4944 5641
4c49 4449 5459 2055 4e53 4545 4e29 0d0a

IP 0x06 TCP (6);


I 0xeb38, 0x008f 60216, 143;
I 0x8ae8 e7fc (2330519548);
I 0x371c cda1 (924634529);
I 0x5, 0x018 (20 ), ACK PSH;
I 0x0b5b, 0x6113 , ;
I 0x0000 ;
TCP/IP : Internet

170/299

TCP I
TCP
(RFC-793) ,
TCP.
TCP
.

TCP sockets finite state machine


TCP
.
.
TCP,
SYN, ACK, RST, FIN ,
11 :
1. Closed TCP , . .
TCP () .
.
;
TCP/IP : Internet

171/299

TCP II
2. Listen TCP , . .
TCP.

(, - WWW
). ,
,
;
3. SYN received TCP
SYN, . . (
);
4. SYN sent TCP SYN, . .
(
);
5. Established
TCP, .
URG, PSH, FIN, ACK,
PSH;
TCP/IP : Internet

172/299

TCP III
6. Close wait TCP (FIN)
, . .
.
,
(ACK);
7. Last ACK TCP
, . . ACK;
8. FIN wait 1 TCP (FIN)
, . .
.
, (ACK);
9. FIN wait 2 ACK
FIN.
,
(ACK).
TCP;

TCP/IP : Internet

173/299

TCP IV

10. Closing , . .
FIN, TCP
FIN .
ACK ;
11. Time wait TCP ,

(2 Maximum Segment Lifetime). (
2MSL) ,
TCP.

TCP/IP : Internet

174/299

Maximum Segment Lifetime



. MSL ,
,
. RFC-793 , MSL 2 .
30 , 1 2
.
MSL :
I

TCP
ACK ,
ACK ;

TCP 2MSL, ,
,
.

TCP/IP : Internet

175/299

:

: [SYN]

Closed
()
:

: [SYN]
: [SYN,ACK]

:

: [SYN]

Listen
()

: [RST]

: [SYN]
: [SYN,ACK]

SYN_rcvd
( SYN)

SYN_sent

( SYN)

: [SYN,ACK]
: [ACK]

: [ACK]

:
-

Established

Close_wait

(
)

:
: [FIN]

( FIN)

: [FIN]
: [ACK]
:
: [FIN]

:
: [FIN]

Last_ACK
( FIN)

: [FIN]
: [ACK]

FIN_wait_1

Closing

( FIN)

()

: [ACK]

: [FIN]
: [ACK]

: [ACK]

: [FIN,ACK]
: [ACK]
: [FIN,ACK]
: [ACK]

FIN_wait_2

Time_wait

( ACK)

(- )

. 42: TCP
TCP/IP : Internet

176/299

netstat network statistics


,
, ,
, . .
man netstat. iproute2 ss.
39: netstat ( net-tools)
~> netstat -lant
Active Internet connections (servers and established)
Proto Local Address
Foreign Address
State
tcp
10.10.12.5:58597 213.158.11.52:443
ESTABLISHED
tcp
127.0.0.1:7634
127.0.0.1:46983
TIME_WAIT
tcp
10.10.12.5:43042 91.238.230.77:143
ESTABLISHED
tcp
127.0.0.1:7634
127.0.0.1:46984
TIME_WAIT
tcp
127.0.0.1:7634
127.0.0.1:46985
TIME_WAIT
tcp
127.0.0.1:7634
127.0.0.1:46980
TIME_WAIT
tcp
10.10.12.5:38619 93.158.134.124:993
ESTABLISHED
tcp
10.10.12.5:58599 213.158.11.52:443
ESTABLISHED
tcp
127.0.0.1:7634
127.0.0.1:46978
TIME_WAIT
TCP/IP : Internet

177/299

c TCP I
TCP
TCP.
3 TCP,

() ISN (Initial Sequence Number).

(three-way handshaking).
TCP:
1. () SYN,
(),
, ISNc ,
;
2. SYN, ACK.
ISNs .
ACK SYN ,
, ,
TCP (Acknowledgement sequence)
ISN, (ISNc + 1);
TCP/IP : Internet

178/299

c TCP II
3. ISNs ,
ACK.
TCP ISNs + 1.

t()

(server)

(client)

SYN ISN_s
ACK ISN_c+1

Listen

Established

SYN_rcvd

SYN_sent

SYN ISN_c

Established ACK ISN_s+1

. 43: TCP
TCP/IP : Internet

179/299

40: tcpdump ( )
~> sudo tcpdump -i wlan0 -vvvnlS -c 4 tcp
21:52:45.726693
10.10.12.5.43221 > 91.122.46.252.21: Flags [S], seq 2921047820
21:52:45.727310
.21 > .43221: Flags [S.], seq 4150798953, ack 2921047821
21:52:45.727335
.43221 > .21: Flags [.], seq 2921047821, ack 4150798954
21:52:45.728659
.21 > .43221: Flags [P.], seq 4150798954:4150798997, ack 2921047821
91.122.46.252:21
[SA], seq 4150798953
ack 2921047821

[PA], seq 4150798954:4150798997


ack 2921047821

(server)

(client)
[S], seq 2921047820

[A], seq 2921047821


ack 4150798954

10.10.12.5:43221

. 44: TCP
TCP/IP : Internet

180/299

TCP:
I

, TCP, . .
SYN ( SYN sent)
.
SYN ( SYN received)
;
(ISN)
TCP . RFC-793 , ISN
4 106 c.
, IP,
,
;

1.
64000
0 9,5 , ,
8 106 c. , ,
TCP, ISN
64000.

TCP/IP : Internet

181/299

TCP
,
(simultaneous open).
TCP ,
, , .
.

SYN ISN_s
ACK ISN_c+1

SYN ISN_s
SYN_sent

Established

SYN_rcvd

~
SYN_sent

SYN_rcvd

SYN ISN_c

SYN ISN_c
ACK ISN_s+1

Established

. 45: TCP
TCP/IP : Internet

182/299

c TCP I
TCP
TCP.
4 TCP. TCP ,
.
TCP:
1. ()
FIN ( ). ()

;
2. () ACK
FIN.
. ()
FIN , . .
, ;
3. , ()
FIN
();
TCP/IP : Internet

183/299

c TCP II
4. ACK , TCP
. .

ACK C+1

t()

Established
(server)

(client)

FIN S

Close_wait

Time_wait

FIN_wait_1
FIN C

Last_ACK

FIN_wait_2

ACK S+1

. 46: TCP

TCP/IP : Internet

184/299

41: tcpdump ( )
~> sudo tcpdump -i eth0 -vvvnlS tcp
17:41:20.288426
.21 > .52834: Flags [F.], seq 3374642807, ack 1727981476
17:41:20.288747
.52834 > .21: Flags [F.], seq 1727981476, ack 3374642808
17:41:20.288931
.21 > .52834: Flags [.], seq 3374642808, ack 1727981477
10.10.12.5:52834
[F.], seq 1727981476
ack 3374642808

(client)

(server)

[F.], seq 3374642807


ack 1727981476

[.], seq 3374642808


ack 1727981477

91.122.46.252:21

. 47: TCP
TCP/IP : Internet

185/299

TCP
TCP,
. TCP
(simultaneous close).

, .

ACK C+1

FIN S
Established

FIN_wait_1

Closing

Time_wait

Established

FIN_wait_1

Closing

Time_wait

FIN C

ACK S+1

. 48: TCP
TCP/IP : Internet

186/299

TCP I
ISO
:
I

(-
SAW ARQ (Stop And Wait Automatic
Repeat Request)). SAW
.
, .
,
;

N
(GBN ARQ Go Back N ARQ).
,
, . ,
,
. . .
;

TCP/IP : Internet

187/299

TCP II


(SR ARQ Selective Repeat ARQ).
GBN ARQ,
. ,
.

TCP GBN ARQ,


TCP/IP (sliding
window) .
,
.
,

.

TCP/IP : Internet

188/299

t1
1

10 11

t2
1

10 11 12 13 14 15

. 49: TCP

TCP/IP : Internet

189/299


, TCP
.
, ,

.


2 101 c.
(Host requirement RFC) ,
TCP ,
5 101 c.
42: tcpdump ( )
.41940 > .21:
.21 > .41940:
.21 > .41940:
.41940 > .21:

[P.],
[P.],
[P.],
[.],

seq
seq
seq
seq

825759627:825759645, ack 2898349004, length 18


2898349004:2898349075, ack 825759645, length 71
2898349075:2898349099, ack 825759645, length 24
825759645, ack 2898349099, length 0

TCP/IP : Internet

190/299

TCP
,
TCP,
(Maximum Segment Size)
(Window Size).


, TCP .
, MSS.
1024 .
IP 40 : 20
TCP 20 IP .

MSS
, MSS ,
.
,
IP TCP .
TCP/IP : Internet

191/299


, "
". ,
. ,
MSS, . MSS
SYN !
MSS ,
536 . , 20
IP 20 TCP,
576 .
43: tcpdump ( )
.49992 > .33051: [S] 517312000 <mss 1460>
.33051 > .49992: [S.] 509556225 ack 517312001 <mss 536>
.49992 > .33051: [.] ack 509556226

TCP/IP : Internet

192/299

MSS MTU
TCP IP .
Ethernet MSS 1460 .

MSS
BSD , MSS 512. Solaris,
SunOS, IBM AIX MSS 1460,
Ethernet.
IP , . .
, MSS 536 .
, IP
, ;
, IP
, ;
, ,
, .

TCP/IP : Internet

193/299

, ,
.
TCP.

BSD
4096 . , Solaris, AIX
, 8192 16384 .
API
.
.
.

TCP/IP : Internet

194/299

44: tcpdump ( )
.11261 > .56612: [S] 1227520000:1227520000 (0)
|--> <win 4096, mss 1460>
.56612 > .11261: [S.] 2363371521:2363371521 (0)
|--> ack 1227520001 <win 6144 mss 1024>
.11261 > .56612: [.] ack 1 <win 4096>
.11261 > .56612: [.] 1:1025(1024) ack 1 <win 4096>
.11261 > .56612: [.] 1025:2049(1024) ack 1 <win 4096>
.11261 > .56612: [.] 2049:3073(1024) ack 1 <win 4096>
.11261 > .56612: [P.] 3073:4097(1024) ack 1 <win 4096>
.11261 > .56612: [.] 4097:5121(1024) ack 1 <win 4096>
.11261 > .56612: [.] 5121:6145(1024) ack 1 <win 4096>
.56612 > .11261: [.] ack 6145 <win 2048>
.11261 > .56612: [.] 6145:7169(1024) ack 1 <win 4096>
.11261 > .56612: [FP.] 7169:8193(1024) ack 1 <win 4096>
.56612 > .11261: [.] ack 6145 <win 4096>
.56612 > .11261: [.] ack 8194 <win 2048>
.56612 > .11261: [.] ack 8194 <win 4096>
.56612 > .11261: [.] ack 8194 <win 6144>
.56612 > .11261: [F.] 1:1(0) ack 8194 <win 6144>
.11261 > .56612: [.] ack 2 <win 4096>
TCP/IP : Internet

195/299

TCP

TCP .
(kind), . , 0
1, 1 . ,
. . ,
TCP RFC-793 RFC-1323:
1. 0;
2. (No operations, NOP) 1;
3. 2;
4. 3;
5. 8.
, ,
4 .

TCP/IP : Internet

196/299

1 1

MSS
2

1 1 1

10

1 1

. 50: TCP

45: tcpdump ( )
.43291 > .33531: [S] 71312001
<mss 512, nop, wscale 0, nop, nop, timestamp 146647 0>
TCP/IP : Internet

197/299


(Domain Name System, DNS)
TCP/IP. ,
TCP/IP,
IP .

DNS
C DNS (Internet
E-Mail).
DNS
Internet , ,
. Internet
( , , . .)
,
.


RFC-1034 DNS, RFC-1035
DNS.
TCP/IP : TCP/IP

198/299

DNS
DNS,
/etc/hosts.
46: /etc/hosts
# /etc/hosts: Local Host Database
# IPv4 and IPv6 localhost aliases
127.0.0.1 hyperion hyperion.radiocoder.net localhost
::1
hyperion hyperion.radiocoder.net localhost
# local network aliases
10.19.0.1 gateway.mysite.org
10.19.0.21 ftp.mysite.net
10.22.2.1 email.mysite.net

( );

TCP/IP : TCP/IP

199/299

, ,
DNS Internet,
,
( ) ,
.
, DNS
(resolver) ,
, DNS,
Internet.

DNS resolver
() ,
TCP/IP.
IP ,
TCP UDP.

TCP/IP : TCP/IP

200/299

DNS UNIX
UNIX,
, gethostbyname gethostbyaddr,
(build with linking) , .
IP
( ), IP
( ).
DNS (name server),
IP .

DNS
DNS
UDP, IP.
53,
. , , DNS
TCP :
I (truncated) ;
I

DNS.

TCP/IP : TCP/IP

201/299

DNS ,
.

arpa

com

...

net

...

org

...

uk

...

ru

in-addr
175

...

su

fido

61

web

()

122
91

PTR: 91.122.61.175.in-addr.arpa.

. 51: DNS
TCP/IP : TCP/IP

202/299

63 ;

(.) ;

(domain name)
,
, ;

,
.

FQDN Fully Qualified Domain Name


, ,
. :
I

sun.tux.org. ;

sun.daemon.co , .
uk,
sun.daemon.co.uk.

TCP/IP : TCP/IP

203/299

:
I

arpa ,
(IP hostname);

3 (generic)
;

2 , (ISO 3166),
(country)
(geographical) .


DNS
. ,

. , (NIC Network Information
Center) ,
.

TCP/IP : TCP/IP

204/299

DNS
Internet 13 DNS (root name
servers), .
, ,
.
.


FTP NIC
(ftp://ftp.rs.internic.net/domain/named.root)
http://www.root-servers.org
47:
.
A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET.
.
B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET.

3600000
3600000
3600000
3600000
3600000
3600000

TCP/IP : TCP/IP

NS
A
AAAA
NS
A
AAAA

A.ROOT-SERVERS.NET.
198.41.0.4
2001:503:ba3e::2:30
B.ROOT-SERVERS.NET.
192.228.79.201
2001:500:84::b
205/299

. 52:

TCP/IP : TCP/IP

206/299

DNS
DNS (zone) DNS.
, sut.ru .
(ikss.sut.ru . .).

DNS:
1. (primary) DNS
.
;
2. (secondary) DNS,
()
.
,
:

A
NS
CNAME
PTR
MX

IP
DNS


TCP/IP : TCP/IP

207/299

48:
site.net. IN SOA atlas.site.net. admin.site.net. (
2006051501 ; Serial
10800
; Refresh
3600
; Retry
604800
; Expire
300
; Negative Response TTL
)
;DNS
IN NS atlas.site.net.
IN NS titan.site.net.
;Origin IP
IN A 91.122.46.25
;Mail
IN MX 10 meteor.site.net.
IN MX 20 comet.site.net.
;Hosts
atlas IN A 91.122.46.99
titan IN A 91.122.46.100
meteor IN A 91.122.46.101
comet IN A 91.122.46.102
skoll IN A 91.122.47.1
imir
IN A 91.122.47.2
;Aliases
www IN CNAME site.net.
TCP/IP : TCP/IP

208/299

DNS
, .
:
I

DNS
,
;
DNS-
10.10.12.3

1.: web.sut.ru IN A ?

DNS
10.10.12.5

2.: sut.ru NS 172.31.100.1


3.: web.sut.ru IN A ?

DNS
172.31.100.1
4.: web.sut.ru IN A 172.17.101.11

. 53:

TCP/IP : TCP/IP

209/299

DNS

(authoritative) DNS.
DNS-
10.10.12.3

1.: web.sut.ru IN A ?

DNS
10.10.12.5

4.: web.sut.ru IN A 172.17.101.11

2.: web.sut.ru IN A ?
3.: web.sut.ru IN A 172.17.101.11
DNS
172.31.100.1

. 54:

TCP/IP : TCP/IP

210/299

49: DNS
~> sudo tcpdump -vvvln -i wlan0 udp and \( dst port 53 or src port 53 \)
IP (tos 0x0, ttl 64, id 10587, offset 0, DF, proto UDP (17), length 60)
10.10.12.5.37122 > 10.10.12.1.53:
|-[udp sum ok] 56414+ A? opds.spbsut.ru. (32)
IP (tos 0x0, ttl 64, id 17459, offset 0, proto UDP (17), length 182)
10.10.12.1.53 > 10.10.12.5.37122:
|-[udp sum ok] 56414 q: A? opds.spbsut.ru.
|--1/3/3 opds.spbsut.ru. [1h] A 91.238.230.164
|---ns: spbsut.ru. [1h] NS ns.itut.ru.,
|----ar: ns.itut.ru. [3d11h4m41s] A 91.238.230.70.

50: /etc/resolv.conf
search site.org
domain site.org
nameserver 10.19.0.2
nameserver 10.19.0.3

TCP/IP : TCP/IP

211/299

DNS

IP, DNS:
1. /etc/hosts;
2. ;
3. DNS.



Punycode.

Hostname IP
Hostname IP , . .
, (
).
( web- Apache).
TCP/IP : TCP/IP

212/299

DNS
1. BIND Berkeley Internet Name Daemon;
2. djbdns D. J. Bernstein DNS;
3. NSD Name Server Daemon ( );
4. Microsoft DNS Server NT.

DNS
1. host DNS
;
2. dig domain information groper, BIND,
DNS;
3. nslookup name server lookup , dig,
, .

TCP/IP : TCP/IP

213/299

Internet
, , . ,
,

.
,
Network Time Protocol (NTP),
. NTP
1985 ,
TCP/IP Internet.
RFC-5905 (
4).


UDP IP.
NTP 123 UDP/TCP.
- .
.
TCP/IP : TCP/IP

214/299

NTP
(stratum , ).
,
.



() .


. ,

, . .
I

0 (stratum 0)
.
,
. .;

TCP/IP : TCP/IP

215/299

1 (stratum 1)
( )
stratum 0. 1 (NTP)
1.
1 2;

2 (stratum 2)
,
1,
2. 2
3;

3
;

NTP 256 .

NTP
3 ;

, , 4,
7 .

TCP/IP : TCP/IP

216/299

S1

S2

S3

S3

RS-232

S1

S2

S3

IEEE-1284

IEEE-1394

S1

S2

S3

S3

. 55: NTP


, NTP
,

, ,
NTP.
TCP/IP : TCP/IP

217/299

I
I

I
I

NTP 4 10 103 c
Internet;
0.2 103 ;
NTP 64 ,
32 32 ,
232 .,
232 .;
00:00 1 1900 (UTC), 00:00 1
1970 (UTC), NTP 70
( ),
Windows UNIX.
http://www.pool.ntp.org
Internet,
NTP .
IP ;
http://ntp.org/ NTP;
http://www.vniiftri.ru
- -

NTP.

TCP/IP : TCP/IP

218/299

NTP vniiftri.ru
I

4- stratum 1,
;
4- stratum 1,
;
stratum 2
.

ntp1.vniiftri.ru
ntp2.vniiftri.ru
ntp3.vniiftri.ru
ntp21.vniiftri.ru


IPv4 UDP 123
IPv4 UDP 123
IPv4 UDP 123
IPv4 UDP 123

TCP/IP : TCP/IP

stratum 1
stratum 1
stratum 1
stratum 2


Meinberg M300/MRS
Intel Xeon, ntpd 4.2.4p8

219/299

51: NTPv4
~> sudo tcpdump -i wlan0 -lvn udp and \( src port 123 or dst port 123 \)
10.10.12.5.123 > 10.10.12.1.123: [udp sum ok] NTPv4, length 48
Client, Leap indicator: clock unsynchronized (192)
Root Delay: 0.000000, Root dispersion: 0.000000, Reference-ID: (unspec)
Reference Timestamp: 0.000000000
Originator Timestamp: 0.000000000
Receive Timestamp:
0.000000000
Transmit Timestamp:
3626080117.284741491 (2014/11/27 15:28:37)
Originator-Receive Timestamp: 0.000000000
Originator-Transmit Timestamp: 3626080117.284741491 (2014/11/27 15:28:37)
10.10.12.1.123 > 10.10.12.5.123: [udp sum ok] NTPv4, length 48
Server, Leap indicator: (0), Stratum 2 (secondary reference)
Root Delay: 0.029754, Root dispersion: 0.043258
Reference Timestamp: 3626079275.349624961 (2014/11/27 15:14:35)
Originator Timestamp: 3626080117.284741491 (2014/11/27 15:28:37)
Receive Timestamp:
3626080117.284362643 (2014/11/27 15:28:37)
Transmit Timestamp:
3626080117.284408271 (2014/11/27 15:28:37)
Originator - Receive Timestamp: -0.000378835
Originator - Transmit Timestamp: -0.000333213

TCP/IP : TCP/IP

220/299

52: /etc/ntp.conf
server atlas.radiocoder.net iburst
# Pools for Gentoo users
#server 0.gentoo.pool.ntp.org
#server 1.gentoo.pool.ntp.org
#server 2.gentoo.pool.ntp.org
# you should not need to modify the following paths
driftfile /var/lib/ntp/ntp.drift
# Allow only time queries, at a limited rate, sending KoD when in excess.
# Allow all local queries (IPv4, IPv6)
#restrict default nomodify nopeer noquery limited kod
#restrict 127.0.0.1
#restrict [::1]
# To allow machines within your network to synchronize
# their clocks with your server, but ensure they are
# not allowed to configure the server or used as peers
# to synchronize against, uncomment this line.
#
#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap

TCP/IP : TCP/IP

221/299


()
(Dynamic Host Configuration Protocol, DHCP)

. DHCP
-,
.


RFC-2131.


DHCP BOOTP (Boot Protocol),
(.
RARP). DHCP IANA
BOOTP. 67 UDP, 68 UDP.
IPv6 DHCPv6 (RFC-3315).
TCP/IP : TCP/IP

222/299

DHCP
:
I

(MAC)
(IP);

,
,
( , ).

.

DHCP
IP .
:
I

DNS;

(NTP) . .

TCP/IP : TCP/IP

223/299

53: DHCP
~> sudo tcpdump -i wlan0 -lvn udp and \( src port 67 or dst port 68 \)
f8:01:13:7a:12:2d > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800)
0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP
-> Request from 68:17:29:89:22:2c, length 389, xid 0x7554abca
--> Flags [none] (0x0000)
Client-Ethernet-Address 68:17:29:89:22:2c
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Request
Client-ID Option 61, length 19: hardware-type 255,
-> 29:89:22:2c:00:01:00:01:1a:53:11:59:2c:d4:44:9f:c3:dc
Requested-IP Option 50, length 4: 10.10.12.5
MSZ Option 57, length 2: 1500
Vendor-Class Option 60, length 68: "dhcpcd-6.3.2:Linux-3.12.26-gentoo"
Hostname Option 12, length 23: "hyperion.radiocoder.net"
T145 Option 145, length 1: 1
Parameter-Request Option 55, length 14:
Subnet-Mask, Classless-Static-Route, Static-Route, Default-Gateway
Domain-Name-Server, Hostname, Domain-Name, BR
NTP, Lease-Time, Server-ID, RN
RB, Option 119
END Option 255, length 0

TCP/IP : TCP/IP

224/299

54: DHCP
14:d6:4d:a7:d4:fe > 68:17:29:89:22:2c, ethertype IPv4 (0x0800)
10.10.12.1.67 > 10.10.12.5.68: [udp sum ok] BOOTP/DHCP
-> Reply, length 300, xid 0x7554abca, Flags [none] (0x0000)
Your-IP 10.10.12.5
Client-Ethernet-Address 68:17:29:89:22:2c
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: ACK
Server-ID Option 54, length 4: 10.10.12.1
Lease-Time Option 51, length 4: 3600
Subnet-Mask Option 1, length 4: 255.255.255.240
Default-Gateway Option 3, length 4: 10.10.12.1
Domain-Name-Server Option 6, length 8: 10.10.12.1,10.10.12.2
Domain-Name Option 15, length 14: "radiocoder.net"
BR Option 28, length 4: 10.10.12.15
END Option 255, length 0

55: dhcpcd
~> sudo dhcpcd wlan0
dhcpcd[4320]: wlan0:
dhcpcd[4320]: wlan0:
dhcpcd[4320]: wlan0:
dhcpcd[4320]: wlan0:
dhcpcd[4320]: forked

rebinding lease of 10.10.12.5


leased 10.10.12.5 for 3600 seconds
adding route to 10.10.12.0/28
adding default route via 10.10.12.1
to background, child pid 4362

TCP/IP : TCP/IP

225/299

56: ISC-DHCP DHCP


option domain-name "site.org";
option domain-name-servers ns1.site.org;
option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 72400;
subnet 10.254.239.0 netmask 255.255.255.224 {
range 10.254.239.10 10.254.239.20;
option routers rtr-239-0-1.site.org, rtr-239-0-2.site.org;
}
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;9
fixed-address fantasia.site.org;
}

TCP/IP : TCP/IP

226/299



1989 . - (Tim Berners-Lee)
, ,
, , . . . .


.
,
, Internet. ,
World Wide Web, (W3).
, 1990 .
, 1993 .

TCP/IP : TCP/IP

227/299



(Hyper-Text Transfer Protocol, HTTP), ISO

(Hyper-Text Markup Language, HTML).
(Universal Resourse Locator, URL)
WWW.
- (web-brouser),
.


WWW ,
.
WWW
.

TCP/IP : TCP/IP

228/299

W3 ()
, ,
( WWW)
, ,
. Web,
Web- .


WWW - (-
-).
TCP, IANA 80 ().
HTML,
(, tags) :
,
HTML- .
, .

TCP/IP : TCP/IP

229/299

:
I HTML (Hyper-Text Markup Language)
;
I

URL (Universal Resource Locator)


( ).
Web , ()
(URI, Universal Resource Identifier);

HTTP (Hyper-Text Transfer Protocol)


;

CGI (Common Gateway Interface) .


HTTP- ,
(, ).

RFC-1866 Hyper-Text Markup Language HTML 2.0;

RFC-1945 Hyper-Text Transfer Protocol HTTP/1.0;

RFC-2616 Hyper-Text Transfer Protocol HTTP/1.1.

TCP/IP : TCP/IP

230/299

Hyper-Text Transfer Protocol ,


WWW Web-.
I

RFC-1945 Hypertext Transfer Protocol


HTTP/1.0 (T. Berners-Lee, R. Fielding, H. Frystyk May 1996);

RFC-2616 Hypertext Transfer Protocol


HTTP/1.1 (R. Fielding, J. Gettys, J. Mogul, H. Frystyk, L. Masinter, P. Leach

T HTTP TCP,
HTTP ( Web)
80 TCP, HTTP (
Web) .

Web
URL:
protocol://user:password@host:port/path/file?paremeters#fragment

1. protocol ,
;
2. user , ;
TCP/IP : TCP/IP

231/299

3. password
;
4. host IP , ;
5. port , ,
;
6. path , ;
7. file , ;
8. paremeters -;
9. fragment (, anchor),
.

TCP/IP : TCP/IP

232/299

Web
. HTTP
.
:
1. ;
2. 1;
3. 2;
4. . . . ;
5. N;
6. ;
7. ( ).
(start-line) .
:
1. (general-headers),
, ;
2. (request-headers),
;
3. (response-headers),
;
4. (entity-headers),
;
TCP/IP : TCP/IP

233/299

, : .

Content-Encoding
Content-Length
Expires
Last-Modified

Location
Server
Age


, ,
, .
.
,
, .

.

URI ,
.
,
.
,
.

TCP/IP : TCP/IP

234/299


Accept-Charset
Accept-Encoding
Host
User-Agent
Connection
Date
Pragma

Transfer-Encoding


,
.
,
.
,
.
.

(close)
(keep-alive) .
.
,
,

.
.

TCP/IP : TCP/IP

235/299


(request-line),
(, , ) , , .
:
< HTTP> < > < HTTP>

HTTP:

OPTIONS

GET

(,
,

,
),

,

( ).
(),
,
.

TCP/IP : TCP/IP

236/299


HEAD
POST

PUT

DELETE
TRACE

GET, ,
.
,
, ()
, ,
..
, ,
,
.
,
.
.
( Web)
.

TCP/IP : TCP/IP

237/299

,
HTTP .


(status-line)
:
< HTTP> < > < >

. . .
(status-code)
.
(reason-phrase) .
,
.
.
. 5
:

TCP/IP : TCP/IP

238/299

1. 1xx ,
;
2. 2xx ,
;
3. 3xx
;
4. 4xx
;
5. 5xx
.

TCP/IP : TCP/IP

239/299

HTTP TCP
; HTTP
TCP, ,
, -
(, . .),
;

HTTP
ontent-Type: /,
, ;

POST HTTP
,
CGI (-). HTML
. , ,
.

TCP/IP : TCP/IP

240/299


WWW .
-,
. ,
HTTP
(SSL, WebDAV . .). , -
(
- ), -
,
.
LAMP. - ( ,
, , . .) :
1. (,
- GNU/Linux);
2. - (, Apache);
3. (, MySQL);
4. -
(, PHP).
TCP/IP : TCP/IP

241/299

-
I

Apache a patchy server, . . ;

IIS Internet Information Services, IIS HTTP,


HTTPS, FTP, POP3, SMTP, NNTP;

nginx engine x, - -,
(http://www.sysoev.ru/);

lighttpd lighty http daemon, -,


.

TCP/IP : TCP/IP

242/299

57: WWW
~> telnet 10.10.12.1 80
Trying 10.10.12.1...
Connected to 10.10.12.1.
Escape character is ^].
GET http://10.10.12.1/index.html http/1.0
HTTP/1.0 200 OK
Date: Thu, 04 Dec 2014 20:55:22 GMT
Server: Apache/2.2.23 (FreeBSD) mod_scgi/1.12 PHP/5.4.12 DAV/2
Last-Modified: Thu, 04 Dec 2014 20:54:27 GMT
ETag: "c7413-7b-5096a2a7446c0"
Accept-Ranges: bytes
Content-Length: 123
Content-Type: text/html
X-Cache: MISS from atlas
Via: 1.1 atlas:3128 (squid/2.7.STABLE9)
Connection: close
<html>
<title>Welcome page</title>
<head>Welcome to site!</head>
<body>This is the main site page</body>
</html>
Connection closed by foreign host.
TCP/IP : TCP/IP

243/299

58: tcpdump
~> sudo tcpdump -i wlan0 -lvn tcp and \( src port 80 or dst port 80 \) \
and ip host 10.10.12.1
10.10.12.5.42946 > 10.10.12.1.80: [S], seq 4157395191, length 0
.80 > .42946: [S.], seq 2524975084, ack 4157395192, length 0
.42946 > .80: [.], seq 1, ack 1, length 0
.42946 > .80: [P.], seq 1:44, ack 1, length 43
.80 > .42946: [.], seq 1, ack 44, length 0
.42946 > .80: [P.], seq 44:46, ack 1, length 2
.80 > .42946: [P.], seq 1:352, ack 46, length 351
.42946 > .80: [.], seq 46, ack 352, length 0
.80 > .42946: [P.], seq 352:475, ack 46, length 123
.42946 > .80: [.], seq 46, ack 475, length 0
.80 > .42946: [F.], seq 475, ack 46, length 0
.42946 > .80: [F.], seq 46, ack 476, length 0
.80 > .42946: [.], seq 476, ack 47, length 0

TCP/IP : TCP/IP

244/299

W3 I

W3 FTP
W3,
FTP.
Internet FTP
.
FTP,

, ,
, . . ,
,
,
(BitTorrent, eD2k . .).

TCP/IP : TCP/IP

245/299

W3 II
I

Archie FTP Internet.


- Archie ,
.
FTP,
. ( )
FTP. W3
Internet - Archie;

WAIS Wide Area Information Servers


. Archie,
,
( ). WAIS ,
,
. . WAIS,
;

TCP/IP : TCP/IP

246/299

W3 III
I

Gopher Internet,
- gopher
Internet (Archie, WAIS
FTP). ,
Internet, ,
,
().
HTTP W3. 2000 ( )
(GNU
GPL). -
,
TCP, IANA
70 (TCP/UDP). RFC-1436;

Veronica Very Easy Rodent-Oriented Netwide Index to Computerized


Archives Gopher.
( )
Gopher. Veronica, ,
Gopher.

TCP/IP : TCP/IP

247/299

W3 IV

FidoNet
.
1984 . ,

,
, .
,
, .

(Zone mail hour). . , 64
FidoNet, http://www.fidonet.org.

TCP/IP : TCP/IP

248/299

I
:
I

X.400 ITU (International Telecommunication


Union, )
,
.
(ISO/OSI),
, , ,
;

UUCP ,
uucp (Unix-to-Unix CoPy)
. cp,

. UUCP uucp
( )

TCP/IP. ( uucpd)
IANA 540 (TCP/UDP).
RFC-976;

TCP/IP : TCP/IP

249/299

II

FidoNet EchoMail
FidoNet;

SMTP Simple Mail Transfer Protocol,


.
TCP/IP,
Internet. -.

. ,

RFC-2821.

TCP/IP : TCP/IP

250/299


RFC-2822.
:
1. (Envelope),
,
SMTP, ;
2. (Header), ,
, ,
,
, , ,

. ., ;
3. (Body), ,
.

TCP/IP : TCP/IP

251/299



. ,
.



ASCII (US).
RFC-2047.


, , ,

MIME (RFC-2045).
.

TCP/IP : TCP/IP

252/299


Date:
From:
Reply-To:
To:
Cc:
Bcc:
Message-ID:
In-Reply-To:
References:
Subject:
Return-Path:
Received:

MIME-Version:
Content-type:
Content-Transfer-Encoding:

TCP/IP : TCP/IP

.
.
.
.
.
.
.
,
.

.
.
,
.
.
,

,
Received:,
IP ,
, . .
MIME.
, .

ASCII, .

253/299

Internet

-
Internet -
. ,
, .
,
,
.

-
,
- , ,
.

TCP/IP : TCP/IP

254/299

RFC-2822.
: _@_
I _ ,
;
I @ ([at]) -;
I _ ,
.


,
ASCII.
,
Internet RFC-1034.
, ,

:
<_@_>
.. <inebaev@spbgut.ru> (. - )

.
TCP/IP : TCP/IP

255/299



Internet,
IP ,
DNS.
1. , ,
DNS ;
2. ,
. MX (Mail
eXchange).

. ,
, ,
.

TCP/IP : TCP/IP

256/299

59: dig mx
~> dig sut.ru mx
; DiG 9.9.5
;; QUESTION SECTION:
;sut.ru. IN MX
;; ANSWER SECTION:
sut.ru. 86400 IN MX 10 mail.sut.ru.
sut.ru. 86400 IN MX 50 mail1.sut.ru.
;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Dec 11 21:35:27 MSK 2014
;; MSG SIZE rcvd: 78

60: dig a
~> dig mail.sut.ru a
; DiG 9.9.5
;; QUESTION SECTION:
;mail.sut.ru. IN A
;; ANSWER SECTION:
mail.sut.ru. 86400 IN A 91.238.228.4
;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Dec 11 21:38:15 MSK 2014
;; MSG SIZE rcvd: 56
TCP/IP : TCP/IP

257/299

Internet
Internet
(E-Mail),
(E-Mail server daemon),
(SMTP, POP, IMAP),
.
:
I

Mail User Agent, MUA ,


;

Mail Transfer Agent, MTA , ;

MUA

SMTP

POP
IMAP

MTA

MTA

MUA

. 56: E-Mail

TCP/IP : TCP/IP

258/299

MTA 1

MTA 2

MTA N

SMTP

SMTP

LDA

SMTP

MUA

MUA

POP E-Mail
IMAP Storage

. 57: E-Mail

TCP/IP : TCP/IP

259/299

Mail User Agent


MUA , ,
. ,
.
, , ,
MUA MUA .
Internet
, RFC-2822.
MUA SMTP MTA,
RFC-821.
TCP, IANA 25
TCP/UDP (465 TCP SMTPs TLS/SSL).
MUA ,
.
:

TCP/IP : TCP/IP

260/299

Post Office Protocol, Version 3 (POP3)


, 3, RFC-1939,
, .
TCP,
IANA 110 TCP/UDP (995 POP3s
TLS/SSL);

Internet Message Access Protocol (IMAP)


, RFC-3501,
, POP3,
,
, .
TCP,
IANA 143 TCP/UDP (993 IMAP4s
TLS/SSL).

TCP/IP : TCP/IP

261/299

MUA
:
I

Microsoft Outlook;
Mozilla Thunderbird ( Netscape Communicator);

The Bat!;

Sylpheed;

Eudora, Elm, Pine, Alpine .;

Web E-mail;

TCP/IP : TCP/IP

262/299

Mail Transfer Agent


MTA ,
. , MUA,
, ,
MTA,
(Local Delivery Agent, LDA).
MTA :
I


, DNS.

TCP/IP : TCP/IP

263/299

MTA
MTA
MTA.
, ,
IP (. DNS).
,
.
, MTA, ,
.
RFC-2505
:
1. IP ,
MTA;
2. ,
MTA;
3. .

TCP/IP : TCP/IP

264/299

, MTA
. MTA, ,
, ,
.
.


MTA :
, .


MTA, ,
, ,
.
,
. MTA
. ,
,
. ,
TCP/IP : TCP/IP

265/299

. , ,
, ,
.

MTA
MTA MUA RFC-1123
RFC-2821 RFC-2822.

MTA
:
I

Microsoft Exchange;

Sendmail;

Postfix;

Exim;

Qmail.

TCP/IP : TCP/IP

266/299

61: E-Mail telnet


~>
S.
C.
S.
S.
S.
S.
S.
C.
S.
C.
S.
C.
S.
C.
S.
C.
S.
C.
C.
S.
C.
S.

telnet foo.org 25
220 foo.org Service Ready
EHLO bar.org
250-foo.org greets bar.org
250-8 BITMIME
250-SIZE
250-DSN
250 HELP
MAIL FROM:<johnsmith@bar.org>
250 OK
RCPT TO:<jjones@foo.org>
250 OK
RCPT TO:<green@foo.org>
550 No such user here
RCPT TO:<brown@foo.org>
250 OK
DATA
354 Start mail input; end with <CRLF>.<CRLF>
Hello everybody!
.
250 OK
QUIT
221 foo.org Service closing transmission channel

TCP/IP : TCP/IP

267/299

62: E-Mail telnet


~>
S.
C.
S.
C.
S.
C.
S.
S.
S.
S.
S.
C.
S.
S.
S.
S.
S.
S.
C.
S.
C.
S.
C.
S.

telnet foo.org 110


+OK ready <6584.1077893295@foo.org>
USER brown
+OK Password required for brown.
PASS *****
+OK brown has 3 visible messages in 223385 octets.
LIST
+OK 3 visible messages (223385 octets)
1 111293
2 111285
3 807
.
TOP 3 1
+OK Message follows
Return-Path: <johnsmith@bar.org>
...
Status: RO
Hello everybody!
.
DELE 3
+OK Message 3 has been deleted.
STAT
+ OK 2 222578
QUIT
+OK Pop server at foo.org signing off.

TCP/IP : TCP/IP

268/299

: GNS3
gns3 a graphical network simulator (http://www.gns3.net/),
,

.

CCNA, CCNP, CCIP CCIE.
:
I Dynamips , IOS
. IOS
!;
I Dynagent (front-end) (back-end),
;
I Qemu ,
(http://wiki.qemu.org/Main_Page);
I VirtualBox
(https://www.virtualbox.org/).
: J. Grossmann, D. Ruiz,
R. Lamaison, A. Levesque, X. Alt, B. Marsili, C. Goudjil,
A. Eromenko aka Technologov.
TCP/IP : : GNS3

269/299

: (http://www.gns3.net/documentation/)
:
1. Introduction to GNS3;
2. GNS3 quick start guide for <OS_name> users;
3. Creating the simplest topology.
:
(http://www.youtube.com/watch?v=JoSTJx5NUHI).


Windows PuTTY
(http://www.chiark.greenend.org.uk/~sgtatham/putty/
download.html).
UNIX-like - xterm.

IOS
I

ftp://91.122.46.252/pub/GNS3/

. 505, /home/student/GNS3/images/

TCP/IP : : GNS3

270/299

-
~> uname -a
Linux 3.12.26-gentoohyperion-csm-i686
i686 Intel(R) Pentium(R) CPU 2020M @ 2.40GHz
GenuineIntel GNU/Linux
GNS3:
=> ver
GNS3 version is 0.8.6
Qt version is 4.8.5
PyQt version is 4.10.3
SIP version is 4.15.4
Python version is 2.7.8 (32-bit)
Python default encoding is utf-8
GNS3 run path is /usr/lib/python-exec/python2.7
Dynagen version 0.13.1.20131002

TCP/IP : : GNS3

271/299

. 58: IOS GNS3


TCP/IP : : GNS3

272/299

. 59:
TCP/IP : : GNS3

273/299

. 60:
TCP/IP : : GNS3

274/299

. 61:
TCP/IP : : GNS3

275/299

. 62: IDLE PC
TCP/IP : : GNS3

276/299

. 63: IDLE PC
TCP/IP : : GNS3

277/299

. 64: ()
TCP/IP : : GNS3

278/299

. 65:
TCP/IP : : GNS3

279/299

. 66:

TCP/IP : : GNS3

280/299

. 67:
TCP/IP : : GNS3

281/299

. 68:

. 69: R1

TCP/IP : : GNS3

282/299

. 70: R2

. 71:
TCP/IP : : GNS3

283/299

. 72:

. 73:
TCP/IP : : GNS3

284/299

. 74:

TCP/IP : : GNS3

285/299

. 75:
TCP/IP : : GNS3

286/299

. 76:

. 77: IOS

TCP/IP : : GNS3

287/299

. 78: IOS

TCP/IP : : GNS3

288/299

. 79:

TCP/IP : : GNS3

289/299

. 80: IP R1

TCP/IP : : GNS3

290/299

. 81:

. 82: R2

TCP/IP : : GNS3

291/299

. 83: R1

. 84: R2

TCP/IP : : GNS3

292/299

. 85: CDP R1

. 86: R2

TCP/IP : : GNS3

293/299

. 87:
TCP/IP : : GNS3

294/299

. 88:

. 89: GNS3
TCP/IP : : GNS3

295/299

: I
1. (API) TCP/IP;
2. TCP/IP
;
3. TCP/IP;
4. - Internet (
-);
5. ;
6. - TCP/IP;
7. TCP/IP. IEEE 802 Ethernet;
8. TCP/IP. SLIP PPP;
9. TCP/IP. ;
10. (ARP),
(RARP);
11. Internet, ;
12. Internet, IPv4;
TCP/IP : :

296/299

: II
13. Internet, IPv4;
14. Internet, ;
15. Internet v6,
;
16. Internet v6, ;
17. Internet v6, IPv6;
18. Internet (ICMP),
;
19. Internet v6 (ICMPv6),
ICMP;
20. , ;
21. (UDP),
;
22. (TCP),
;
TCP/IP : :

297/299

: III
23. (TCP),
, netstat;
24. (TCP),
;
25. (TCP),
;
26. (TCP),

TCP;
27. (TCP),
TCP, TCP;
28. TCP/IP,
(DNS);
29. TCP/IP,
Internet (NTP);
30. TCP/IP,
(DHCP);
TCP/IP : :

298/299

: IV

31. TCP/IP,
(WWW);
32. TCP/IP,
Internet (xFTP);
33. TCP/IP,
Internet (E-Mail), .
34. TCP/IP,
Internet (E-Mail).

TCP/IP : :

299/299