TCPIP Essentials A LabBased Approach Chapter 2 A

TCP/IP Essentials A Lab-Based Approach Chapter 2 A Single Segment Network -- Data Link Layer Shivendra Panwar, Shiwen Mao Jeong-dong Ryoo, and Yihan Li

Data Link Layer n n In this lecture, we will focus on the Data Link Layer. Main tasks of the data link layer: ¨ Transfer data from the network layer of one machine to the network layer of another machine. ¨ Convert the raw bit stream of the physical layer into groups of bits (“frames”). ¨ Perform flow control between sender and receiver. Panwar, Mao, Ryoo, Li: TCP/IP Essentials Application Layer Transport Layer Network Layer Data Link Layer Physical Layer TCP/IP Suite 2

Types of Networks n Point-to-point network Two end hosts connected by a link Usually for long distance connections ¨ Examples: dialup, SONET/SDH ¨ ¨ n Point-to-Point Network Broadcast network A number of stations share a common transmission medium ¨ Local networks ¨ Examples: Ethernet, wireless local area networks ¨ Panwar, Mao, Ryoo, Li: TCP/IP Essentials Broadcast Network 3

Point-to-Point Networks The Point-to-Point Protocol (PPP) is a data link protocol. n The main purpose of PPP is encapsulation and transmission of IP datagrams, or other network layer protocol data, over a serial link. n Currently, most dial-up Internet access service are provided using PPP. n Panwar, Mao, Ryoo, Li: TCP/IP Essentials 4

Point-to-Point Protocol (PPP) n PPP consists of two types of protocols: ¨ Link n Control Protocol (LCP) Responsible for establishing, configuring and negotiating the data-link connection. ¨ Network n Control Protocol (NCP) IP Control Protocol (IPCP), used for transmitting IP datagrams over a PPP link, Panwar, Mao, Ryoo, Li: TCP/IP Essentials 5

PPP Encapsulation n PPP frame format ¨ Flag: mark the beginning and ending of a frame ¨ Protocol: used to multiplex different protocol data ¨ No addressing, only two end hosts. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 6

Local Area Networks n n Local area networks (LANs) typically connect computers within a building or a campus. Almost all LANs are broadcast networks. Typical topologies of LANs are bus or ring. The protocol that determines who can transmit on a broadcast channel is called Medium Access Control (MAC) protocol. Bus LAN Panwar, Mao, Ryoo, Li: TCP/IP Essentials Ring LAN 7

MAC and LLC n n In any broadcast network, the stations must ensure that only one station transmits at a time on the shared communication channel. The protocol that determines who can transmit on a broadcast channel is called Medium Access Control (MAC) protocol. The MAC protocol is implemented in the MAC sublayer which is the lower sublayer of the data link layer. The higher portion of the data link layer is often called Logical Link Control (LLC). Panwar, Mao, Ryoo, Li: TCP/IP Essentials 8

LLC n LLC can provide different services to the network layer: ¨ acknowledged connectionless service ¨ unacknowledged connectionless service ¨ connection-oriented service n n n Framing Error control Addressing Panwar, Mao, Ryoo, Li: TCP/IP Essentials 9

MAC n n MAC algorithms are used to resolve collisions and share the medium in a broadcast network. Examples of MAC: ¨ Aloha ¨ Carrier Sense Multiple Access/Collision Detection (CSMA/CD) ¨ Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA) n Ethernet ¨ An industry standard since ¨ Based on CSMA/CD. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 1982 10

Collisions in Ethernet n n n The collision resolution process of Ethernet requires that a collision is detected while a station is still transmitting. Assume the maximum propagation delay on the bus is a. Restrictions: Each frame should be at least twice as long as the time to detect a collision (2 a). Panwar, Mao, Ryoo, Li: TCP/IP Essentials 11

Collisions in Ethernet t 0 A Begins Transmission A B t 0+a- e B Begins Transmission A B t 0+a B Detects Collision A B t 0 +2 a A Panwar, Mao, Ryoo, Li: TCP/IP Essentials B A detects collision just before end of transmission 12

CSMA/CD n n n Each station listens before it transmits. If the channel is busy, it waits until the channel goes idle, and then transmits. If the channel is idle it transmits immediately. Continue sensing for 2 a seconds. ¨ a: n the maximum end-to-end propagation delay. If collision is detected, stop transmitting data and start to backoff. ¨ Backoff: wait a random amount of time before attempting to retransmit. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 13

Exponential Backoff Algorithm n n If a station is involved in a collision, it waits a random amount of time before attempting a retransmission. The random time is determined by the following algorithm: ¨ ¨ ¨ Set “slot time” to 2 a. After first collision wait 0 or 1 time unit. After the ith collision, wait a random number between 0 and 2 i-1 time slots. Do not increase random number range if i>9. Give up after 16 collisions. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 14

Ethernet Switches n In an Ethernet LAN, hosts can be ¨ Attached to a common cable, or ¨ Connected by Ethernet switches. n Ethernet switches are MAC layer devices that switch frames between different ports. ¨ Offer guaranteed bandwidth for LAN segments. ¨ Separate a LAN into collision domains. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 15

Ethernet Encapsulation Dest. Addr. 6 Src. Addr Type 6 2 Type 0800 2 Type 0806 2 Type 8035 2 Panwar, Mao, Ryoo, Li: TCP/IP Essentials Data CRC 46 -1500 4 IP datagram 46 -1500 ARP request/reply 28 RARP request/reply 28 PAD 18 16

IEEE 802. 11 Wireless LANs n Replacement for Ethernet: wireless channel ¨ Frequency band: unlicensed radio spectrum at 2. 4 GHz and 5. 7 GHz ¨ n Data rates: IEEE 802. 11 b: 1, 2, 5. 5, 11 Mbps ¨ IEEE 802. 11 a and g: 54 Mbps at 2. 4 GHz and 5. 7 GHz ¨ n Range: transmission power up to 100 m. W indoor: 20 - 25 meters ¨ outdoor: 50 - 100 meters ¨ Panwar, Mao, Ryoo, Li: TCP/IP Essentials 17

IEEE 802. 11 Protocols n n n IEEE 802. 11 b: 5, 11 Mbps IEEE 802. 11 a: 6, 9, 12, 18, 24, 36, 48, 54 Mbps IEEE 802. 11 g: 54 Mbps IEEE 802. 11 i: security IEEE 802. 11 f: Inter Access Point Protocol IEEE 802. 11 e: Quality of Service enhancement Panwar, Mao, Ryoo, Li: TCP/IP Essentials 18

IEEE 802. 11 Architecture n Two working modes: q the infrastructure mode – Fixed Access Point (AP) provides: n connection to wireline network n relay function – Handoff, an active host moves from one access point to another. Panwar, Mao, Ryoo, Li: TCP/IP Essentials q the ad hoc mode – No access point. – Hosts communicate with each other directly. 19

Extended Service Set ESS: a set of BSSs interconnected by a distribution System – ESS and all of its stations appear to be in a single MAC layer – AP communicate with each other to forward traffic – Station mobility within an ESS is invisible to the higher layers Panwar, Mao, Ryoo, Li: TCP/IP Essentials 20

IEEE 802. 11 MAC Layer n Priorities: ¨ Defined through different inter frame spaces ¨ SIFS (Short Inter Frame Spacing) n Highest priority, for ACK, CTS, Polling response ¨ PIFS (PCF IFS) n Medium priority, for time-bounded service using PCF ¨ DIFS(DCF, Distributed Coordination Function IFS) n Lowest priority, for asynchronous data service DIFS PIFS DIFS Medium Busy Direct access if the medium is free DIFS Panwar, Mao, Ryoo, Li: TCP/IP Essentials Contention Next Frame SIFS 21

IEEE 802. 11 MAC Layer n n n A super time frame consists of Contention-free Period and Contention period. These two periods are variable length. Their duration depends on the traffic load at the AP and at the mobile hosts. Different channel access control schemes are used for these two periods. A Super Frame Contention-free Period Contention Period time Panwar, Mao, Ryoo, Li: TCP/IP Essentials 22

IEEE 802. 11 MAC Layer n Point Coordination Function (PCF): ¨ For delay sensitive service ¨ Used in Contention free period ¨ Use polling for channel access control n Distributed Coordination Function (DCF): ¨ For best-effort data service ¨ Use CSMA/CA for channel access control ¨ RTS/CTS scheme is used to solve hidden-terminal problem Panwar, Mao, Ryoo, Li: TCP/IP Essentials 23

CSMA/CA n n Why not CSMA/CD? CSMA/CA: ¨ CSMA: carrier sensing n Carrier: do not send n No carrier: send n Needs to be enhanced in wireless networks ¨ CA: collision avoidance n random backoff n priority ack protocol Panwar, Mao, Ryoo, Li: TCP/IP Essentials 24

CSMA/CA : Backoff n n n Immediate access when medium is free DIFS When medium is not free, defer until the end of current frame transmission + DIFS To begin backoff procedure: Choose a random number in (0, Cwindow) ¨ Listen to determine if the channel is busy for each time slot ¨ Decrement backoff time by one slot if channel is idle ¨ n n Suspend backoff procedure if channel is busy in a time slot Resume backoff when the channel becomes idle again. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 25

CSMA/CA : Backoff DIFS CWindow DIFS Frame A DIFS Frame defer Frame B defer Frame C defer Channel idle Resume backoff D n Cwindow: Frame Generate a random, Channel busy Backoff counter reaches 0 and number suspend backoff channel is idle, transmit begin backoff counting ¨ Increases after each failure: 31, 63, 127, 255, 511, 1023, then give up ¨ Reset to 31 after each successful transmission Panwar, Mao, Ryoo, Li: TCP/IP Essentials 26

CSMA/CA : ACK Protocol SIFS Source DIFS data Dest. ACK Contention Window Others n n Next frame Receiver of directed frames returns an 14 Byte ACK immediately when CRC is correct. If no ACK received, the sender will retransmit after a random backoff Panwar, Mao, Ryoo, Li: TCP/IP Essentials 27

Exposed/Hidden Terminal Problems W W Y Z X Z Y The exposed terminal problem • Y will not transmit to X even though it can do so Panwar, Mao, Ryoo, Li: TCP/IP Essentials The hidden terminal problem • Y finds that medium is free and transmits a packet to W 28

RTS/CTS The sender send Request-to-Send (RTS): 20 bytes n Receiver returns Clear-to-Send (CTS): 14 bytes n Then transmission begins n Solves hidden terminal problem n Panwar, Mao, Ryoo, Li: TCP/IP Essentials 29

IEEE 802. 11 Frame Format 0 to 2312 More fields than other data-link protocols n High overhead: n ¨ 30 byte header, RTC/CTS, ACK ¨ Four Address fields: BSSID, Source Address, Destination Address, Receiving Station Address, Transmitting station Address n Different frame types for different tasks: ¨ all fields are not present in all types of frames Panwar, Mao, Ryoo, Li: TCP/IP Essentials 30

The Address Resolution Protocol n n IP addresses are not recognizable in the interface layer where physical addresses (or MAC addresses) are used. Different kinds of physical networks use different addressing schemes. Address Resolution Protocol (ARP): maps an IP address to a MAC address. Reverse Address Resolution Protocol (RARP): maps a MAC address to an IP address. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 31

ARP Process When a source host wants to send an IP packet to a destination, it first broadcasts an ARP request asking for the MAC address corresponding to the destination IP address. n The destination host will return an ARP reply with its MAC address. n Panwar, Mao, Ryoo, Li: TCP/IP Essentials 32

ARP Packet Format n n 28 bytes long. An ARP request or ARP reply is encapsulated in an Ethernet frame. Protocol Type: set to 0 x 0806 for ARP messages. Operation field: specifies ARP request (1), ARP reply (2), RARP request (3), or RARP reply (4). Panwar, Mao, Ryoo, Li: TCP/IP Essentials 33

ARP Request n Ethernet destination: ff: ff: ff (broadcast address) n Target Ethernet Address: not set. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 34

ARP Reply n n The ARP reply is sent by the node whose IP address matches the target IP address in the ARP request. ¨ It fills its MAC address into the target Ethernet address field of the ARP request. ¨ It then swaps the two sender addresses (Ethernet and IP addresses) with the two target addresses, sets the op field to 2. ¨ The ARP reply is sent back to the source host only. All other nodes receiving the broadcast ARP ignore the request, since their IP addresses do not match the target IP address. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 35

ARP Cache n n n Sending an ARP request/reply for each IP datagram is inefficient. Each host maintains an ARP cache containing the recent resolved IP addresses. A source host first checks it ARP cache for the destination MAC address, ¨ If an entry is found, sends out the IP packet within an Ethernet frame. ¨ Otherwise, sends out an ARP request. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 36

Manipulating the ARP Table n Elements of an entry in the ARP table: ¨ An IP address ¨ A MAC address ¨ Flags n n A normal entry expires after 20 minutes after it is created or the last time it is referred. Manipulate ARP table by the arp command: ¨ arp –a: Displays all entries in the ARP table. –b: Deletes an entry in the ARP table. –s: Inserts an entry into the ARP table. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 37

Proxy ARP n n Hide the two physical networks from each other. A router answers ARP requests targeted for a host. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 38

Gratuitous ARP n n Occurs when a host sends an ARP request resolving its own IP address. Usually happens when the interface is configured at bootstrap time. The interface uses gratuitous ARP to determine if there are other hosts using the same IP address. The sender’s IP and MAC address are broadcast, and other hosts will insert this mapping into their ARP tables. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 39

Loopback Interface n n n Most TCP implementations have a loopback interface with IP address 127. 0. 0. 1 and name localhost. The localhost behaves as a separate data link interface. A packet that is sent to the loopback interface moves down the protocol stack and is returned back by the driver software for the localhost “device”. Used for debugging. Packets sent to loopback interface will not appear on network. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 40

Network Interface Operations Functional Diagram of an Ethernet Interface Card Panwar, Mao, Ryoo, Li: TCP/IP Essentials 41

Maximum Transmission Unit There is a limit on the frame size of each data link layer protocol. n This limit is called maximum transmission unit (MTU). n MTUs for various data link layers: n ¨ Ethernet: 1500 ¨ FDDI: 4352 Panwar, Mao, Ryoo, Li: TCP/IP Essentials 42

ICMP n n The Internet Control Message Protocol (ICMP) is the protocol used for error and control messages in the Internet. ICMP provides an error reporting mechanism of routers to the sources. All ICMP packets are encapsulated as IP datagrams. The packet format is simple: Panwar, Mao, Ryoo, Li: TCP/IP Essentials 43

Types of ICMP Packets n Many ICMP packet types exist, each with its own format. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 44

ICMP Message Types n n ICMP messages are either query messages or error messages. ICMP query messages: n n n Echo request / Echo reply Router advertisement / Router solicitation Timestamp request / Timestamp reply Address mask request / Address mask reply ICMP error messages: n n Host unreachable Source quench Time exceeded Parameter problem Panwar, Mao, Ryoo, Li: TCP/IP Essentials 45

ICMP Error Messages n n Each ICMP error message contains the header and at least the first 8 bytes of the IP datagram payload that triggered the error message. To prevent that too many ICMP messages, ICMP error messages are not sent ¨ for multiple fragments of the same IP datagrams ¨ in response to an error message ¨ in response to a broadcast packet Panwar, Mao, Ryoo, Li: TCP/IP Essentials 46

ICMP Error Message Types n There are 16 different ICMP error messages (‘codes’) of type “Destination Unreachable” (Type = 3) Code 0 1 2 3 4 5 6 7 Message Type Network unreachable Host unreachable Protocol unreachable Port unreachable Fragmentation needed but bit not set Source route failed Destination network unknown Destination node unknown Panwar, Mao, Ryoo, Li: TCP/IP Essentials Code 8 9 10 11 12 13 14 15 Message Type Source host isolated Destination network administratively prohibited Destination host administratively prohibited Network unreachable for TOS Host unreachable for TOS Communication administratively prohibited by filtering host precedence violation precedence cutoff in effect 47

ICMP Port Unreachable n If, in the destination host, the IP module cannot deliver the datagram because the indicated protocol module or process port is not active, the destination host may send a port unreachable message to the source host. Request a service at a port No. 1234 Client Server No process is waiting at Port 1234 ble Port Panwar, Mao, Ryoo, Li: TCP/IP Essentials cha a e r n u 48

PING (Packet Inter. Net Gopher) is a program that utilizes the ICMP echo request and echo reply messages. n PING is used to verify if a certain host is up and running. It is used extensively for fault isolation in IP networks. n PING can be used with a wide variety of options. n Panwar, Mao, Ryoo, Li: TCP/IP Essentials 49

Echo Request and Reply n n n Ping’s are handled directly by the kernel. Each Ping is translated into an ICMP Echo Request. The Ping’ed host responds with an ICMP Echo Reply. ICMP ECH O REQUES T Host 2 Host 1 LY ICMP Panwar, Mao, Ryoo, Li: TCP/IP Essentials EP HO R EC 50

Echo Request/Reply Message Format n n Identifier is set to process ID of querying process. Sequence number is incremented for each new echo request. Panwar, Mao, Ryoo, Li: TCP/IP Essentials 51

Sock Traffic Generator n Sock is a test program. ¨ Can be run as a client or as a server ¨ Use UDP or TCP. n Sock operates in one of the following four modes: ¨ Interactive client ¨ Interactive server ¨ Source client ¨ Sink server Panwar, Mao, Ryoo, Li: TCP/IP Essentials 52
- Slides: 52