View
258
Download
14
Category
Preview:
Citation preview
Компютърни Мрежи и GNU/Linux
Боян Кроснов
boyan@krosnov.org http://boyan.krosnov.org/
Мариян Маринов
mm@yuhu.bizSiteGround LLC
2
Лекцията
Преговор Linux Networking Stack Команди – IP ARP протокол Команди – ARP Sniffers TCP и UDP протоколи Команди – TCP и UDP
4
Слоести мрежови модели
1. Physical
2. Datalink
3. Network
4. Transport
5. Session
6. Presentation
7. Application
6
Протоколи
1. baseband, *PSK, QAM-*, OFDM, CDMA, etc. overCat5, Fiber, HFC, phone line, RF etc.
2. Ethernet (802.3) , 802.11, 802.15, 802.16, PPP
3. IP/IPv6
4 and 5. TCP, UDP, RTP
7. HTTP, FTP, SMTP, POP3, IMAP4, SIP, XMPP, IRC, SNMP, SSH, TELNET, DNS, NTP, DHCP
7
Мрежова топология
router
subnet, (V)LAN
hosthost
host
host
subnet, (V)LAN
host host
host
subnet, (V)LAN
host
host
host
hostsubnet, (V)LAN
router
14
Команди - IP
ipcalc ip addr; ifconfig ip route; route ping; fping traceroute; mtr /etc/network/interfaces (Debian)
/etc/sysconfig/network-scripts (Redhat)
ARP Protocol
RFC826: Ethernet Address Resolution Protocol: Or Converting Network Protocol Addresses to 48.bit Ethernet Address for Transmission on Ethernet Hardware. D. Plummer. November 1982. (Format: TXT=21556 bytes) (Also STD0037) (Status: STANDARD)
ARP Table
gw:~# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.0.5 ether 00:0B:DB:4A:BD:8A C eth1
192.168.0.10 ether 00:0E:A6:6A:B1:12 C eth1
192.168.0.150 ether 00:14:BF:2C:94:5A C eth1
172.16.0.199 ether 00:13:02:4F:78:16 C eth1
192.168.0.124 ether 00:1C:BF:0F:24:F9 C eth1
172.16.0.22 (incomplete) eth1
85.14.21.165 ether 00:17:0F:AD:E1:C0 C eth0
85.14.21.44 ether 00:19:66:34:B1:24 CM eth0
MAC address table
Switch# show mac-address-table vlan 254
. . .
vlan mac address type learn age ports
------+----------------+--------+-----+----------+-----------------
* 254 0004.6a00.326c dynamic Yes 5 Gi1/29
* 254 0003.f402.60e5 dynamic Yes 0 Gi1/3
* 254 0004.6a00.35c0 dynamic Yes 5 Gi1/3
* 254 0004.6a00.31dc dynamic Yes 5 Gi1/3
* 254 0040.c7f6.11e3 dynamic Yes 0 Gi1/3
* 254 0004.6a00.3004 dynamic Yes 5 Gi1/3
* 254 0004.6a00.350c dynamic Yes 5 Gi1/3
* 254 0004.6a00.3720 dynamic Yes 5 Gi1/3
. . .
23
TCP и UDP протоколи
UDP (RFC768 J.Postel 1980)– ports
TCP (RFC793 J.Postel 1981)– Session establishment and tear-down– Window procedure– Slow start and congestion avoidance (VJ 1988)
Berkeley sockets (1983)– The Berkeley socket API forms the de facto
standard abstraction for network sockets. Most other programing languages use an interface similar to the C API. // wikipedia
24
Протоколи
1. baseband, *PSK, QAM-*, OFDM, CDMA, etc. overCat5, Fiber, HFC, phone line, RF etc.
2. Ethernet (802.3) , 802.11, 802.15, 802.16, PPP
3. IP/IPv6
4 and 5. TCP, UDP, RTP
7. HTTP, FTP, SMTP, POP3, IMAP4, SIP, XMPP, IRC, SNMP, SSH, TELNET, DNS, NTP, DHCP
UDP header
0 7 8 15 16 23 24 31
+--------+--------+--------+--------+
| Source | Destination |
| Port | Port |
+--------+--------+--------+--------+
| | |
| Length | Checksum |
+--------+--------+--------+--------+
|
| data octets ...
+---------------- ...
User Datagram Header Format
TCP Header
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F| |
| Offset| Reserved |R|C|S|S|Y|I| Window |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
TCP Header Format
28
TCP и UDP команди
telnet tcptraceroute netstat, fuser, lsof hping nc - TCP/IP swiss army knife
/etc/inetd.conf
Recommended