Ethernet / TCP-IP - Training Suite 03 – IP and UDP Protocols
Ethernet / TCP-IP - Training Suite
03 IP and UDP Protocols
2
TCP-IP : Key Protocols
Internet Layer
Transport Layer
Datalink Layer
I want to send data to 127.127.127.127
IP
IP
STM32F4x7
PHY
Eth
ern
et
IP
Internet Protocol
IP characteristic
IP header
IP Router
IP Packets Fragments
3
4
IP Characteristic Best Effort Delivery(unreliable, connectionless)
Packets can be lost Packets can be duplicated Packets can be received in any order
The IP protocol can fragment and rebuild fragmented packets
A
A C
A
B
Internet Protocol
IP Characteristic
IP Header
IP Router
IP Packets Fragments
5
6
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
Data (variable length)
Bit 0 Bit 31
Header
Data
IP Packet Header and Data
7
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Version Version number of IP protocol (Version 4 or Version 6)
IP Packet Header
8
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Header Length (in 32 bit words) Indicates end of header and beginning of payload If no options, Header length = 5 (5 * 32bytes)
IP Packet Header
9
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Type of Service (TOS) Allows different types of service to be requested Initially, meaning was not well defined Currently being defined (different service)
IP Packet Header
10
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Packet Length (in Bytes) Unambiguously specify end of packet Max packet size = 216 = 65,535 Bytes
IP Packet Header
11
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
These three fields for Fragmentation Control (will come back to them later)
IP Packet Header
12
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Time to Live Initially set by sender (up to 255) Decremented by each router Discard when TTL = 0 to avoid infinite routing loops
IP Packet Header
13
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Protocol Value indicates what is in the field Example: TCP, UDP, ICMP
IP Packet Header
14
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Header Checksum Checks for error in the header only Bad header can harm the network If error found, packet is simply discarded
IP Packet Header
15
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Source and Destination IP Address
IP Packet Header
16
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Options Example: timestamp, record route, source route
IP Packet Header
Internet Protocol
IP Characteristic
IP Header
IP Router
IP Packets Fragments and Reassembly
17
IP Router
Router table (route)
Add: static, dynamic
RIP (Routing Information Protocol) UDP Port: 520
18
Internet Protocol
IP Characteristic
IP Header
IP Router
IP Packets Fragments and Reassembly
19
20
IP Fragmentation & Reassembly
Maximum Transmission Unit (MTU) Largest IP packet a network will accept Arriving IP packet may be larger (max IP packet size = 65,535 bytes)
Sender or router will split the packet into multiple fragments Destination will reassemble the packet IP header fields used to identify and order related fragments
IP Packet fragments and reassembly
21
Version(4) Hdr len(4) TOS(8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
IP Packet Header
Identification: All fragments of a single datagram have the same identification number
Flag: 1st bit: reserved, must be zero 2nd bit: DF -- Do not fragment 3rd bit: MF -- More fragments
Fragment Offset: Used for reassembly of packet 1st fragment has offset = 0
IP Packet Header
22
IP Fragments Example: IP fragments
23
TCP-IP : Key Protocols
Internet Layer
Transport Layer
Datalink Layer
I want to send a datagram on the port #
UDP
I want to send data to 127.127.127.127
IP
IP
UDP
STM32F4x7
PHY
Eth
ern
et
IP
UDP
UDP Characteristics
UDP does not provide :
Connections or logical circuits.
Flow control.
Retransmission of lost datagrams.
Acknowledgements of datagram reception.
It is a connectionless service.
24
25
User Datagram Protocol (UDP)
A very simple datagram service
Relies on the IP protocol
Advantages : simple, Lightweight
Drawbacks: A connectionless protocol (not reliable)
C
A
A
A
B
UDP Datagram Header and Data
Source port number (16bits) Destination port number (16bits)
UDP Length (16bits) UDP Checksum (16bits)
UDP Data
26
Source port
identifies the sending port Destination port
identifies the receiving port
Server port & Client port
Server port: must be assigned (snmp:80) Client port: assigned or random
UDP Datagram Header
Source port number (16bits) Destination port number (16bits)
UDP Length (16bits) UDP Checksum (16bits)
27
UDP Length Specifies the length in bytes of the UDP header and UDP data.
Checksum The checksum field is used for error-checking of the header and data. If
no checksum is generated by the transmitter, the field uses the value
all-zero. This field is not optional for IPv6.
The design of UDP server
The IP & port from client
The server can reply to any client request to it.
The destination IP
Sometimes the server need to know who the data want to sent to. (TFTP)
The UDP input queue
The server could endure the number of clients.
28
Ethernet / TCP-IP - Training Suite
03 - IP and UDP Protocols