You are on page 1of 13

ISO OSI and TCP Model

Layer Description This deals with the physical aspect of a network, i.e. electrical or light signals sent between local devices. Includes Encoding and Signalling, physical data transfer, hardware specifications, topology and design. Deals with low-level data messages between local devices. Includes logical link control, data framing, error detection and handling. Deals with messages between local or remote devices. Includes addressing, routing, datagram encapsulation and fragmentation and reassembly. Deals with the communication between software processes. Includes process-level addressing, multiplexing / de-multiplexing, segmentation and re-assembly, ACK and flow control. Deals with sessions between local and remote devices. Includes session establishment, management and termination. Deals with application data representation including data transmission, compression and encryption. Deals with application data associated with user application such as email programs.

Physical

Data Link

Network

Transport

Session

Presentation Application

Figure 1: TCP vs ISO OSI

Shannon-Hartley Law
The ShannonHartley theorem tells the maximum rate at which information can be transmitted over a communications channel of a specified bandwidth in the presence of noise. = () log 2 (1 + )

Automatic Repeat Requests


Stop and Wait Sender waits for an ACK for each send frame Frames may be damaged or lost, same for ACK No NACKs for lost or error frame Sender uses a timer and resends frame A 1-bit frame number (0 or 1) is needed for data and ACK frames. This value alternates when data is ACKed (new data sent), but remains the same when data is resent.

Go Back N Receiver has no buffer It can only accept (and send) a correct frame with the next expected sequence number. o Sends an ACK for that sequence number, which implies that all previous frames have arrived. Otherwise it discards the frame and: o Either sends nothing back, or o Sends an ACK for the last accepted frame o Sends a NACK for the next frame Receiver time to send ACK or NACK in separate frame.

Selective Repeat Receiver buffers frames o Can store out-of-order correct frames Only 1 frame has to be resent in case of error or loss NACKs are usually used for error or lost frames Sender needs timer of each send frame Receiver timer to send ACK or NACK in separate frame.

Trade-Offs between Go-Back-N and Selective Repeat Since Go-Back-N only has a buffer on the sender side, if a frame is lost or corrupted, the frames have to be resent starting from the last ACKed frame. Since Selective Repeat has a buffer on both the sending and receiving side, only the lost or corrupted frame needs to be resent.

Media Access Control (MAC)


CSMA/CD CSMA/CD is a media access control method. It is a modification of the pure CSMA where a transmission is terminated if a collision is detected (CD).

Figure 2: CSMA Flow Chart

1. 2. 3. 4.

The station that wants to transmit first listens to check if another transmission is in progress. If medium is in use, station waits, else it transmits Transmitter waits for ACK, if none, retransmits If Station transmits and no collisions occur during the time the leading edge of frame takes to propagate to the farthest station, then no collisions. 5. CD: If collision is detected, terminate transmission. Collisions can still occur when 2 or more stations begin transmitting within a short time of each other. CSMA/CD is not required with Gigabit Ethernet since the normal mode of operation for Gigabit Ethernet is full-duplex, which allows traffic in both directions at the same time. In this configuration, all lines are buffered, so each computer and switch is free to send frames whenever it wants to. On the computer and a switch, the computer is the only possible sender on the line to the switch. Since no contention is possible, the CSMA/CD protocol is not used.

Figure 3 Why collision detection takes 2

IPV4

Figure 4 IPV4 Header

Field IHL Type of Service

Time to Live (TTL)

Protocol Header Checksum

Description Defines how long the header is, in 32 bit words. Contains a 3-bit precedence field used for the priority and 3 flags: delay, throughput and reliability, to specify what is most important in the packet The TTL field is a counter to limit packet lifetimes. It must decrement at each hop and the packet is discarded when it reaches 0. This field tells the receiving host which transport process (TCP / UDP / etc) the packet should be given to. This is used to verify the header only, useful for detecting errors.

The fields used for fragmentation are the flag and fragmentation offset. Flag is a 3-bit field and is used to control or identify fragments. The fragment offset is the offset of a particular fragment to the beginning of the original IP datagram.

TCP/IP
TCP provides a reliable byte stream over an unreliable internetwork. TCP accepts user data streams from local processes, breaks them up into pieces not exceeding 64k and sends each piece as a separate IP datagram. The receiver side gives IP datagrams containing TCP data to its TCP entitiy, which reconstructs the original byte streams. IP gives no guarantees that datagrams will be delivered properly, so its up to TCP to time out, retransmit, and re-order them in the proper sequence.

Figure 5 TCP/IP Header

Description Identifies the sending port Identifies the receiving port If SYN = 1, this is the sequence number of the actual first data byte and the ACK number in the corresponding ACK is this number + 1. Sequence Number If SYN = 0, this is the accumulated sequence number of the first data byte of this segment. Acknowledgement If ACK = 1, value of this field is the next sequence number that the receiver Number is expecting. TCP Header Length Specifies the size of the Header in 32 bit words. Number of 1 bit flags used for dealing with acknowledgements, Flags (SYN, FIN, ACK, etc) terminations, etc The size of the receive window which specifies the number of window size Window Size units that the sender of the segment is currently willing to receive. Checksum Used for error checking of both header and Data If flag URG = 1, the value is an offset from the sequence number indicating Urgent Pointer the last urgent data byte. Used to add padding so that the TCP header ends (and the data begins) on Options a 32 bit boundary.

Field Source Port Destination Port

TCP Connection Protocol Full-Duplex

Figure 6 TCP half duplex 3-way handshake

1. The initiator (A) sends a SYN to the listener (B), and sets the sequence number to a random value . 2. In response, B replies with a SYN-ACK. The acknowledgement number is set to + 1, and the sequence number is another random value . 3. A sends an ACK back to B, the sequence number is set to the received acknowledgment number ( + 1) and the acknowledgement number is set to + 1.

Figure 7 Special Case TCP connection

This diagram shows what happens when two devices try to open a connection to each other at the same time. In this case instead of a three-way handshake, each sends a SYN and receives an ACK. They each follow the same sequence of states, which differs from both sequences in the normal three-way handshake.

TCP Connection Termination

Figure 8 TCP Connection Termination

TCP Congestion Control Slow Start: Slow start is part of the congestion control strategy used by TCP. It is used to avoid sending more data than the network is capable of transmitting, that is, to avoid network congestion. The congestion window is doubled on each packet successfully sent (an ACK received before timeout). This exponential increase continues until the threshold (initially 32k) is reached, after which the increase is linear. When a timeout occurs, the threshold is set for half the current congestion window, and the slow start is repeated. Congestion Avoidance: Upon receiving an ACK the congestion window (cwind) is increased by . This is an additive increase, as opposed the multiplicative increase of the basic slow start. Accurate retransmission timeout estimation: If the retransmission timer is too short, unnecessary retransmissions will occur. On the other hand, if too long, a long transmission delay will occur. A number of algorithms are available to replace the basic RTT timer value, including Jacobson and Karns algorithms.
1

Error Detection / Correction


On channels that are highly reliable, such as fiber, it is cheaper to use an error detecting code. On channels such as wireless links, that have many errors, it is better to add enough redundancy to each block for the receiver to be able to figure out what the original block was.

Hamming Code Example Bit stream: 10101111 20 1 P1 Bit Index Bit 3 Bit 5 Bit 6 Bit 7 Bit 9 Bit 10 Bit 11 Bit 12 21 2 P2 3 1 22 4 P4 5 0 6 1 7 0 23 8 P8 9 1 10 1 11 1 12 1

Made up of: P1 + P2 P1 + P4 P2 + P4 P1 + P2 + P4 P1 + P8 P2 + P8 P1 + P2 + P8 P4 + P8 Odd Parity

P1 = (Bit Value) P2 = (Bit Value) P3 = (Bit Value) P4 = (Bit Value)

3, 1 3, 1 5, 0 9, 1

5, 0 6, 1 6, 1 10, 1

7, 0 7, 0 7, 0 11, 1

9, 1 10, 1 12 1 12 1

11 1 11 1

0 1 1 1

Final Bit Stream: 01110101111 Cyclic Redundancy Check (CRC) The CRC bit is typically put in the trailer so that the calculations, for both the sender and receiver, can be both made without the need of memory. From the sender side, as the data is being transmitted, the CRC value can be calculated and after all the data is finished being transmitted (and the CRC being updated each step), the CRC value is then added to the trailer. On the receiving side, as the data is coming in, the CRC may be calculated (as the data is updated) and then checked with the CRC value in the trailer. If the CRC were to be in the header, the sender would have to calculate the CRC based on the data, send it in the header, and then send the data. The receiver would receive the CRC first, store it, receive the data, calculate the CRC and compare it to the saved data. Thus putting CRC in the trailer allows the process to be real-time (on the go).

User Datagram protocol (UDP)

Figure 9 UPD Header

No Connection establishment No reliability No ordering No Flow or congestion Control

UDP is basically IP with a shorter header added. The port numbers indicate the sending and receiving transport endpoints. When a UDP packet arrives its payload is sent to the process attached to the destination port. The checksum is optional and stored as 0 if not computed, a calculated 0 checksum is stored as all 1s. UDP does not do flow control, error control or retransmission upon receipt of bad datagrams.

Domain Name System (DNS)


The DNS maps host names to IP addresses and Vice versa. Application calls resolver with name Resolver contacts local DNS server (using UDP) passing the name Server returns with corresponding IP address

By using a distributed hierarchy of servers the system has better scalability and does not present a single point of failure. If DNS were to crash, one could only use IP addresses and not host names when accessing servers on the internet. Real Time Transport Protocol (RTP) is intended for real time multimedia applications, it multiplexes several real-time data streams into a single stream of UDP packets.

HTTP
HTTP is the transfer protocol used throughout the world wide web. It specifies what messages clients may send to servers and what responses to get in return. All clients and servers must obey this protocol. Each HTTP request consists of one of more lines of ASCII text, with the first word on the first line being the name of the method requested. There are a number of methods, such as: GET, HEAD, PUT, etc Client Side Clicking in a browser on http://www.cs.ru.nl/~ths/index.html. The steps that occur then are: 1. The browser determines the URL (by seeing what was selected) 2. The browser asks DNS for the IP address of www.cs.ru.nl 3. DNS answers with the IP number154 4. The browser makes a TCP connection to that number on port 80

5. 6. 7. 8. 9.

It then sends a GET /~ths/index.html command The www.cs.ru.nl server sends the file index.html The TCP connection is released The browser displays all the text in index.html The browser fetches all images indicated in index.html, by establishing a TCP connection for each of them, and displays them.

Server Side This performs the following steps in its main loop: 1. Accept a TCP connection from a client. 2. Resolve the name of the page requested. 3. Authenticate the client if needed. 4. Perform access control on the client, can the requested page be sent given the client's identity and location. 5. Perform access control on the web page, some pages may only been sent to clients on particular domains, e.g. inside the company. 6. Check the cache if the page is there, otherwise get it from disk. 7. Determine the MIME type and include it in the header of the reply. 8. Other possible tasks, like building a user profile, gathering statistics or making an entry in a logfile. 9. Return a reply, either the requested file or error information 10. Release the TCP connection

Types of Networks
Circuit switching For each connection, physical switches are set in the network to create a physical circuit. Switches are set up at the beginning of the connection and maintained throughout the connection. Network resources are reserved and dedicated. Example: Telephone Network Packet Switching In this switching method, instead of establishing a dedicated line between the sender and receiver, the message is sent to the nearest, directly connected switching node. This node stores the message, checks for errors, selects the best available route and forwards the message to the next intermediate node. To reduce the required storage size messages are divided into subsets of equal length called packets. Each packet is composed of the payload (data), and a header, which contains information useful for network layer functions such as the source and destination addresses. Example: The internet (TCP/UDP) Virtual Circuit Switching At connection establishment time, the path from source to destination is selected and used throughout the connection lifetime. Thus, packets passing though the route can have a short header, containing only a virtual circuit identifier (VCI) and not their destination.

Example: Frame Relay

Figure 10 Virtual Circuit Vs. Datagram Subnet

Repeaters, Hubs, Bridges, Switches, Routers and Gateways


A bridge connects two or more LANs A switch is more often used to connect individual computers A router gets the packet out of a frame and uses the information in the packet header, for example the IP addresses. A transport gateway receives e.g. a TCP packet and uses the header information to decide what to do with the packet. An application gateway understands the format and content of the data. It can translate messages from on format to another. Might also be used for security, for example, blocking messages.

Figure 11 Comparison to Layers

Ethernet

Figure 12 Ethernet Frame Format

Field Preamble Start of Frame (SOF) Addresses Length Data Pad Checksum

Description 7 bytes used to synchronize clocks Contains 10101011 Unique values in the world of 6 bytes each. Address containing all 1s is reserved for broadcast, a message destined to all receivers. Variable uses, most common is type field that indicates that the data is a higher level protocol packet. Data Used so that the frame has always the same length Used for error checking

Dynamic Routing
Distance Vector routing A routing table in each router contains, for each router, the preferred outgoing line for the router and the estimate cost to that destination. The cost metric might be number of hops, queue length, time delay, etc Once every T msec each router sends its neighbours a list of estimated costs to each destination. Link State Routing In Link State routing each router sends the costs to the immediate neighbours to all the routers in the network. Each router must: 1. 2. 3. 4. 5. Discover its neighbours, learn their network addresses Measure the delay or cost to each of its neighbours Construct a packet telling all it has just learned Send this packet to neighbouring routers Compute the shortest path to every other router

Summary: In Distance Vector, each node talks only to its directly connected neighbours, but it tells them everything it has learned the distance to all nodes. In Link State, each node talks to all other nodes, but it tells them only the state of its directly connected links.

Fragmentation

Figure 13 Transparent (a) and Non-transparent (b) fragmentation

Fragmentation happens when a message is larger than the maximum allowable network packet size. Transparent: Small packets are transparent to other networks Packet is reassembled at exit gateway Other networks are not aware fragmentation occurred Exit Gateway must know that all pieces were received (fragment counter or end of packet bit) May have to repeatedly fragment and reassemble to travel through a series of networks. Non-Transparent Reassembly only occurs at destination host Each Fragment becomes a separate packet and may be routed independently. Every packet (fragment) must carry header until it reaches destination host.

Internet Control Message Protocol (ICMP)


When something unexpected occurs in a router or host, this event is reported by ICMP. It is also used by routers to test the internet or to obtain information to be used in routing decisions (ECHO). Messages include: Time Exceeded, Echo, and Echo reply.

You might also like