Skip to content
JNTUK · B.Tech study libraryFree access · No sign-up
JNTUK · R23 · CSE · Semester 3-1

Computer Networks exam preparation.

Practice questions for every unit in the style of the R23 end exam, a model answer for each, and a one-page revision summary. Built on the official syllabus units.

  • Practice questions in the exam's style
  • Drafted with AI and checked by a second AI pass. Doubtful points were verified against public sources. Report a mistake
Units
5
Questions
60
2-mark
30
10-mark
30
Checked on

Exam guide

Paper pattern

Semester-end theory paper, 70 marks, from the JNTUK B.Tech R23 Regulations, end-examination pattern for theory subjects.

  1. Question 1 · 20 marksTen compulsory short-answer questions of 2 marks each (two from every unit).
  2. Questions 2 to 6 · 50 marksFive either/or questions of 10 marks each, one per unit. You answer one of the two in each.
  • The semester-end examination carries 70 marks; internal assessment carries 30.
  • Mid-semester examinations are separate: a 20-minute objective paper (10 marks) and a 90-minute subjective paper with three either/or questions of 10 marks (condensed to 15 marks).
  • The regulations text does not state the length of the end examination. Use the duration printed on your hall ticket or question paper.

Read the R23 regulations (PDF) ↗

How to split your time

This plan assumes a 3-hour paper. If yours is different, keep the same proportions. Marks per minute stay roughly even across Question 1 and the 10-mark answers.

  1. 10 minRead the paper and choose one option in each either/or question
  2. 30 minQuestion 1: ten short answers (about 3 minutes each)
  3. 130 minQuestions 2 to 6: one 10-mark answer per unit (about 26 minutes each)
  4. 10 minFinal check of numbering, calculations and diagrams

Study tips for Computer Networks

  • Practise subnetting and CIDR problems by hand until you can find the network address, broadcast address, number of usable hosts and subnet mask from any given IP block without a calculator, and always verify by converting the final octets back to binary.
  • For error-control calculations such as CRC, Hamming code and checksum, write out every step of the binary division or parity check explicitly, then confirm your answer by checking that the received codeword gives a zero remainder or correct syndrome.
  • Draw protocol diagrams yourself, such as the OSI and TCP/IP layer stacks, the TCP three-way handshake, sliding window frames and the CSMA/CD flowchart, and label every arrow with the message or flag it carries so you can reproduce them quickly in the exam.
  • Trace routing algorithms such as Dijkstra's shortest path and distance vector updates on small sample graphs in a table, one iteration per row, and practise writing short pseudocode for bit stuffing, byte stuffing and the sliding window protocols so you can explain each line's purpose clearly.
Unit 1

Introduction and Physical Layer

Syllabus: Network types: LAN, MAN and WAN; Network topologies; The OSI reference model; The TCP/IP reference model; Comparison of the OSI and TCP/IP reference models; Guided media: twisted-pair, coaxial and fibre-optic cable; Introduction to unguided media

One-page revision summary

  • Networks are classified by area into LAN (building or campus), MAN (city) and WAN (country or world).
  • A LAN is privately owned, fast and low in errors; a WAN uses carrier-leased links and has more delay and cost.
  • Topology is the physical arrangement of nodes and links; the basic types are mesh, star, bus and ring.
  • Mesh gives the highest reliability at the highest cost, while star is cheap and easy to manage but depends on its hub.
  • A bus fails completely if the backbone breaks, and a ring can fail completely from one break unless it is a dual ring.
  • The OSI model has seven layers, each serving the layer above and using the layer below.
  • Encapsulation adds a header at each layer while sending, and the receiver removes the headers in reverse order.
  • The TCP/IP model has four layers: host-to-network, internet, transport and application.
  • IP is connectionless; TCP gives reliable connection-oriented delivery and UDP gives fast connectionless delivery.
  • OSI is a protocol-independent reference model, whereas TCP/IP is the protocol suite actually used on the Internet.
  • OSI separates the session and presentation layers, but TCP/IP folds them into the application layer.
  • OSI transport is connection-oriented only, while TCP/IP transport offers both connection-oriented and connectionless service.
  • Twisted pair (UTP or STP with RJ-45 connectors) cancels noise by twisting and is used in Ethernet LANs and telephone lines.
  • Coaxial cable has a central conductor, insulation, a braided shield and a jacket, and is used for cable TV.
  • Optical fibre guides light by total internal reflection and comes as step-index multimode, graded-index multimode or single-mode.
  • Fibre offers huge bandwidth, low attenuation and immunity to electromagnetic interference, but it is costly to install.
  • Unguided media send signals through free space by ground, sky or line-of-sight propagation.
  • Radio waves are omnidirectional, microwaves are directional line-of-sight, and infrared is short-range and blocked by walls.

Learn these by heart

  • Mesh topology with n devices: links = n(n-1)/2 and ports per device = n-1 (for example, 8 devices need 28 links).
  • OSI layers from bottom to top: Physical, Data Link, Network, Transport, Session, Presentation, Application.
  • Data units: bits at the physical layer, frame at the data link layer, packet at the network layer, segment at the transport layer.
  • OSI to TCP/IP mapping: Application + Presentation + Session → Application; Transport → Transport; Network → Internet; Data Link + Physical → Host-to-network.
  • Total internal reflection in fibre requires the core refractive index to exceed the cladding's and the angle of incidence to exceed the critical angle.
  • Approximate bands: radio waves 3 kHz–1 GHz, microwaves 1–300 GHz, infrared 300 GHz–400 THz.

2-mark questions

1 Differentiate between a LAN and a WAN. 2 marks
Model answer

A LAN connects devices within a small area such as a room, building or campus. It is usually privately owned and offers high data rates, low delay and few errors. A WAN spans a state, country or continent and usually runs over links leased from carriers. Compared with a LAN, it has more delay and higher cost.

2 A fully connected mesh network has 6 devices. How many duplex links and I/O ports per device are required? 2 marks
Model answer

Duplex links = n(n-1)/2 = 6 × 5 / 2 = 15 links.

Each device connects to every other device, so it needs n - 1 = 5 I/O ports. The total number of ports in the network is 6 × 5 = 30.

3 What is encapsulation in the OSI reference model? 2 marks
Model answer

As data moves down the sending stack, each layer adds its own header to the unit received from the layer above. The data link layer also adds a trailer. At the receiver, each layer removes and processes its own header in reverse order. This lets every layer talk logically with its peer layer.

4 Name the layers of the TCP/IP reference model and give one protocol for each. 2 marks
Model answer
  • Application layer: HTTP, FTP, SMTP or DNS.
  • Transport layer: TCP or UDP.
  • Internet layer: IP, supported by ICMP and ARP.
  • Host-to-network (link) layer: no protocol is fixed by TCP/IP; technologies such as Ethernet or Wi-Fi are used.
5 Why are the two conductors of a twisted-pair cable twisted? 2 marks
Model answer

Twisting keeps both wires equally exposed to external noise and crosstalk, so nearly the same unwanted voltage is induced in each. The receiver uses the difference between the two wires, so this common noise cancels out. More twists per unit length give better noise rejection.

6 What are unguided media? Give two examples. 2 marks
Model answer

Unguided (wireless) media carry electromagnetic signals through free space without a physical conductor. An antenna radiates the signal, and any receiver in range that is tuned to it can pick it up. Examples are radio waves (FM broadcasting), microwaves (cellular and satellite links) and infrared (TV remote controls).

10-mark questions

1 Explain the OSI reference model with a neat diagram. Describe the functions of each of its seven layers. 10 marks
Model answer

The Open Systems Interconnection (OSI) model was proposed by ISO as a layered framework. It lets any two systems communicate whatever their internal design. The communication task is split into seven layers. Each layer uses the services of the layer below and offers services to the layer above.

OSI reference model: seven layers on Host A and Host BDiagram in words: Draw two vertical stacks, Host A on the left and Host B on the right. Each stack has seven boxes, from top to bottom: Application, Presentation, Session, Transport, Network, Data Link, Physical. A downward arrow beside Host A is labelled 'headers added'. An upward arrow beside Host B is labelled 'headers removed'. Dashed horizontal arrows join each pair of same-named boxes, labelled 'peer protocol'. A solid line labelled 'transmission medium' joins the two Physical boxes.Host AHost BApplicationPresentationSessionTransportNetworkData LinkPhysicalApplicationPresentationSessionTransportNetworkData LinkPhysicalheaders addedheadersremovedpeer protocolpeer protocolpeer protocolpeer protocolpeer protocolpeer protocoltransmissionmedium
OSI reference model: seven layers on Host A and Host B

Functions of the layers, from bottom to top:

1. Physical layer: sends the raw bit stream over the medium. It defines the mechanical and electrical properties of interfaces, how bits are encoded as signals, the data rate and bit synchronisation. It also defines the transmission mode: simplex, half-duplex or full-duplex.

2. Data link layer: groups bits into frames and gives node-to-node delivery. It adds physical (MAC) addresses and performs flow control. It detects errors using a trailer and controls access when many devices share one link.

3. Network layer: moves packets from the source host to the destination host across several networks. Its main jobs are logical addressing (for example IP addresses) and routing.

4. Transport layer: provides process-to-process delivery of the complete message. It uses port addresses and divides messages into numbered segments, then reassembles them at the receiver. It also handles connection control and end-to-end flow and error control.

5. Session layer: acts as the dialog controller. It sets up, maintains and closes sessions and decides whose turn it is to send. It adds checkpoints so that a long transfer can restart from the last checkpoint after a crash.

6. Presentation layer: handles the syntax of the data. It translates between different data representations, encrypts and decrypts data, and compresses data to save bandwidth.

7. Application layer: gives users and programs access to the network. Typical services are file transfer, e-mail, remote login, directory services and the web.

The data unit is called a frame at layer 2, a packet at layer 3 and a segment at layer 4.

In conclusion, the OSI model separates networking concerns into seven clear layers. This makes networks easier to design, teach and troubleshoot.

2 Explain the TCP/IP reference model and compare it with the OSI reference model. 10 marks
Model answer

The TCP/IP reference model was developed for ARPANET, a research network funded by the US Department of Defense, and became the basis of the Internet. Its protocols were designed first, and the model was later written to describe them. It is normally presented with four layers.

1. Host-to-network (link) layer: TCP/IP fixes no protocol here. A host only has to attach to the network with some technology, such as Ethernet or Wi-Fi, that can carry IP packets.

2. Internet layer: lets hosts inject packets into any network. Each packet travels independently to the destination and may arrive out of order. IP is the main protocol; it is connectionless and handles logical addressing and routing. ICMP, ARP and IGMP support it.

3. Transport layer: provides end-to-end communication between processes. TCP is reliable and connection-oriented and delivers a byte stream with flow and error control. UDP is connectionless and unreliable, which suits quick request-reply exchanges and real-time traffic.

4. Application layer: contains all higher-level protocols, such as HTTP, SMTP, FTP, DNS and TELNET. The applications themselves perform any session or presentation work.

OSI reference model vs TCP/IP reference modelDiagram in words: Draw two columns side by side. The left column, labelled OSI, has seven boxes from top to bottom: Application, Presentation, Session, Transport, Network, Data Link, Physical. The right column, labelled TCP/IP, has four boxes from top to bottom: Application, Transport, Internet, Host-to-network. Arrows run from left to right: OSI Application, Presentation and Session point to TCP/IP Application. OSI Transport points to TCP/IP Transport. OSI Network points to Internet. OSI Data Link and Physical point to Host-to-network.OSITCP/IPApplicationPresentationSessionTransportNetworkData LinkPhysicalApplicationTransportInternetHost-to-network
OSI reference model vs TCP/IP reference model

Comparison:

  • Layers: OSI has seven layers; TCP/IP has four.
  • Origin: the OSI model was designed before its protocols; the TCP/IP protocols existed before its model.
  • Concepts: OSI clearly separates service, interface and protocol; TCP/IP does not.
  • Network layer: OSI supports both connectionless and connection-oriented service; the TCP/IP Internet layer is connectionless only.
  • Transport layer: OSI provides connection-oriented service only; TCP/IP provides both kinds (TCP and UDP).
  • Upper layers: OSI has separate session and presentation layers; TCP/IP merges them into the application layer.
  • Generality: OSI is protocol-independent and can describe many stacks; the TCP/IP model is tied to its own protocols.
  • Use: OSI is mainly a reference and teaching model; TCP/IP is the working protocol suite of the Internet.

In conclusion, OSI gives the cleaner concepts while TCP/IP supplies the protocols actually in use. For study, a five-layer hybrid model is therefore often used: physical, data link, network, transport and application.

3 Explain mesh, star, bus and ring topologies with diagrams, advantages and disadvantages. For a network of 8 devices, find the number of cable links needed in each topology. 10 marks
Model answer

Topology is the geometric arrangement of devices (nodes) and the links between them. There are four basic topologies: mesh, star, bus and ring. A hybrid topology combines them, for example several stars joined to a bus backbone.

Mesh, star, bus and ring topologiesDiagram in words: Draw four small figures. (a) Mesh: five nodes A, B, C, D and E at the corners of a pentagon, with a line joining every pair of nodes (10 lines in all). (b) Star: a central box labelled Hub/Switch with separate lines to nodes A, B, C and D. (c) Bus: a horizontal line labelled Backbone with a terminator at each end. Short vertical drop lines connect nodes A, B, C and D to the backbone through taps. (d) Ring: nodes A, B, C and D in a circle, each joined to the next. Arrows show the signal moving one way: A to B, B to C, C to D and D back to A.(a) Mesh(b) Star(c) Bus(d) RingABCDEHub/SwitchABCBackboneABCABCdrop linedrop linedrop line
Mesh, star, bus and ring topologies

1. Mesh: every device has a dedicated point-to-point link to every other device. With n devices it needs n(n-1)/2 duplex links and n-1 ports per device.

  • Advantages: no sharing of links, high robustness, privacy and easy fault isolation.
  • Disadvantages: heavy cabling, many ports, high cost and difficult installation.

2. Star: each device has one dedicated link to a central hub or switch.

  • Advantages: cheaper than mesh, easy to install and reconfigure; a failed link affects only one device.
  • Disadvantages: the hub is a single point of failure, and more cable is used than in a bus.

3. Bus: a single backbone cable, with all devices attached through drop lines and taps.

  • Advantages: simple installation and the least cable.
  • Disadvantages: a backbone fault stops all traffic. Signal reflection and attenuation limit the number of taps, and adding devices is hard.

4. Ring: each device links only to its two neighbours. The signal travels one way, and every device acts as a repeater.

  • Advantages: easy to install, and faults are easy to isolate.
  • Disadvantages: traffic flows in one direction, and one break can disable the whole ring unless a dual ring is used.

Calculation for n = 8 devices:

  • Mesh: links = 8 × 7 / 2 = 56 / 2 = 28 duplex links. Each device needs 8 - 1 = 7 ports, so the total is 8 × 7 = 56 ports.
  • Star: 8 links, one from each device to the hub.
  • Ring: 8 links, each device to its next neighbour and the last back to the first.
  • Bus: 1 backbone cable plus 8 drop lines.

In conclusion, choosing a topology means balancing cost, reliability and ease of expansion. Star topology built around switches is the usual choice in modern LANs.

4 Classify computer networks by geographical area. Explain LAN, MAN and WAN with their characteristics and examples, and compare them. 10 marks
Model answer

Computer networks are commonly classified by the area they cover and by who owns them. The three main classes are the Local Area Network (LAN), the Metropolitan Area Network (MAN) and the Wide Area Network (WAN).

1. LAN: connects computers, printers and servers within a room, building or campus, usually up to a few kilometres.

  • One organisation owns and manages it.
  • Typical technologies are switched Ethernet (100 Mbps to 10 Gbps) and Wi-Fi.
  • Data rates are high, propagation delay is small and error rates are very low.
  • Star topology with a switch is common today.
  • Example: computers in a college laboratory sharing a printer and an internet connection.

2. MAN: covers a town or city, typically tens of kilometres.

  • It may belong to a service provider, or to an organisation linking its offices across a city.
  • It usually interconnects several LANs.
  • Examples: a cable TV network that also provides broadband internet, and city-wide wireless broadband. IEEE 802.6 (DQDB) and IEEE 802.16 (WiMAX) are standards in this class.

3. WAN: spans a state, country or continent.

  • It is usually built from links leased from telecom carriers, such as optical fibre, undersea cable, microwave and satellite links.
  • Routers interconnect the LANs and MANs it joins.
  • A point-to-point WAN joins two devices over a dedicated line. A switched WAN is a mesh of many interconnected switches or routers.
  • Delay, cost and error rates are higher than in a LAN.
  • Example: a bank network linking branches across India. The Internet is the largest internetwork of LANs and WANs.
LAN, MAN and WAN: three LANs joined by a city link and a WAN linkDiagram in words: Draw three LANs, LAN-A, LAN-B and LAN-C. Each LAN has four PCs connected by lines to a central Switch, and each switch connects to its own router: RA, RB and RC. RA and RB are in Vijayawada and are joined by a line labelled 'city fibre link'. A dashed oval enclosing LAN-A and LAN-B is labelled 'MAN (Vijayawada)'. RB connects to RC, in Hyderabad, through a cloud labelled 'Carrier network'. The line is labelled 'WAN link (leased line)'.LAN-ALAN-BLAN-CMAN (Vijayawada)four PCsSwitchRAfour PCsSwitchRBCarrier networkfour PCsSwitchRC (Hyderabad)cityfibre linkWAN link(leased line)WAN link(leased line)
LAN, MAN and WAN: three LANs joined by a city link and a WAN link

Comparison:

  • Area: LAN covers a building or campus; MAN a city; WAN a country or the world.
  • Ownership: LAN is private; MAN is private or provider-owned; WAN mostly uses carrier links.
  • Speed: highest in a LAN and lowest in a WAN for the same cost.
  • Delay and errors: lowest in a LAN and highest in a WAN.
  • Cost and maintenance: a LAN is cheap and simple; a WAN is expensive and complex.
  • Media: a LAN uses twisted pair and Wi-Fi; a MAN uses fibre and coaxial cable; a WAN uses fibre, microwave and satellite.

In conclusion, the three classes differ mainly in coverage, ownership and performance. Real networks usually combine all three: LANs joined by MANs and WANs form the Internet.

5 Explain guided transmission media: twisted-pair, coaxial and fibre-optic cable, with their construction, types and applications. 10 marks
Model answer

Guided (wired) media confine the signal to a physical path. There are three main types. Twisted-pair and coaxial cable carry electrical signals over copper, while optical fibre carries light.

1. Twisted-pair cable

  • Construction: two insulated copper wires twisted around each other, with several pairs bundled in one jacket. Twisting makes both wires pick up nearly equal noise. The receiver works on the difference between the wires, so this noise cancels.
  • Types: Unshielded Twisted Pair (UTP) is cheap and widely used. Shielded Twisted Pair (STP) adds a metal foil or braid around the pairs, which gives better noise immunity but is bulkier and costlier.
  • UTP is graded into categories; Cat 5e and Cat 6 support Gigabit Ethernet. The connector is RJ-45.
  • Applications: telephone local loops, DSL and Ethernet LANs.

2. Coaxial cable

  • Construction: a central copper conductor, then an insulating layer, then an outer conductor of metal foil or braid that also acts as a shield, and finally a plastic jacket.
  • It carries higher frequencies than twisted pair. However, attenuation is significant, so repeaters are needed at intervals.
  • Common grades are RG-59 (cable TV), RG-58 (thin Ethernet) and RG-11 (thick Ethernet). BNC connectors, T-connectors and terminators are used.
  • Applications: cable TV distribution and older Ethernet LANs.

3. Fibre-optic cable

  • Construction: a thin glass or plastic core, surrounded by cladding of lower refractive index, then a buffer coating and an outer jacket.
  • Principle: light meets the core-cladding boundary at an angle greater than the critical angle. It is therefore totally internally reflected and stays inside the core.
  • Propagation modes:
  • Multimode step-index: the core density is uniform, so many rays follow paths of different lengths and the signal is distorted.
  • Multimode graded-index: the density is highest at the centre and falls towards the edge, so rays bend smoothly and distortion is lower.
  • Single-mode: the core is very narrow and light travels almost straight, giving the least distortion over long distances.
  • Connectors: SC, ST and LC.
  • Advantages: very high bandwidth, low attenuation (fewer repeaters), immunity to electromagnetic interference, light weight and difficulty of tapping.
  • Disadvantages: installation and splicing need expertise, and the cable and interfaces cost more. A light signal on one wavelength travels in one direction only, so a full-duplex link typically uses a pair of fibres. A single fibre can still carry both directions if each direction uses a different wavelength (wavelength-division multiplexing), as passive optical networks do for upstream and downstream traffic.

Diagram in words: Draw a lengthwise section of a fibre. A central horizontal strip labelled Core has strips above and below labelled Cladding, with outer layers labelled Buffer and Jacket. A zig-zag arrow labelled 'Light ray' enters the core from the left. It reflects alternately off the upper and lower core-cladding boundaries and moves to the right. Each bounce point is labelled 'total internal reflection (angle > critical angle)'.

In conclusion, twisted pair suits cheap short links, coaxial cable suits cable TV, and optical fibre is preferred for high-speed backbones and long-distance links.

6 What are unguided media? Explain the propagation methods and the use of radio waves, microwaves and infrared. Compare guided and unguided media. 10 marks
Model answer

Unguided media, also called wireless media, carry electromagnetic waves through free space without any physical conductor. A transmitting antenna radiates the signal, and any receiver in range that is tuned to that frequency can pick it up. For communication, the useful spectrum is divided into radio waves, microwaves and infrared.

Propagation methods: 1. Ground propagation: low-frequency signals (below about 2 MHz) travel close to the earth and follow its curvature. The distance covered depends on the transmitted power. 2. Sky propagation: higher-frequency radio waves (about 2 to 30 MHz) travel up to the ionosphere and are reflected back to earth. This gives long range at low power, as in shortwave radio. 3. Line-of-sight propagation: very high frequencies travel in straight lines from antenna to antenna. The antennas must face each other and be tall enough to clear the earth's curvature.

Propagation methods: ground, sky and line-of-sightDiagram in words: Draw the earth as a curved arc, with transmitting tower T on the left and receiving tower R on the right. Above the earth, draw a band labelled Ionosphere. Arrow 1, labelled 'Ground propagation', follows the earth's curve from T to R. Arrow 2, labelled 'Sky propagation', rises from T to the ionosphere and reflects down to R. Arrow 3, labelled 'Line-of-sight', is a straight line between the tops of T and R.IonosphereTransmittingtower TReceivingtower REarth(curved arc)2. Skypropagationreflects down3. Line-of-sight1. Groundpropagationfollowsearth's curve
Propagation methods: ground, sky and line-of-sight

Types of unguided media: 1. Radio waves (about 3 kHz to 1 GHz):

  • They are mostly omnidirectional, so the antennas need not be aligned.
  • Lower frequencies travel far and pass through walls.
  • Drawbacks: users of the same band interfere with each other, and the bandwidth available for data is limited.
  • Uses: AM and FM radio, maritime radio, cordless phones and paging.

2. Microwaves (about 1 GHz to 300 GHz):

  • They are unidirectional and need line-of-sight, so long links use relay towers. Higher frequencies cannot pass through walls.
  • The wide bands allow high data rates. Parabolic dish and horn antennas are used.
  • Uses: cellular telephony, satellite links, point-to-point terrestrial links and wireless LANs.

3. Infrared (about 300 GHz to 400 THz):

  • It works only over short line-of-sight distances and cannot pass through walls. This stops interference between rooms.
  • Sunlight contains infrared, which makes outdoor use difficult.
  • Uses: TV remote controls and short-range links between devices.

Guided versus unguided media:

  • Path: guided media use a cable; unguided media use free space.
  • Signal: a guided signal is confined to the cable; an unguided signal is broadcast or beamed.
  • Security: guided media are harder to tap; an unguided signal can be received by anyone in range.
  • Mobility and installation: unguided media suit mobile users and difficult terrain without laying cable.
  • Noise: unguided media are more affected by interference and weather.

In conclusion, unguided media provide mobility and easy deployment. Their range and behaviour depend strongly on the frequency band chosen.

Unit 2

Data Link Layer

Syllabus: Data link layer design issues; Fixed-size and variable-size framing; Flow control and error control; Error detection and correction codes; CRC; Checksum and the one's-complement internet checksum; Services provided to the network layer; Simplex protocol, simplex stop-and-wait and simplex protocol for a noisy channel; Sliding window protocols: one-bit, Go-Back-N and Selective Repeat; HDLC; Point-to-Point Protocol (PPP)

One-page revision summary

  • The data link layer's design issues are the service interface to the network layer, framing, error control and flow control.
  • The three services offered to the network layer are unacknowledged connectionless, acknowledged connectionless and acknowledged connection-oriented.
  • Fixed-size framing needs no delimiters, while variable-size framing uses a byte count, flag bytes with byte stuffing, flag bits with bit stuffing, or physical layer coding violations.
  • Flow control stops a fast sender from flooding a slow receiver, and error control uses detection codes, acks, timers and sequence numbers to give reliable delivery.
  • Error-detecting codes such as parity, checksum and CRC trigger retransmission, while error-correcting codes such as Hamming codes let the receiver fix errors without retransmission.
  • Simple parity adds one bit so the count of 1s is even (or odd) and detects any odd number of flipped bits but misses even numbers, while two-dimensional parity adds a parity bit to every row and column, detects all 1-, 2- and 3-bit errors and can locate and correct a single-bit error.
  • A Hamming code for m data bits uses r check bits with 2^r ≥ m + r + 1, places the check bits at positions 1, 2, 4, 8 and so on, and sets each check bit to give even parity over every position whose binary number contains that power of two.
  • The receiver recomputes each parity check and writes the results as a binary syndrome, and a non-zero syndrome equals the position of the single wrong bit, which is then flipped, so Hamming(7,4) with dmin = 3 corrects any single-bit error.
  • CRC treats bits as polynomial coefficients, appends r zeros, divides modulo 2 by the generator and sends the remainder as check bits; a zero remainder at the receiver means no error was detected.
  • The Internet checksum is the one's complement of the one's-complement sum of 16-bit words, and the receiver's sum including the checksum must be FFFF.
  • The utopia protocol assumes a perfect channel, stop-and-wait adds receiver-driven flow control, and PAR (stop-and-wait ARQ) adds timers and 1-bit sequence numbers for a noisy channel.
  • Go-Back-N resends the lost frame and every frame after it, while Selective Repeat buffers out-of-order frames and resends only the bad one.
  • HDLC is a bit-oriented protocol whose frame is Flag (01111110) | Address | Control | Information | FCS | Flag, where the address names the secondary station, the control field identifies the frame type, the FCS is a CRC, and bit stuffing keeps the flag pattern out of the data.
  • HDLC has three station types, a primary that issues commands, a secondary that only sends responses and a combined station that does both, arranged in an unbalanced configuration (one primary with one or more secondaries) or a balanced configuration (two combined stations).
  • HDLC defines three transfer modes: Normal Response Mode (a secondary sends only when polled by the primary), Asynchronous Response Mode (a secondary may send without being polled, though the primary still manages the link) and Asynchronous Balanced Mode (two combined stations, either may start sending), with NRM and ABM being the two in common use.
  • HDLC has three frame types: I-frames carry data with piggybacked acks, S-frames carry supervisory control (RR, RNR, REJ, SREJ), and U-frames carry link management commands.
  • PPP is a byte-oriented point-to-point protocol whose frame is Flag 0x7E | Address 0xFF | Control 0x03 | Protocol (2 bytes, for example 0x0021 for IPv4 and 0xC021 for LCP) | Payload (up to 1500 bytes by default) | FCS (2 or 4 bytes) | Flag 0x7E.
  • PPP uses byte stuffing with escape byte 0x7D, LCP to set up, test and close the link, and NCP (for example IPCP) to configure each network layer protocol.
  • A PPP link moves through the phases Dead, Establish (LCP negotiates options), Authenticate (optional), Network (NCP such as IPCP configures the network layer), Open (data transfer) and Terminate (LCP closes the link), after which it returns to Dead.
  • PAP is a two-way handshake that sends the user name and password in clear text, while CHAP is a three-way handshake in which the authenticator sends a random challenge and the peer returns a hash of the challenge and a shared secret, so the password never crosses the link.

Learn these by heart

  • Hamming distance: detect s errors if dmin ≥ s + 1; correct t errors if dmin ≥ 2t + 1.
  • Hamming code: choose r with 2^r ≥ m + r + 1; check bits sit at positions 1, 2, 4, 8, …; a non-zero syndrome gives the position of the bad bit.
  • Simple parity detects only odd numbers of bit errors; 2D parity detects all 1-, 2- and 3-bit errors and corrects a single-bit error.
  • CRC: append r = degree(G) zeros, divide modulo 2 (XOR), the remainder is the CRC, and the receiver's remainder must be 0.
  • Internet checksum = complement of the 16-bit one's-complement sum with end-around carry; the receiver's sum including the checksum is FFFF.
  • Go-Back-N: Ws ≤ 2^m − 1 and Wr = 1. Selective Repeat: Ws = Wr ≤ 2^(m−1).
  • Stop-and-wait utilisation U = 1/(1 + 2a), where a = propagation time / transmission time.
  • HDLC flag 01111110: stuff a 0 after five consecutive 1s. PPP flag 0x7E with escape 0x7D: the stuffed byte is XORed with 0x20.
  • HDLC stations: primary, secondary, combined. Modes: NRM, ARM and ABM (NRM and ABM in common use). Frames: I, S, U.
  • PPP phases: Dead → Establish → Authenticate → Network → Open → Terminate → Dead. PAP is a two-way clear-text exchange; CHAP is a three-way challenge-response.

2-mark questions

1 Distinguish fixed-size framing from variable-size framing. 2 marks
Model answer

In fixed-size framing every frame has the same length, so the length itself marks the boundaries and no delimiter is needed. ATM's 53-byte cells are an example. In variable-size framing, frames differ in length, so the end of each frame must be marked. This is done with a length field, with flag bytes and byte stuffing, or with flag bits and bit stuffing.

2 Find the Hamming distance between the codewords 10110 and 11011. State the minimum distance needed to detect s errors and to correct t errors. 2 marks
Model answer

10110 ⊕ 11011 = 01101. The result contains three 1s, so the Hamming distance is 3. A code can detect up to s errors if its minimum distance dmin ≥ s + 1. It can correct up to t errors if dmin ≥ 2t + 1. In a Hamming code the check bits sit at positions 1, 2, 4, 8 and so on, and a non-zero syndrome gives the position of the single wrong bit.

3 List the services that the data link layer can provide to the network layer. 2 marks
Model answer
  • Unacknowledged connectionless service: frames are sent without acknowledgements. It suits low-error links such as Ethernet.
  • Acknowledged connectionless service: each frame is acknowledged individually. It suits unreliable links such as wireless.
  • Acknowledged connection-oriented service: a connection is set up first, and frames are numbered and delivered exactly once, in order.
4 What is bit stuffing in HDLC? Give an example. 2 marks
Model answer

An HDLC frame starts and ends with the flag 01111110. To keep this pattern from appearing inside the data, the sender inserts a 0 after every five consecutive 1s. The receiver removes any 0 that follows five 1s. Example: the data 0111111 is sent as 01111101. The HDLC frame is Flag, Address, Control, Information, FCS, Flag, and the control field shows whether it is an I, S or U frame.

5 What is piggybacking in data link protocols? 2 marks
Model answer

Piggybacking is used in full-duplex data link protocols. Instead of sending a separate acknowledgement frame, the receiver delays the acknowledgement briefly and attaches it to the ack field of its next outgoing data frame. This saves bandwidth and frame overhead. If no data frame is ready before an ack timer expires, a separate acknowledgement is sent.

6 What are LCP and NCP in PPP? 2 marks
Model answer

LCP (Link Control Protocol) establishes, configures, tests and terminates the PPP link. It negotiates options such as maximum frame size and authentication. NCP (Network Control Protocol) is a family of protocols, one per network layer protocol, for example IPCP for IP. NCP configures that network layer, such as assigning an IP address, after the link is up. The PPP frame is Flag 0x7E, Address 0xFF, Control 0x03, Protocol, Payload, FCS, Flag. A link passes through the phases Dead, Establish, Authenticate, Network, Open and Terminate.

10-mark questions

1 Explain the design issues of the data link layer. Describe the services it offers to the network layer and explain how flow control and error control are achieved. 10 marks
Model answer

The data link layer turns the raw, error-prone bit pipe of the physical layer into a reliable link between two directly connected machines. It takes packets from the network layer, wraps them in frames and hands them to the physical layer.

Design issues:

1. Service interface to the network layer: decide what kind of service the network layer gets.

2. Framing: break the bit stream into frames so the receiver can find where each frame begins and ends.

3. Error control: make sure frames reach the receiver correctly, in order and without duplicates.

4. Flow control: stop a fast sender from overrunning a slow receiver.

Services to the network layer:

  • Unacknowledged connectionless: there are no acks and no connection, and lost frames are not recovered. It is used on reliable links and for real-time traffic.
  • Acknowledged connectionless: each frame is acknowledged and is resent if the ack does not arrive in time. It is useful on wireless links.
  • Acknowledged connection-oriented: the service has three phases: connection setup, numbered data transfer and release. Every frame is received exactly once and in order.
Virtual vs actual data path between data link layersDiagram in words: Two stacks, Host 1 and Host 2, each have three boxes from top to bottom: Network layer, Data link layer, Physical layer. A dashed horizontal arrow labelled "virtual data path" joins the Data link layer of Host 1 to the Data link layer of Host 2. A solid arrow labelled "actual data path" goes down from Host 1's Network layer through its Data link and Physical layers, then across a line labelled "transmission medium" to Host 2's Physical layer, and up to Host 2's Network layer.Host 1Host 2Network layerData link layerPhysical layerNetwork layerData link layerPhysical layervirtualdata pathactualdata pathtransmissionmedium
Virtual vs actual data path between data link layers

Error control:

1. The sender adds redundancy (parity, CRC or checksum) so the receiver can detect damaged frames.

2. The receiver returns a positive acknowledgement for good frames. It may return a negative acknowledgement for bad ones.

3. The sender starts a timer for each frame. If no ack arrives before the timer expires, the frame is retransmitted. This handles frames that are lost completely.

4. Sequence numbers let the receiver recognise and discard duplicate frames caused by retransmission.

Flow control:

1. Feedback-based flow control: the receiver explicitly tells the sender when it may send more. Stop-and-wait (one frame per ack) and sliding window protocols (up to W unacknowledged frames) both work this way.

2. Rate-based flow control: the sender limits its own rate with no feedback. It is rarely used at this layer.

In conclusion, the data link layer addresses framing, error control and flow control so that it can offer the network layer one of three service types, from simple best-effort delivery to fully reliable, in-order delivery.

2 What is framing? Explain the character count, byte stuffing and bit stuffing methods of framing with suitable examples. 10 marks
Model answer

Framing is the process of breaking the bit stream from the physical layer into separate units called frames, each carrying its own header and error check. Fixed-size frames, such as 53-byte ATM cells, need no boundary marking. Variable-size frames need one of the methods below.

1. Character (byte) count:

The header carries a field giving the number of bytes in the frame. The receiver reads the count and knows where the frame ends. Example: the count 5 followed by four data bytes A B C D makes a 5-byte frame. The weakness is that if the count is corrupted, the receiver loses synchronisation for every later frame. For this reason the method is rarely used alone.

2. Flag bytes with byte stuffing:

Each frame starts and ends with a special FLAG byte. If a FLAG byte occurs in the data, the sender puts an ESC byte before it. An ESC byte in the data is also preceded by ESC. The receiver deletes each ESC and keeps the byte that follows it.

Example: the data A FLAG B ESC C is sent as FLAG A ESC FLAG B ESC ESC C FLAG.

PPP uses this idea with flag 0x7E and escape 0x7D. The drawback is that the method is tied to 8-bit characters.

3. Flag bits with bit stuffing:

Each frame starts and ends with the bit pattern 01111110. Whenever the sender sees five consecutive 1s in the data, it inserts a 0. The receiver deletes the 0 that follows five 1s. The flag therefore never appears inside the data, and frames can be any number of bits long.

Example: the data 011111101111110 (15 bits) is stuffed as follows:

  • 0, then five 1s: insert 0, giving 0111110
  • next bits 1, 0: no stuffing, giving 10
  • five 1s: insert 0, giving 111110
  • next bits 1, 0: no stuffing, giving 10

The stuffed output is 01111101011111010 (17 bits). It is sent between two flags as 01111110 01111101011111010 01111110.

4. Physical layer coding violations:

Some line codes have spare signal patterns that never occur in data, such as invalid 4B/5B codes. These patterns can mark frame boundaries.

Bit-stuffed frame layout with sender stuffing and receiver destuffingDiagram in words: A horizontal strip divided into boxes from left to right: Flag (01111110), Header, Payload (stuffed data), Checksum, Flag (01111110). An arrow from a box labelled "Sender stuffing" points into the Payload, and an arrow from the Payload points to a box labelled "Receiver destuffing".FrameFlag (01111110)HeaderPayload(stuffed data)ChecksumFlag (01111110)Sender stuffingReceiverdestuffing
Bit-stuffed frame layout with sender stuffing and receiver destuffing

In conclusion, bit stuffing (HDLC) and byte stuffing (PPP) are the practical methods. Many protocols combine a count with flags for extra safety.

3 Explain the Cyclic Redundancy Check (CRC). Compute the CRC for the data 110101 using the generator polynomial G(x) = x^3 + x + 1, and show how the receiver verifies the frame. 10 marks
Model answer

CRC is a powerful error-detection code. The bit string is treated as a polynomial with coefficients 0 and 1, and the frame is divided by an agreed generator polynomial using modulo-2 arithmetic, in which subtraction is XOR. The sender appends a remainder chosen so that the transmitted frame is exactly divisible by the generator.

Procedure:

1. Let r be the degree of G(x). Append r zeros to the data.

2. Divide the result by G(x) using modulo-2 division.

3. The r-bit remainder is the CRC. It replaces the appended zeros.

4. The receiver divides the received frame by G(x). A zero remainder means no error was detected.

Worked example:

The generator is G(x) = x^3 + x + 1, which is 1011, so r = 3. The data is 110101. After appending three zeros, the dividend is 110101000.

          111101
       ----------
1011 ) 110101000
       1011
       ----
        1100
        1011
        ----
         1111
         1011
         ----
          1000
          1011
          ----
           0110
           0000
           ----
            1100
            1011
            ----
             111   <- remainder

The quotient is 111101 and the remainder (CRC) is 111. The transmitted codeword is 110101 followed by 111, which is 110101111.

Check by multiplication: 111101 × 1011 = 111101000 ⊕ 1111010 ⊕ 111101 = 110101111. This matches the codeword.

Verification at the receiver:

1. If 110101111 arrives unchanged, dividing by 1011 gives remainder 000, so the frame is accepted.

2. Suppose bit 4 from the left is flipped and 110001111 arrives. The division steps give 1100→111, 1110→101, 1011→000, 0001, 0011 and 0111, so the remainder is 111. The remainder is non-zero, so the frame is rejected.

Properties of CRC:

  • It detects all single-bit errors, because G(x) has more than one term.
  • It detects all burst errors of length ≤ r.
  • It detects every odd number of bit errors if G(x) has (x + 1) as a factor.
  • It is easy to build in hardware with a shift register and XOR gates.

Error correction with a Hamming code:

A Hamming code adds r check bits to m data bits, where 2^r ≥ m + r + 1. The check bits sit at positions 1, 2, 4, 8 and so on. Each check bit gives even parity over all positions whose binary number contains that power of two.

Example: the data 1011 in Hamming(7,4) occupies positions 3, 5, 6 and 7. Then p1 (positions 1, 3, 5, 7) = 0, p2 (positions 2, 3, 6, 7) = 1 and p4 (positions 4, 5, 6, 7) = 0, so the codeword is 0110011. If position 5 is flipped, the received word is 0110111. The checks for p1, p2 and p4 give 1, 0 and 1, so the syndrome is 101 = 5, and the receiver flips bit 5 to recover the codeword.

In conclusion, CRC appends r check bits obtained by modulo-2 division. For the data 110101 with generator 1011, the CRC is 111 and the frame sent is 110101111.

4 Explain the one's-complement Internet checksum. Compute the checksum for the 16-bit words 7A12, 3C45, E0F1 and 1234 (hexadecimal), and show the check at the receiver. Compare the checksum with CRC. 10 marks
Model answer

A checksum is an error-detection code built from the arithmetic sum of the data. The Internet checksum, used in IP, UDP and TCP headers, uses 16-bit one's-complement arithmetic. In this arithmetic, any carry out of the most significant bit is added back into the least significant bit (end-around carry).

Sender procedure:

1. Split the data into 16-bit words. Set the checksum field to 0.

2. Add all words using one's-complement addition, wrapping every carry back into the sum.

3. Complement the final sum by inverting every bit. The result is the checksum, which is placed in the checksum field.

Receiver procedure:

1. Add all received words, including the checksum, with one's-complement addition.

2. Complement the result. If the result is 0000, that is, if the sum was FFFF, the data is accepted. Otherwise it is rejected.

Worked example:

1. 7A12 + 3C45 = B657. There is no carry.

2. B657 + E0F1 = 1 9748. A carry comes out of 16 bits, so it is wrapped: 9748 + 1 = 9749.

3. 9749 + 1234 = A97D. There is no carry.

4. The one's-complement sum is A97D, which is 1010 1001 0111 1101 in binary.

5. Inverting gives the checksum 0101 0110 1000 0010 = 5682 (hex).

Receiver check:

The receiver adds 7A12 + 3C45 + E0F1 + 1234 + 5682. The first four words give A97D, as above. Then A97D + 5682 = FFFF, and the complement of FFFF is 0000. The data is accepted.

If a single bit of any word had changed, the sum would not be FFFF and the error would be detected.

Internet checksum: sender computation and receiver checkDiagram in words: Box "Data words" → arrow "one's-complement add" → box "Sum A97D" → arrow "invert bits" → box "Checksum 5682" → arrow "transmit with data" → box "Receiver adds all words" → arrow "result FFFF, complement 0000" → box "Accept".Data wordsSum A97DChecksum 5682Receiver addsall wordsAcceptone's-complement addinvert bitstransmitwith dataFFFF,complement 0000
Internet checksum: sender computation and receiver check

Comparison with CRC:

  • Computation: the checksum is simple addition and is cheap in software. CRC uses polynomial division and is cheap in hardware.
  • Strength: the checksum misses some errors, such as two words swapped or two errors that cancel in the sum. CRC detects all bursts up to its degree and almost all longer ones.
  • Use: the checksum is used in IP, UDP and TCP at higher layers. CRC is used in data link frames such as HDLC, PPP and Ethernet.

In conclusion, the Internet checksum for the given words is 5682 (hex). The receiver's sum of FFFF confirms the data. The checksum is weaker than CRC but very fast to compute in software.

5 Explain the elementary data link protocols: the unrestricted simplex protocol, the simplex stop-and-wait protocol, and the simplex protocol for a noisy channel. 10 marks
Model answer

Elementary data link protocols show, step by step, how reliability is built up. All three send data in one direction only (simplex). Each one removes an unrealistic assumption made by the previous one.

1. Unrestricted simplex protocol (Utopia):

Assumptions: the channel never loses or damages frames, the receiver has infinite buffer space and infinite processing speed, and the network layer always has data ready.

Sender: it repeatedly takes a packet from the network layer, builds a frame and sends it.

Receiver: it waits for a frame, extracts the packet and passes it up.

The protocol has no sequence numbers, acks or flow control. It is unrealistic, but it gives a base design.

2. Simplex stop-and-wait protocol (error-free channel):

The assumption of an infinitely fast receiver is dropped. The sender sends one frame and then waits. After passing the frame to its network layer, the receiver sends back a small dummy frame that acts as permission to send the next frame. This is feedback-based flow control. Because the channel is still error-free, no timers or sequence numbers are needed.

3. Simplex protocol for a noisy channel (PAR / stop-and-wait ARQ):

Frames may now be damaged or lost. The fixes are:

  • A checksum lets the receiver detect damaged frames and discard them silently.
  • The sender starts a timer after each frame. If no ack arrives in time, it retransmits the frame.
  • A 1-bit sequence number (0 or 1) is placed in each frame. Without it, a lost ack would cause the sender to retransmit, and the receiver would wrongly accept a duplicate. With it, the receiver accepts only the expected number and re-acknowledges duplicates.

Sender pseudocode for this protocol:

next_frame_to_send = 0
get packet from network layer
loop:
  build frame(seq = next_frame_to_send, packet)
  send frame; start timer
  wait for event
  if event == ack_arrival and ack == next_frame_to_send:
      stop timer
      get next packet from network layer
      next_frame_to_send = 1 - next_frame_to_send
  // on timeout or bad ack: loop and resend the same frame
Stop-and-wait ARQ on a noisy channel: lost frame and retransmissionDiagram in words: Two vertical time lines, Sender on the left and Receiver on the right. A slanting arrow from Sender to Receiver is labelled "Frame 0", and an arrow back is labelled "ACK 0". A second arrow labelled "Frame 1" ends with a cross before reaching the Receiver (lost). On the Sender line a bracket is labelled "timeout", followed by a new arrow "Frame 1 (retransmitted)" that reaches the Receiver, and an arrow back labelled "ACK 1".SenderReceiverSenderReceiverSend Frame 0Frame 0 reachesACK 0; sendFrame 1X losttimeoutFrame 1 reachesACK 1 arrivesFrame 0ACK 0Frame 1Frame 1(retransmitted)ACK 1
Stop-and-wait ARQ on a noisy channel: lost frame and retransmission

In conclusion, these three protocols build up the ideas of acknowledgement, timeout and sequence number. Because only one frame is outstanding at a time, line utilisation is poor on long links, which leads to sliding window protocols.

6 Explain the sliding window protocols: one-bit sliding window, Go-Back-N and Selective Repeat. Derive the maximum window sizes using an example with 3-bit sequence numbers. 10 marks
Model answer

Sliding window protocols let a sender keep several frames outstanding before receiving acknowledgements, which keeps the link busy. With m-bit sequence numbers the numbers run from 0 to 2^m − 1. The sender window lists frames sent but not yet acknowledged. The receiver window lists frames the receiver will accept.

1. One-bit sliding window:

The window size is 1 and the sequence numbers are 0 and 1. The protocol is full duplex: each side sends data frames with piggybacked acks. It behaves like stop-and-wait, so it is correct, but it is inefficient when the propagation delay is large.

2. Go-Back-N (GBN):

The sender window Ws can be greater than 1. The receiver window is 1, so the receiver accepts frames only in order. When a frame is lost or damaged, the receiver discards every later frame. When the sender's timer for the lost frame expires, it resends that frame and all frames after it. Acks are cumulative.

3. Selective Repeat (SR):

Both windows are greater than 1. The receiver buffers correct out-of-order frames and may send a NAK for a missing frame. Only the lost or damaged frame is retransmitted, and the buffered frames are then delivered in order.

Example: frames 0 to 6 are sent and frame 2 is lost.

Frame 2 lost: Go-Back-N vs Selective RepeatDiagram in words: Two vertical time lines, Sender and Receiver. Arrows labelled 0, 1, 2, 3, 4, 5, 6 go from Sender to Receiver, and arrow 2 ends in a cross (lost). In the GBN version, frames 3 to 6 at the Receiver are marked "discarded", and after a "timeout 2" mark the Sender resends arrows 2, 3, 4, 5, 6. In the SR version, frames 3 to 6 at the Receiver are marked "buffered", an arrow "NAK 2" returns to the Sender, and only arrow 2 is resent, after which the Receiver delivers frames 2 to 6.GBN versionSR versionSenderReceiverFrame 2 lostFrames 3 to6 discardedtimeout 2ReceiverSenderReceiverFrame 2 lostFrames 3 to6 bufferedSenderDeliversframes 2 to 60, 123, 4, 5, 6resend 2,3, 4, 5, 60, 123, 4, 5, 6NAK 2resend 2
Frame 2 lost: Go-Back-N vs Selective Repeat

Window size derivation (m = 3, sequence numbers 0 to 7):

1. GBN with Ws = 8: the sender sends frames 0 to 7, the receiver accepts all of them, and all eight acks are lost. The sender times out and resends frame 0. The receiver now expects the next frame 0 and wrongly accepts the old one as new. With Ws = 7 this ambiguity cannot happen. So Ws ≤ 2^m − 1 = 7.

2. SR with Ws = Wr = 5: the sender sends frames 0 to 4, the receiver accepts them and moves its window to 5, 6, 7, 0, 1, and all acks are lost. The sender times out and resends the old frame 0, which falls inside the receiver's new window. The receiver cannot tell it apart from a fresh frame, so it wrongly accepts it as the new frame 0 and later delivers a duplicate packet to the network layer. To prevent this, the old and new receiver windows must not overlap, so Ws = Wr ≤ 2^(m−1) = 4.

Comparison:

  • GBN has a simple receiver but wastes bandwidth on resends.
  • SR needs buffers and more complex logic but resends only the frames that need it.

In conclusion, with 3-bit sequence numbers the maximum window is 7 for Go-Back-N and 4 for Selective Repeat.

Unit 3

Media Access Control and Wired LANs

Syllabus: Random access: ALOHA; CSMA; CSMA with collision detection (CSMA/CD); CSMA with collision avoidance (CSMA/CA); Controlled access: reservation, polling and token passing; Channelization: FDMA, TDMA and CDMA; Ethernet protocol and standard Ethernet; Fast Ethernet; Gigabit Ethernet and 10 Gigabit Ethernet

One-page revision summary

  • In random access no station controls another; ALOHA, CSMA, CSMA/CD and CSMA/CA all accept or manage the risk of collision.
  • Pure ALOHA sends at any time and has vulnerable time 2Tfr; slotted ALOHA sends only at slot starts and has vulnerable time Tfr.
  • CSMA senses before sending, and its vulnerable time equals the propagation time Tp.
  • The 1-persistent, non-persistent and p-persistent methods decide how a station behaves after sensing the line.
  • CSMA/CD aborts on collision, sends a jam signal and retries with binary exponential backoff, and needs Tfr ≥ 2Tp.
  • CSMA/CA avoids collisions using IFS, a contention window whose timer freezes when the channel is busy, and acknowledgments.
  • RTS/CTS together with the NAV gives virtual carrier sensing and solves the hidden station problem.
  • In reservation, each interval starts with a frame of N minislots, and a station sets its own minislot to book a data slot.
  • In polling a primary controls secondaries, using select to send data and poll to collect data; the primary is a single point of failure.
  • In token passing only the token holder sends, around a logical ring built as a physical, dual, bus or star ring.
  • FDMA gives each station a frequency band separated by guard bands, and TDMA gives each station a time slot in every frame.
  • CDMA lets all stations send together using orthogonal chip sequences, which can be generated with Walsh tables.
  • The Standard Ethernet frame has preamble, SFD, destination, source, type/length, data and CRC fields, and is 64 to 1518 bytes long.
  • Ethernet addresses are 48 bits; the first byte's least significant bit separates unicast (0) from multicast (1), and all 1s means broadcast.
  • Standard Ethernet implementations are 10Base5, 10Base2, 10Base-T and 10Base-F, all using Manchester encoding.
  • Fast Ethernet runs at 100 Mbps, adds autonegotiation, and uses 100Base-TX, 100Base-FX and 100Base-T4.
  • Gigabit Ethernet is mostly full duplex; half duplex needs carrier extension and frame bursting, and its media are SX, LX, CX and T.
  • 10 Gigabit Ethernet is full duplex only, uses no CSMA/CD, runs mainly on fibre and suits LANs, MANs and WANs.
  • Standard Ethernet changed through bridged Ethernet (a bridge separates collision domains), switched Ethernet (a switch gives each station its own link) and full-duplex Ethernet (separate send and receive paths, so no CSMA/CD), with an optional MAC control layer for flow control.

Learn these by heart

  • Pure ALOHA: S = G e^(−2G), maximum 0.184 at G = 0.5. Slotted ALOHA: S = G e^(−G), maximum 0.368 at G = 1.
  • Vulnerable time: pure ALOHA = 2Tfr, slotted ALOHA = Tfr, CSMA = Tp.
  • CSMA/CD rule: Tfr ≥ 2Tp, so minimum frame bits = data rate × 2Tp (512 bits = 64 bytes for 10 Mbps Ethernet).
  • Binary exponential backoff: choose R from 0 to 2^K − 1, wait R × slot time, and abort when K > Kmax (15).
  • CDMA: send −1 for bit 0, +1 for bit 1 and 0 when silent; recovered value = (combined signal · own code) / N.
  • Ethernet frame: 64 to 1518 bytes with 46 to 1500 bytes of data; addresses are 48 bits; broadcast is FF:FF:FF:FF:FF:FF.

2-mark questions

1 Define vulnerable time. Find its value for pure ALOHA and for slotted ALOHA when the frame transmission time is 2 ms. 2 marks
Model answer

Vulnerable time is the interval during which any other transmission would collide with a given frame.

  • Pure ALOHA: vulnerable time = 2 × Tfr = 2 × 2 = 4 ms.
  • Slotted ALOHA: a frame can collide only with frames sent in the same slot, so vulnerable time = Tfr = 2 ms.
2 What is the p-persistent method in CSMA? 2 marks
Model answer

The p-persistent method is used on slotted channels. When a station finds the line idle, it transmits with probability p. With probability q = 1 − p it waits for the next slot and senses the line again. If the line has become busy, it behaves as if a collision occurred and applies backoff. This balances collisions against delay.

3 A 10 Mbps CSMA/CD network has a maximum propagation time of 25.6 μs. Find the minimum frame size. 2 marks
Model answer

The frame transmission time must be at least twice the propagation time, so that the sender is still transmitting when news of a collision returns.

Tfr = 2 × 25.6 = 51.2 μs.

Minimum size = 10 × 10^6 × 51.2 × 10^-6 = 512 bits = 64 bytes.

4 What is the Network Allocation Vector (NAV) in CSMA/CA? 2 marks
Model answer

The NAV is a timer kept by every station. When a station hears an RTS or CTS frame, it reads the duration field and sets its NAV to that value. Until the NAV expires, the station treats the medium as busy and does not try to send. This acts as a virtual carrier sense.

5 What is autonegotiation in Fast Ethernet? 2 marks
Model answer

Autonegotiation lets two connected devices exchange their capabilities and settle on the best mode both support. They agree on the data rate (10 or 100 Mbps) and on half or full duplex. A 100 Mbps device can therefore work with older 10 Mbps devices, and a hub port can be set to suit each attached station.

6 Why are carrier extension and frame bursting used in half-duplex Gigabit Ethernet? 2 marks
Model answer

At 1 Gbps a 64-byte frame is sent too quickly for collision detection over a useful cable length. Carrier extension pads short frames up to a minimum of 512 bytes (4096 bits). Because padding wastes capacity, frame bursting sends several short frames back to back, filling the gaps with extension symbols.

10-mark questions

1 Explain pure ALOHA and slotted ALOHA with their vulnerable times. Derive the throughput of pure ALOHA and find its maximum value. Stations share a 500 kbps channel using pure ALOHA with 500-bit frames. Find the throughput when the system produces (i) 1000 (ii) 500 (iii) 250 frames per second. 10 marks
Model answer

ALOHA is the earliest random access protocol and was designed for a shared radio channel. No station controls another, so collisions can occur and are handled by retransmission.

Pure ALOHA

  • A station sends a frame as soon as it has one, without sensing the channel.
  • It then waits for an acknowledgment. If none arrives within a timeout (about 2 × maximum propagation time), it assumes a collision.
  • It waits a random backoff time TB = R × (Tp or Tfr), where R is chosen from 0 to 2^K − 1 and K is the attempt number. It then resends, and gives up after Kmax attempts.
  • A frame sent at time t collides with any frame started between t − Tfr and t + Tfr, so the vulnerable time is 2 × Tfr.

Slotted ALOHA

  • Time is divided into slots of length Tfr, and a station may send only at the start of a slot.
  • Only frames starting in the same slot collide, so the vulnerable time is Tfr.

Throughput derivation for pure ALOHA 1. Let G be the average number of frames generated by all stations in one frame time. Assume Poisson arrivals: P(k frames) = λ^k e^(−λ)/k!, where λ is the mean count in the interval. 2. A frame succeeds only if no other frame is generated during its vulnerable time 2Tfr. The mean count in that interval is 2G, so P(success) = e^(−2G). 3. Throughput S = G × P(success) = G e^(−2G). 4. For the maximum, set dS/dG = e^(−2G)(1 − 2G) = 0, which gives G = 1/2. 5. Smax = (1/2)e^(−1) = 1/(2e) ≈ 0.184, that is 18.4%.

The same steps with vulnerable time Tfr give S = G e^(−G) for slotted ALOHA. Its maximum is 1/e ≈ 0.368 at G = 1.

Numerical problem Tfr = 500 bits / 500 kbps = 1 ms, so G = (frames per second) × 0.001. Successful frames per second = S / Tfr = S × 1000.

(i) 1000 frames/s: G = 1, S = 1 × e^(−2) = 0.135. About 135 frames/s succeed.

(ii) 500 frames/s: G = 0.5, S = 0.5 × e^(−1) = 0.184. About 184 frames/s succeed, which is the maximum possible.

(iii) 250 frames/s: G = 0.25, S = 0.25 × e^(−0.5) = 0.25 × 0.6065 = 0.152. About 152 frames/s succeed.

For comparison, slotted ALOHA at 1000 frames/s gives S = e^(−1) = 0.368, or 368 frames/s.

In conclusion, pure ALOHA uses at most 18.4% of the channel. Slotted ALOHA halves the vulnerable time and doubles the peak throughput, at the cost of keeping all stations synchronised.

2 Explain the persistence methods of CSMA. Describe CSMA/CD with its flow of operation, derive the minimum frame size condition, and compute the minimum frame for a 100 Mbps network of length 2 km with signal speed 2 × 10^8 m/s. 10 marks
Model answer

CSMA (carrier sense multiple access) reduces collisions by making each station listen to the medium before it sends. Collisions are still possible because of propagation delay: a station may sense the line idle while another station's signal has not yet reached it. The vulnerable time of CSMA is therefore the propagation time Tp.

Persistence methods (what a station does when it senses the line) 1. 1-persistent: the station senses continuously and sends immediately once the line is idle. This is fast, but collisions are likely when several stations are waiting. 2. Non-persistent: if the line is busy, the station waits a random time and then senses again. Collisions are fewer, but the line may sit idle, which lowers efficiency. 3. p-persistent: used on slotted lines. When the line is idle, the station sends with probability p. With probability 1 − p it waits for the next slot and senses again. If the line is busy, it uses backoff.

CSMA/CD operation 1. Set the attempt counter K = 0. 2. Apply a persistence method until the line is idle. 3. Transmit the frame while monitoring the energy level on the line. 4. If the whole frame is sent with no collision, the transmission succeeds. 5. If a collision is detected, stop at once and send a short jam signal so that every station notices it. 6. Increment K. If K > Kmax (typically 15), abort. 7. Otherwise choose R at random from 0 to 2^K − 1, wait R × slot time (binary exponential backoff) and return to step 2.

CSMA/CD flow of operation with backoffDiagram in words: A flowchart starts at box "K = 0", with an arrow to box "Apply persistence method", then an arrow to box "Transmit and monitor", then an arrow to decision "Collision?". The "No" arrow goes to box "Success". The "Yes" arrow goes to box "Send jam signal", then to box "K = K + 1", then to decision "K > Kmax?". Its "Yes" arrow goes to box "Abort". Its "No" arrow goes to box "Wait R × slot time, R in 0..2^K − 1", and an arrow from there returns to "Apply persistence method".K = 0Apply persistencemethodTransmitand monitorCollision?SuccessSend jam signalK = K + 1K exceeds Kmax?AbortWait R ×slot timeNoYesYesNo (R in0..2^K − 1)repeat
CSMA/CD flow of operation with backoff

Minimum frame size A sender knows of a collision only if it is still transmitting. In the worst case, station A starts sending, and station B at the far end starts just before A's signal arrives. The collision then needs another Tp to travel back to A. Hence Tfr ≥ 2 × Tp.

Calculation Tp = 2000 / (2 × 10^8) = 10 μs. Tfr(min) = 2 × 10 = 20 μs. Minimum frame = 100 × 10^6 × 20 × 10^-6 = 2000 bits = 250 bytes.

In conclusion, sensing lowers the chance of collision, and collision detection cuts the time wasted when one occurs. This works only if frames are long enough to cover the round-trip time.

3 Why is CSMA/CD unsuitable for wireless networks? Explain CSMA/CA with interframe space, contention window, acknowledgment, RTS/CTS and NAV, giving a timing description. 10 marks
Model answer

Wireless LANs cannot rely on collision detection for three reasons:

  • A station usually cannot transmit and receive at the same time, so it cannot sense a collision while it is sending.
  • Two hidden stations may both reach the access point but not each other, so the sender may never hear a collision.
  • The received signal is very weak compared with the transmitted one, so a collision does not cause a clear energy change.

CSMA/CA therefore avoids collisions instead of detecting them. It uses three tools.

1. Interframe space (IFS): even when the channel is idle, a station waits an IFS (DIFS for data in IEEE 802.11) before sending, because a distant station may already have started. The shorter SIFS is used before CTS, data and ACK, which gives those frames priority. 2. Contention window: after the IFS, the station picks a random number of slots. The window size doubles after each failure (binary exponential). The station senses the channel after every slot. If the channel turns busy, the timer is frozen, not reset, and resumes when the channel is idle again, which favours stations that have waited longer. 3. Acknowledgment: because collisions are not detected, the receiver confirms each correct frame with an ACK. A missing ACK within the timeout means the frame must be resent.

Exchange with RTS/CTS 1. The source senses the channel idle, waits DIFS and then completes its backoff. 2. The source sends Request To Send (RTS), which carries the duration needed. 3. The destination waits SIFS and replies with Clear To Send (CTS). 4. The source waits SIFS and sends the data frame. 5. The destination waits SIFS and sends ACK.

Network Allocation Vector Other stations that hear RTS or CTS set their NAV to the announced duration and stay silent until it expires. This virtual carrier sensing also solves the hidden station problem, because a station that cannot hear the source still hears the CTS from the destination.

CSMA/CA timing with RTS/CTS and NAVDiagram in words: A timing chart has three horizontal time lines labelled "Source", "Destination" and "Other stations", with time running left to right. On the Source line are the blocks "DIFS", "Backoff" and "RTS". A gap labelled "SIFS" leads to block "CTS" on the Destination line. A second gap labelled "SIFS" leads to block "Data" on the Source line. A third gap labelled "SIFS" leads to block "ACK" on the Destination line. On the Other stations line, a long bar labelled "NAV (do not transmit)" runs from the end of RTS to the end of ACK.SourceDestinationOther stationsDIFSBackoffRTSCTSDataACKNAV (do nottransmit)SIFSSIFSSIFSend of RTSend of ACK
CSMA/CA timing with RTS/CTS and NAV

In conclusion, CSMA/CA accepts some idle waiting time in exchange for far fewer collisions. This suits wireless media, where collisions cannot be reliably sensed.

4 What is controlled access? Explain the reservation, polling (select and poll) and token passing methods with suitable diagrams. 10 marks
Model answer

In controlled access, stations consult one another to decide which station may send. A station transmits only when it is authorised, so collisions do not occur. There are three methods.

1. Reservation

  • Time is divided into intervals. Each interval starts with a reservation frame, followed by data frames.
  • With N stations, the reservation frame has N minislots, one belonging to each station.
  • A station that wants to send sets its own minislot. The reserving stations then send their data frames in minislot order.
  • Example: with 5 stations, if minislots 1, 3 and 4 are set, the frames of stations 1, 3 and 4 follow in that order.

2. Polling One device is the primary station and the others are secondaries. All exchanges pass through the primary, which controls the link.

  • Poll (used when the primary wants to receive): the primary asks a secondary whether it has data. The secondary replies NAK if it has nothing, or sends its data frame, which the primary acknowledges with ACK. The primary then polls the next secondary.
  • Select (used when the primary wants to send): the primary sends a SEL frame addressed to a secondary to check that it is ready. The secondary returns ACK, and the primary then sends the data.
  • Drawbacks: if the primary fails, the whole system stops, and polling messages add delay.
Controlled access: polling (select and poll) and token passingDiagram in words: Two boxes, "Primary" on the left and "Secondary A" on the right. For select, the arrows are: Primary → A labelled "SEL", A → Primary labelled "ACK", Primary → A labelled "Data", A → Primary labelled "ACK". For poll, the arrows are: Primary → A labelled "Poll", A → Primary labelled "Data", Primary → A labelled "ACK". An alternative arrow A → Primary labelled "NAK" is used when A has no data. Diagram in words: Four circles A, B, C and D are placed in a ring. The arrows run A → B, B → C, C → D and D → A, each labelled "token". A note beside A reads "holds token, sends data".Polling: select and pollToken passing: logical ringPrimarySecondary AABCDholds token,sends dataSelect: SELSelect: ACKSelect: DataSelect: ACKPoll: PollPoll: DataPoll: ACKPoll: NAK(no data)tokentokentokentoken
Controlled access: polling (select and poll) and token passing

3. Token passing

  • Stations form a logical ring, and each station has a predecessor and a successor.
  • A special frame called the token circulates around the ring. Only the station holding the token may send. When it finishes, or when its token holding time runs out, it passes the token to its successor.
  • Token management covers limiting the holding time, regenerating a lost token, removing duplicate tokens and handling priorities.
  • The logical ring can be built as a physical ring, a dual ring (the second ring is a backup), a bus ring (token bus) or a star ring (a hub with internal ring wiring, which tolerates faults better).

In conclusion, controlled access removes collisions and gives predictable delay. The price is overhead: reservation frames, poll and select messages, or token circulation.

5 Explain FDMA, TDMA and CDMA. Four stations use CDMA with the codes A = [+1 +1 +1 +1], B = [+1 −1 +1 −1], C = [+1 +1 −1 −1] and D = [+1 −1 −1 +1]. A sends bit 0, B sends 1, C is silent and D sends 1. Find the combined signal and show how every station's data is recovered. 10 marks
Model answer

Channelization shares the available capacity of a link among stations by dividing it in frequency, in time or by code.

1. FDMA (frequency division multiple access)

  • The total bandwidth is split into frequency bands, and each station is given one band for as long as it needs it.
  • Thin guard bands separate neighbouring bands to prevent interference, and each station uses a bandpass filter to stay within its band.
  • FDMA is an access method in the data link layer. It differs from FDM, which is a physical-layer technique that combines signals from low-bandwidth channels.

2. TDMA (time division multiple access)

  • All stations use the whole bandwidth, but time is divided into frames and each station owns one slot in every frame.
  • Stations must be synchronised, and guard times are added to allow for differing propagation delays.

3. CDMA (code division multiple access)

  • All stations transmit at the same time over the full bandwidth. Each station is separated from the others by its own chip sequence.
  • The codes are orthogonal: the inner product of two different codes is 0, and the inner product of a code with itself is N, the number of chips.
  • Encoding rule: bit 0 is sent as −1, bit 1 as +1, and a silent station contributes 0. Each station multiplies its value by its code, and the channel adds the results.

Solution of the problem (N = 4) A sends −1: −1 × [+1 +1 +1 +1] = [−1 −1 −1 −1] B sends +1: [+1 −1 +1 −1] C is silent: [0 0 0 0] D sends +1: [+1 −1 −1 +1]

Combined signal, chip by chip:

  • Chip 1: −1 + 1 + 0 + 1 = +1
  • Chip 2: −1 − 1 + 0 − 1 = −3
  • Chip 3: −1 + 1 + 0 − 1 = −1
  • Chip 4: −1 − 1 + 0 + 1 = −1

Combined signal = [+1 −3 −1 −1].

Decoding: take the inner product with the station's code and divide by 4.

  • A: (1)(1) + (−3)(1) + (−1)(1) + (−1)(1) = −4, and −4/4 = −1, so A sent bit 0.
  • B: (1)(1) + (−3)(−1) + (−1)(1) + (−1)(−1) = 1 + 3 − 1 + 1 = 4, and 4/4 = +1, so B sent bit 1.
  • C: (1)(1) + (−3)(1) + (−1)(−1) + (−1)(−1) = 1 − 3 + 1 + 1 = 0, so C was silent.
  • D: (1)(1) + (−3)(−1) + (−1)(−1) + (−1)(1) = 1 + 3 + 1 − 1 = 4, and 4/4 = +1, so D sent bit 1.

In conclusion, FDMA and TDMA give each station a private share of frequency or time. CDMA lets every station use the whole channel at once, and orthogonal codes make each station's data recoverable. Such codes can be generated with Walsh tables, where N is a power of 2.

6 Describe the Standard Ethernet frame format, addressing and physical implementations. Explain how Fast Ethernet, Gigabit Ethernet and 10 Gigabit Ethernet changed the standard. 10 marks
Model answer

Ethernet (IEEE 802.3) is the dominant wired LAN technology. Standard Ethernet runs at 10 Mbps, is connectionless and unreliable at the MAC level (it uses no acknowledgments), and uses 1-persistent CSMA/CD.

1. Frame format The fields, in order, are:

  • Preamble (7 bytes): alternating 1s and 0s for synchronisation.
  • Start frame delimiter (1 byte): 10101011, which marks the start of the frame.
  • Destination address (6 bytes).
  • Source address (6 bytes).
  • Type or length (2 bytes): the upper-layer protocol, or the data length.
  • Data (46 to 1500 bytes), padded if shorter than 46 bytes.
  • CRC (4 bytes): a CRC-32 error check.

The minimum frame is 64 bytes (512 bits, needed for collision detection) and the maximum is 1518 bytes; both exclude the preamble and SFD.

Ethernet frame fields in order of transmission (bytes)Diagram in words: One long horizontal rectangle divided into seven boxes, left to right: "Preamble 7", "SFD 1", "Destination 6", "Source 6", "Type/Length 2", "Data and padding 46–1500", "CRC 4". A brace under the last five boxes is labelled "64 to 1518 bytes". An arrow above points left to right, labelled "order of transmission".64 to 1518 bytesPreamble 7SFD 1Destination 6Source 6Type/Length 2Data andpadding 46–1500CRC 4
Ethernet frame fields in order of transmission (bytes)

2. Addressing

  • Each address is 48 bits, written in hexadecimal such as 4A:30:10:21:10:1A.
  • If the least significant bit of the first byte is 0, the address is unicast; if it is 1, the address is multicast. An address of all 1s (FF:FF:FF:FF:FF:FF) is broadcast.
  • Bytes are sent left to right, and within each byte the least significant bit is sent first.

3. Standard Ethernet implementations (Manchester encoding)

  • 10Base5: thick coaxial bus, 500 m segment.
  • 10Base2: thin coaxial bus, 185 m.
  • 10Base-T: twisted pair in a star around a hub, 100 m.
  • 10Base-F: fibre in a star, 2000 m.

Changes in Standard Ethernet:

  • Bridged Ethernet: a bridge splits a LAN into separate collision domains, which raises the bandwidth available to each segment.
  • Switched Ethernet: a switch with N ports gives each station its own link, so stations no longer compete for one shared medium.
  • Full-duplex Ethernet: each station has separate send and receive paths, so there are no collisions and CSMA/CD is not needed. An optional MAC control layer adds flow control, for example with PAUSE frames.

4. Fast Ethernet (100 Mbps)

  • It keeps the frame format, the addressing and the minimum and maximum frame lengths.
  • It added autonegotiation and supports full duplex through switches.
  • Implementations: 100Base-TX (two pairs of Cat 5 UTP, 4B/5B with MLT-3), 100Base-FX (fibre, 4B/5B with NRZ-I) and 100Base-T4 (four pairs of Cat 3, 8B/6T).

5. Gigabit Ethernet (1000 Mbps)

  • It is mostly full duplex with switches, so CSMA/CD is not needed.
  • Half duplex uses carrier extension (a minimum of 512 bytes) and frame bursting.
  • Implementations: 1000Base-SX (short-wave fibre), 1000Base-LX (long-wave fibre), 1000Base-CX (shielded copper) and 1000Base-T (four pairs of Cat 5 UTP).

6. 10 Gigabit Ethernet (IEEE 802.3ae)

  • It is full duplex only and has no CSMA/CD.
  • It runs mainly on fibre and can serve LANs, MANs and WANs.
  • Implementations include 10GBase-SR, 10GBase-LR and 10GBase-EW (short, long and extended reach).

In conclusion, each generation multiplied the data rate by ten while keeping the frame and address formats, which keeps the generations compatible. Over time Ethernet moved from shared buses with CSMA/CD to switched, full-duplex links.

Unit 4

Network Layer

Syllabus: Store-and-forward packet switching; Services provided to the transport layer; Connectionless and connection-oriented service; Comparison of virtual-circuit and datagram networks; The optimality principle; Shortest path routing and flooding; Distance vector routing; Link state routing; Hierarchical routing; General principles of congestion control and congestion prevention policies; Traffic-aware routing, admission control, traffic throttling and load shedding; Leaky bucket and token bucket; How networks differ and how they can be connected; Tunnelling, internetwork routing and fragmentation; IPv4 header format; IP addresses, classful addressing, CIDR and subnets; The main IPv6 header; Transition from IPv4 to IPv6 and comparison of IPv4 and IPv6

One-page revision summary

  • In store-and-forward packet switching, each router receives the whole packet, verifies its checksum, and only then forwards it towards the destination.
  • Network layer services must be independent of router technology, hide the number, type and topology of routers from the transport layer, and use a uniform addressing plan, and they may be connectionless (each datagram routed independently) or connection-oriented (a virtual circuit set up first).
  • Virtual-circuit networks need setup, short labels and per-connection state but give ordered delivery and easy QoS; datagram networks need no setup and are more robust to router failure.
  • By the optimality principle, if router J lies on the optimal path from I to K, the J-to-K part is also optimal, so optimal routes to one destination form a loop-free sink tree, which shortest path routing builds by modelling the network as a weighted graph and running Dijkstra's algorithm.
  • Flooding sends every incoming packet out on every line except its arrival line, and duplicates are limited by a hop counter decremented at each router (packet discarded at zero) or by source sequence numbers that let each router drop packets it has already seen.
  • Selective flooding sends packets only on lines going roughly in the right direction, and flooding is used where robustness matters, such as broadcasting, military networks, updating distributed databases and distributing link state packets, and as a benchmark because it always finds the shortest-delay path.
  • Distance vector routing applies the Bellman-Ford equation using neighbours' vectors and suffers from the count-to-infinity problem, which split horizon and poisoned reverse reduce.
  • Link state routing works in five steps: discover neighbours (HELLO packets), measure link costs (ECHO packets), build link state packets, flood them reliably, and run Dijkstra on the full topology.
  • Hierarchical routing groups routers into regions (and regions into clusters, zones and groups for more levels), so each router keeps full entries only for routers in its own region and one entry per other region, shrinking tables at the cost of sometimes longer paths.
  • Example: 1000 routers in 25 regions of 40 need 40 + 24 = 64 entries per router instead of 1000, and three levels of 10 clusters × 10 regions × 10 routers need only 10 + 9 + 9 = 28 entries.
  • Congestion control is open loop (prevention by design) or closed loop (monitor, feed back, adjust), using provisioning, traffic-aware routing, admission control, throttling (choke packets, ECN, hop-by-hop backpressure) and load shedding (wine or milk policy, RED).
  • In the leaky bucket algorithm, arriving packets join a finite queue that releases them at a constant rate (for example one packet or a fixed number of bytes per clock tick) however bursty the input is, and any packet arriving when the queue is full is discarded.
  • In the token bucket algorithm, tokens are added at rate ρ up to capacity C, a packet (or byte) can leave only by removing tokens, an idle host saves tokens so it may later send a burst at the full line rate, and when the bucket is full new tokens, not packets, are discarded.
  • Networks differ in service offered (connectionless or connection-oriented), addressing scheme, broadcasting support, maximum packet size, ordered delivery, quality of service, error and flow control, congestion control, security, timeouts and accounting.
  • Networks are joined by multiprotocol routers that strip the incoming network's frame header, process a common IP packet (forwarding on its destination address), and re-encapsulate it in the outgoing network's frame, so hosts on different technologies communicate through one shared network layer.
  • Internetwork routing is two-level (intradomain protocols such as OSPF, interdomain BGP), and fragmentation can be transparent or nontransparent, with path MTU discovery avoiding it.
  • The IPv4 header is 20 to 60 bytes (version, IHL, DS, total length, identification, flags, fragment offset, TTL, protocol, checksum, addresses, options), and wasteful classful addressing has been replaced by CIDR prefixes, subnet masks and longest prefix matching.
  • The IPv6 main header has a fixed 40 bytes, 128-bit addresses, a flow label and a hop limit, with no header checksum and with options in chained extension headers.
  • IPv4-to-IPv6 transition uses dual stack (hosts and routers run both protocols and pick one per destination, often by DNS), tunnelling (an IPv6 packet travels as the payload of an IPv4 packet, protocol 41, across IPv4-only regions) and translation such as NAT64 with DNS64, which rewrites headers between IPv6-only hosts and IPv4-only servers.
  • IPv4 has 32-bit addresses, a variable 20–60 byte header, a header checksum, fragmentation by routers and sources, broadcast and ARP, while IPv6 has 128-bit addresses, a fixed 40-byte header, no checksum, fragmentation only at the source, multicast and anycast in place of broadcast, and neighbour discovery replacing ARP.

Learn these by heart

  • Distance vector (Bellman-Ford): D_X(Y) = min over neighbours N of [c(X,N) + D_N(Y)].
  • Token bucket burst length: S = C/(M − ρ), since C + ρS = MS; e.g. C = 500 KB, M = 25 MB/s, ρ = 5 MB/s gives S = 0.5/20 s = 25 ms.
  • Leaky bucket: fixed output rate, no bursts, packets dropped when the queue overflows; token bucket: long-run rate ρ but bursts up to C allowed, tokens (not packets) dropped when full, packets wait for tokens.
  • Flooding duplicate control: the hop counter starts at the source-to-destination path length (or the network diameter if unknown) and the packet dies at zero; with sequence numbers each router keeps, per source, a counter k meaning all numbers up to k were seen.
  • Subnetting: number of subnets = 2^s for s borrowed bits; usable hosts per subnet = 2^h − 2 for h host bits.
  • Fragmentation: data in every non-last fragment is a multiple of 8 bytes; offset = starting data byte / 8; MF = 0 only in the last fragment.
  • IPv4 header = 20 to 60 bytes (IHL counts 4-byte words); IPv6 main header = fixed 40 bytes with 128-bit addresses.
  • Hierarchical routing with N routers and m levels of k = N^(1/m) units each needs about m·k entries; minimising m·N^(1/m) gives m = ln N, k = e and about e·ln N entries (N = 1000: about 6.9 levels, 18.8 entries).
  • Transition methods: dual stack = run IPv4 and IPv6 side by side; tunnelling = IPv6 carried inside IPv4 (protocol 41); translation = NAT64/DNS64 header conversion between IPv6-only and IPv4-only nodes.
  • Longest prefix match: when several CIDR entries match, the entry with the longest prefix wins.

2-mark questions

1 What is store-and-forward packet switching? 2 marks
Model answer

A host sends a packet to the nearest router. The router stores the complete packet in its buffer until it has fully arrived and its checksum is verified. It then forwards the packet on the next link towards the destination. Every router on the path repeats this until the packet reaches the destination host.

2 State the optimality principle in routing. 2 marks
Model answer

If router J lies on the optimal path from router I to router K, then the optimal path from J to K follows that same route. As a result, the optimal routes from all sources to one destination form a loop-free tree rooted at that destination, called the sink tree.

3 A token bucket has capacity C = 250 KB, token arrival rate ρ = 2 MB/s and maximum output rate M = 25 MB/s. Find the maximum burst length. 2 marks
Model answer

Burst length S = C/(M − ρ) = 0.25 MB / (25 − 2) MB/s = 0.25/23 s ≈ 0.0109 s.

So the host can transmit at the full 25 MB/s for about 10.9 ms.

4 How many usable hosts does a /26 subnet have, and what is its subnet mask? 2 marks
Model answer

A /26 prefix leaves 32 − 26 = 6 host bits. Usable hosts = 2^6 − 2 = 64 − 2 = 62, because the all-zeros (network) and all-ones (broadcast) addresses are excluded. The last octet of the mask is 11000000 = 192, so the mask is 255.255.255.192.

5 Define tunnelling in internetworking. 2 marks
Model answer

Tunnelling carries a packet of one network type across a different intermediate network. The whole original packet is encapsulated inside the payload of the intermediate network's packet. At the far end, the exit router removes the outer header and delivers the original packet. An example is IPv6 packets carried inside IPv4 packets.

6 List the fields of the main IPv6 header. 2 marks
Model answer

The fixed 40-byte header contains:

  • Version (4 bits, value 6)
  • Traffic class (8 bits)
  • Flow label (20 bits)
  • Payload length (16 bits)
  • Next header (8 bits)
  • Hop limit (8 bits)
  • Source address (128 bits)
  • Destination address (128 bits)

Options are moved to extension headers.

10-mark questions

1 Explain the services the network layer provides to the transport layer. Compare connectionless (datagram) and connection-oriented (virtual-circuit) networks with a suitable illustration. 10 marks
Model answer

The network layer carries packets from the source host to the destination host across many routers. How this service is offered to the transport layer is a key design decision.

Goals of the service offered to the transport layer: 1. It must not depend on the technology used inside the routers. 2. The transport layer must be shielded from the number, type and topology of the routers. 3. Addresses given to the transport layer must follow a uniform numbering plan across LANs and WANs.

Two kinds of service follow from these goals:

  • Connectionless service: the network offers only simple send and receive primitives. Each packet, called a datagram, carries the full destination address and is routed on its own. Error control and flow control are left to the hosts. The Internet uses this model with IP.
  • Connection-oriented service: a path called a virtual circuit (VC) is set up before any data flows, much like a telephone call. All packets of the connection follow this path, which makes reliability and quality of service easier to provide. MPLS is an example.
Datagram vs virtual-circuit routing from H1 to H2Diagram in words: host H1 is linked to router A. A is linked to routers B and C. B and C are both linked to router D, and D is linked to host H2. In the datagram network, packet 1 travels A → B → D while packet 2 travels A → C → D, because A's routing table changed in between. In the VC network, every packet of connection 1 travels A → C → D. It carries label 1 on link A–C and a label chosen by C on link C–D.RoutersHost H1Router ARouter BRouter CRouter DHost H2datagrampacket 1datagrampacket 1packet 2;VC 1 label 1packet 2; VC1 C's label
Datagram vs virtual-circuit routing from H1 to H2

In a VC network each router keeps a table that maps (incoming line, incoming label) to (outgoing line, outgoing label). Replacing the label at each hop is called label switching.

Comparison of virtual-circuit and datagram networks:

  • Setup: a VC network needs circuit setup; a datagram network does not.
  • Addressing: a VC packet carries a short VC number; a datagram carries full source and destination addresses.
  • Router state: VC routers keep an entry per connection; datagram routers keep no connection state.
  • Routing: a VC route is chosen once, at setup; a datagram route is chosen per packet.
  • Router failure: all VCs through the failed router are terminated; a datagram network loses only queued packets and reroutes the rest.
  • QoS and congestion control: easy in VC, because resources can be reserved at setup; difficult in datagram networks.
  • Ordering: VC delivers packets in order; datagrams may arrive out of order.

In conclusion, datagram networks are robust and keep routers simple, while virtual-circuit networks give predictable service at the cost of setup and per-connection state.

2 Discuss the general principles of congestion control and congestion prevention policies. Explain traffic-aware routing, admission control, traffic throttling and load shedding. 10 marks
Model answer

Congestion occurs when the load offered to a network, or a part of it, exceeds its capacity. Router queues grow, delay rises and packets are dropped and retransmitted. In the worst case useful throughput collapses. Congestion control keeps the network-wide load below capacity. Flow control, by contrast, only protects a slow receiver from a fast sender.

General principles: 1. Open-loop control prevents congestion through good design: when to accept traffic, when to discard packets and how to schedule them. Its decisions do not use the current network state. 2. Closed-loop control monitors queue lengths, loss and delay, passes this information to points where action can be taken, and adjusts operation. 3. There are only two remedies: increase resources or decrease load.

Congestion prevention policies at different layers:

  • Data link: retransmission policy, out-of-order caching, acknowledgement policy, flow control.
  • Network: virtual circuits or datagrams, queueing and service policy, discard policy, routing algorithm, packet lifetime.
  • Transport: the same issues plus how timeouts are set.
Approaches to congestion control by timescaleDiagram in words: a horizontal arrow labelled timescale points from 'slower' on the left to 'faster' on the right. Five boxes sit along it in this order: Network provisioning, Traffic-aware routing, Admission control, Traffic throttling, Load shedding.slowerfasterNetworkprovisioningTraffic-aware routingAdmissioncontrolTrafficthrottlingLoad sheddingtimescale
Approaches to congestion control by timescale

The approaches, from slowest to fastest: 1. Network provisioning: upgrade links and routers where long-term load is heavy. 2. Traffic-aware routing: link weights depend on measured load or delay as well as bandwidth, so traffic shifts away from hotspots. To stop routes oscillating between two paths, weights are changed slowly or traffic is split over several paths. 3. Admission control: in virtual-circuit networks, a new connection is refused if accepting it would cause congestion. The flow is described, for example by a token bucket, and routers check their spare capacity before agreeing. 4. Traffic throttling: routers detect approaching congestion, for example from an averaged queue length, and ask senders to slow down. The methods are:

  • choke packets sent back to the source;
  • explicit congestion notification (ECN) bits set in forwarded packets and echoed back by the receiver;
  • hop-by-hop backpressure, in which every router on the path cuts its rate.

5. Load shedding: when all else fails, routers drop packets, but they drop them intelligently. For file transfer, old packets are worth more (wine policy). For real-time media, new packets are worth more (milk policy). Random early detection (RED) drops packets randomly once the average queue length crosses a threshold, so TCP senders slow down before buffers overflow.

In conclusion, good congestion control combines prevention through design with fast reactions such as throttling and shedding.

3 Explain the distance vector routing algorithm with an example. What is the count-to-infinity problem and how can it be reduced? 10 marks
Model answer

Distance vector routing is a dynamic, distributed algorithm. Each router keeps a table (vector) giving the best known distance to every destination and the outgoing line to use. Routers learn only from their direct neighbours. RIP is based on this algorithm.

Working of the algorithm: 1. Each router knows the cost (hops, delay or similar) of the link to each directly connected neighbour. 2. Periodically, each router sends its whole distance vector to all its neighbours. 3. When router X receives the vector of neighbour N, it computes cost(X,N) + D_N(Y) for every destination Y. 4. X sets D_X(Y) = min over all neighbours N of [cost(X,N) + D_N(Y)] (the Bellman-Ford equation) and records the minimising N as the next hop. 5. The new table is built from the latest neighbour vectors; X's old table is not used in the computation.

Worked example

Distance vector routing example: four routers with link costsDiagram in words: four routers A, B, C and D joined by undirected links A–B cost 2, A–C cost 5, B–C cost 1, C–D cost 3 and B–D cost 7.ABCD25137
Distance vector routing example: four routers with link costs

Router A's neighbours are B (cost 2) and C (cost 5). The vectors A receives are:

  • From B: A=2, B=0, C=1, D=4
  • From C: A=3, B=1, C=0, D=3

A computes:

  • To B: via B = 2+0 = 2; via C = 5+1 = 6 → 2, next hop B
  • To C: via B = 2+1 = 3; via C = 5+0 = 5 → 3, next hop B
  • To D: via B = 2+4 = 6; via C = 5+3 = 8 → 6, next hop B

A's new table: A 0 (local), B 2 (B), C 3 (B), D 6 (B). Check: the path A–B–C–D costs 2+1+3 = 6, which agrees.

Count-to-infinity problem

Good news spreads quickly, but bad news spreads slowly. Take a line A–B–C with unit link costs, so B stores distance 1 to A and C stores distance 2. 1. A goes down, and B stops hearing from it. 2. B sees C advertising distance 2 to A and sets its own distance to 3 via C. 3. C then updates to 4 via B, B to 5, and so on. 4. The distances creep up until they reach the value used for infinity (16 in RIP). Meanwhile, packets for A loop between B and C.

Remedies:

  • Split horizon: do not report a route back to the neighbour it was learnt from.
  • Poisoned reverse: report that route back with distance infinity.
  • Use a small value for infinity so counting ends quickly.

These remedies help in simple topologies but do not cure every case.

In conclusion, distance vector routing is simple and needs little computation. However, it converges slowly and suffers from count-to-infinity, which led to link state routing in larger networks.

4 Explain link state routing in detail. Using Dijkstra's shortest path algorithm, find the shortest paths from router A in a given network. 10 marks
Model answer

Link state routing gives every router the complete network topology, so each router computes shortest paths locally. It converges faster than distance vector routing and is used in OSPF and IS-IS.

The five steps of link state routing: 1. Discover neighbours: send a HELLO packet on each line; each neighbour replies with its unique name. 2. Measure link cost: for example, time ECHO packets to find the delay, or set the cost inversely proportional to bandwidth. 3. Build a link state packet (LSP): it contains the sender's identity, a sequence number, an age, and the list of neighbours with their costs. 4. Distribute LSPs by flooding: each router forwards a new LSP on all lines except the one it arrived on. Sequence numbers let routers discard duplicates and old copies, the age field makes stale entries expire, and LSPs are acknowledged. 5. Compute routes: each router builds the full graph and runs Dijkstra's algorithm.

Dijkstra example

Network for Dijkstra's shortest paths from router ADiagram in words: five routers A, B, C, D and E joined by undirected links A–B 4, A–C 1, B–C 2, B–D 1, C–D 5, C–E 8 and D–E 3.ABCDE4121583
Network for Dijkstra's shortest paths from router A

The source is A. Each label is (distance, predecessor), and at each step the smallest tentative label is made permanent.

  • Step 1: A is permanent with distance 0. B = (4, A), C = (1, A), D = E = ∞.
  • Step 2: C(1) becomes permanent. Via C: B = min(4, 1+2) = 3 via C; D = 1+5 = 6 via C; E = 1+8 = 9 via C.
  • Step 3: B(3) becomes permanent. Via B: D = min(6, 3+1) = 4 via B.
  • Step 4: D(4) becomes permanent. Via D: E = min(9, 4+3) = 7 via D.
  • Step 5: E(7) becomes permanent, and the algorithm ends.

Routing table at A:

  • B: cost 3, path A–C–B, next hop C
  • C: cost 1, path A–C, next hop C
  • D: cost 4, path A–C–B–D, next hop C
  • E: cost 7, path A–C–B–D–E, next hop C

The shortest path to D avoids the direct C–D link of cost 5, and the path to E avoids C–E of cost 8. This shows why using the whole graph matters.

Compared with distance vector routing, link state routing:

  • converges faster and has no count-to-infinity problem;
  • needs more memory to hold the whole topology;
  • needs more computation, and flooding LSPs uses extra bandwidth.

In conclusion, link state routing, built on flooding and Dijkstra's shortest path algorithm, is well suited to large networks.

5 Draw and explain the IPv4 header format. A 4000-byte IPv4 datagram (20-byte header) must pass through a link whose MTU is 1500 bytes. Show the fragments produced. 10 marks
Model answer

An IPv4 datagram consists of a header and a payload. The header is 20 bytes without options and at most 60 bytes with them.

IPv4 header format (32 bits wide)Diagram in words: a rectangle 32 bits wide, divided into rows. Row 1: Version (4 bits), IHL (4), Differentiated services (8), Total length (16). Row 2: Identification (16), one unused bit, DF (1), MF (1), Fragment offset (13). Row 3: Time to live (8), Protocol (8), Header checksum (16). Row 4: Source address (32). Row 5: Destination address (32). Following rows: Options (0 to 40 bytes), padded to a multiple of 32 bits.Version (4)IHL (4)Differentiatedservices (8)Totallength (16)Identification(16)Unused (1)DF (1)MF (1)Fragmentoffset (13)Time to live (8)Protocol (8)Headerchecksum (16)Sourceaddress (32)Destinationaddress (32)Options (0-40B) + padding
IPv4 header format (32 bits wide)

The fields are:

  • Version: 4 for IPv4.
  • IHL: header length in 32-bit words, from 5 to 15 (20 to 60 bytes).
  • Differentiated services: 6 bits for the service class and 2 bits for ECN.
  • Total length: header plus data, at most 65,535 bytes.
  • Identification: the same value in every fragment of one datagram.
  • DF (Don't Fragment) and MF (More Fragments): MF is 1 in every fragment except the last.
  • Fragment offset: where the fragment's data sits in the original datagram, in units of 8 bytes.
  • TTL: decremented at each router; the packet is discarded at 0, which stops endless looping.
  • Protocol: the upper-layer protocol, for example 6 for TCP and 17 for UDP.
  • Header checksum: covers the header only and is recomputed at every hop because TTL changes.
  • Source and destination addresses: 32 bits each.
  • Options: for example record route, timestamp and source routing.

Fragmentation example

The datagram has a 20-byte header and 4000 − 20 = 3980 data bytes. Assume identification 777 and DF = 0.

  • Step 1: maximum data per fragment = 1500 − 20 = 1480 bytes. This is a multiple of 8 (1480/8 = 185), so it can be used.
  • Step 2: 3980 = 1480 + 1480 + 1020, so three fragments are needed.
  • Step 3: the offsets are 0/8 = 0, 1480/8 = 185 and 2960/8 = 370.

The fragments are:

  • Fragment 1: data bytes 0–1479, total length 1500, MF = 1, offset 0
  • Fragment 2: data bytes 1480–2959, total length 1500, MF = 1, offset 185
  • Fragment 3: data bytes 2960–3979, total length 1040, MF = 0, offset 370

All three carry identification 777. Check: 1480 + 1480 + 1020 = 3980 data bytes.

IPv4 uses nontransparent fragmentation: routers do not reassemble. Only the destination rebuilds the datagram, using the identification, offset and MF fields.

In conclusion, the IPv4 header supports options, fragmentation by routers and loop protection through TTL, at the cost of checksum processing at every hop.

6 Explain classful IPv4 addressing and its drawbacks. How do subnetting and CIDR overcome them? Divide 192.168.10.0/24 into four equal subnets, and aggregate 200.1.0.0/24, 200.1.1.0/24, 200.1.2.0/24 and 200.1.3.0/24 into one route. 10 marks
Model answer

An IPv4 address is a 32-bit number written in dotted decimal, for example 192.168.10.5. It has a network part (the prefix) and a host part.

Classful addressing

In the original scheme, the leading bits fixed the prefix length:

  • Class A: leading bit 0, first octet 1–126, /8, 2^24 − 2 = 16,777,214 hosts
  • Class B: leading bits 10, first octet 128–191, /16, 2^16 − 2 = 65,534 hosts
  • Class C: leading bits 110, first octet 192–223, /24, 2^8 − 2 = 254 hosts
  • Class D: leading bits 1110, 224–239, multicast
  • Class E: leading bits 1111, 240–255, reserved

This scheme has three drawbacks:

  • Block sizes jump in large steps. An organisation needing 2000 hosts must take a class B and wastes over 63,000 addresses.
  • Class B space is used up quickly.
  • Every network needs its own entry in core routing tables.

Subnetting

Inside an organisation, some host bits are borrowed to create subnets. The subnet mask has 1s over the network and subnet bits, while outside routers still see a single network.

Problem 1: divide 192.168.10.0/24 into four equal subnets.

  • Step 1: 4 = 2^2, so borrow 2 bits. The new prefix is /26 and the mask is 255.255.255.192.
  • Step 2: block size = 2^(32−26) = 64 addresses, so usable hosts = 64 − 2 = 62.
  • Step 3: list the subnets.
  • Subnet 1: 192.168.10.0/26, hosts .1–.62, broadcast .63
  • Subnet 2: 192.168.10.64/26, hosts .65–.126, broadcast .127
  • Subnet 3: 192.168.10.128/26, hosts .129–.190, broadcast .191
  • Subnet 4: 192.168.10.192/26, hosts .193–.254, broadcast .255

CIDR (Classless Inter-Domain Routing)

CIDR removes the classes. A block of any power-of-two size is allocated and written as a.b.c.d/x. Blocks can match real needs, and adjacent blocks can be aggregated into one routing entry.

Problem 2: aggregate the four /24 routes.

  • Step 1: write the third octets in binary: 00000000, 00000001, 00000010, 00000011.
  • Step 2: the first six bits are identical, so the common prefix is 8 + 8 + 6 = 22 bits.
  • Step 3: the aggregate route is 200.1.0.0/22 (mask 255.255.252.0). It covers 2^10 = 1024 addresses, exactly the four /24 blocks.

Longest prefix match: suppose a router has 200.1.0.0/22 → line A and 200.1.2.0/24 → line B. A packet for 200.1.2.5 matches both entries, but /24 is the longer prefix, so the packet leaves on line B.

In conclusion, subnetting splits one block internally, while CIDR allocates and aggregates blocks of any size. Together they slow address exhaustion and keep routing tables small.

Unit 5

Transport and Application Layers

Syllabus: Transport layer services and port numbers; UDP: user datagrams, services and applications; TCP services and features; TCP segment; A TCP connection; Windows in TCP; TCP flow control and error control; Congestion control in TCP; World Wide Web and HTTP; Electronic mail: architecture, web-based mail and email security; TELNET: local versus remote logging; Domain Name System

One-page revision summary

  • The transport layer provides process-to-process delivery using port numbers, with multiplexing, demultiplexing, flow, error and congestion control, and a socket address is an IP address plus a port number, the client normally using a temporary (ephemeral) port.
  • UDP is connectionless and unreliable, with an 8-byte header and no flow control, congestion control or acknowledgments, so it suits simple request/response programs such as DNS queries, real-time multimedia, multicasting, SNMP and RIP routing updates.
  • TCP gives a reliable, connection-oriented, full-duplex byte-stream service in which every byte is numbered, and its 20 to 60 byte header carries ports, sequence and acknowledgment numbers, HLEN, control flags, window, checksum and urgent pointer.
  • A TCP connection opens with a three-way handshake (SYN, SYN+ACK, ACK) and closes with FIN segments, and half-close is allowed.
  • The TCP send window equals min(rwnd, cwnd), and the receiver advertises rwnd for flow control.
  • TCP error control uses checksums, cumulative acknowledgments, retransmission on RTO timeout and fast retransmission after three duplicate ACKs.
  • TCP congestion control uses slow start, congestion avoidance and, in Reno, fast recovery, following AIMD, whereas Tahoe restarts slow start on every loss signal.
  • The Web uses URLs, HTML and HTTP over TCP port 80; HTTP is stateless so cookies keep state, HTTP/1.1 uses persistent connections by default, and proxy servers cache responses to cut traffic.
  • Email uses a UA to compose, an MTA with SMTP to push and an MAA with POP3 or IMAP4 to pull (web mail uses HTTP at both ends), while PGP and S/MIME add digital signatures and session-key encryption.
  • TELNET provides remote logging over TCP port 23 and, because hosts use different character sets, translates characters into Network Virtual Terminal (NVT) form: data characters are 7-bit ASCII with the top bit 0, and control characters, such as IAC (255), have the top bit 1.
  • TELNET options such as echo, binary transmission, terminal type and suppress go-ahead are negotiated with the commands WILL, WONT, DO and DONT, each sent after IAC, so a side can offer, refuse, request or forbid an option before using it.
  • At the client, keystrokes pass from the terminal driver to the TELNET client, which converts them to NVT and sends them over TCP; the TELNET server converts them back and gives them to a pseudoterminal driver, which hands them to the operating system as if typed locally, and output returns the same way in reverse.
  • DNS maps names to IP addresses using a hierarchical, inverted-tree name space with an unnamed root, up to 128 levels and labels of at most 63 characters, where a fully qualified domain name is read from the node up to the root and ends with a dot.
  • A domain is a subtree of the name space, and since one server cannot hold the whole tree, the space is divided into zones, each being the part of a domain for which one server is responsible and keeps a zone file.
  • Root servers do not keep all domain data but hold references to top-level domain servers, a primary server keeps the zone file on its disk and updates it, and a secondary server copies the zone file from the primary by zone transfer without changing it.
  • On the Internet the name space is split into generic domains (labels such as com, edu, gov, org, net), country domains (two-letter codes such as in, us, uk) and the inverse domain (in-addr.arpa) used to map an IP address back to a name.
  • DNS resolution can be recursive or iterative, caching with a time-to-live reduces repeated lookups, and DNS normally uses UDP port 53, switching to TCP for large responses and zone transfers.
  • Each resource record holds a domain name, type, class, time-to-live and value, and common types are A (IPv4), AAAA (IPv6), NS (name server), CNAME (alias), MX (mail exchanger), SOA (start of authority) and PTR (inverse lookup).
  • A DNS query or response message has a 12-byte header with identification, flags and counts of question, answer, authority and additional records, followed by the question, answer, authority and additional sections, a query carrying only the header and question.

Learn these by heart

  • Port ranges: well-known 0–1023, registered 1024–49151, dynamic 49152–65535; HTTP 80, SMTP 25, DNS 53, TELNET 23, POP3 110, IMAP4 143.
  • rwnd = receiver buffer size − bytes waiting in buffer; send window = min(rwnd, cwnd).
  • Three-way handshake: SYN(seq = x) → SYN+ACK(seq = y, ack = x + 1) → ACK(seq = x + 1, ack = y + 1).
  • Acknowledgment number = number of the next byte expected; last byte of a segment = sequence number + length − 1.
  • Header sizes: UDP 8 bytes fixed; TCP 20–60 bytes, HLEN in 4-byte words (5–15).
  • Slow start doubles cwnd each RTT up to ssthresh; congestion avoidance adds 1 MSS per RTT.
  • On a timeout: ssthresh = cwnd/2 and cwnd = 1. On three duplicate ACKs (Reno): ssthresh = cwnd/2 and cwnd = ssthresh + 3, then cwnd = ssthresh on a new ACK.
  • DNS limits: label up to 63 characters, tree up to 128 levels, message header 12 bytes; an FQDN ends with a dot, a PQDN does not.
  • TELNET: NVT data bytes have top bit 0, control bytes top bit 1; IAC = 255; WILL/WONT announce the sender's own option, DO/DONT ask the other side to enable or disable it.

2-mark questions

1 What is a port number? State the three ranges into which port numbers are divided. 2 marks
Model answer

A port number is a 16-bit identifier that lets the transport layer deliver data to the correct process on a host. The ranges are: well-known ports 0 to 1023 (assigned to standard servers), registered ports 1024 to 49151 (registered to avoid duplication), and dynamic or ephemeral ports 49152 to 65535 (used temporarily by clients).

2 List the fields of a UDP user datagram header and state its size. 2 marks
Model answer

The UDP header is a fixed 8 bytes with four 16-bit fields: source port number, destination port number, total length (header plus data, in bytes), and checksum. The checksum covers a pseudoheader, the header and the data. In IPv4 it is optional, and an all-zero value means it was not computed.

3 The first byte of a 1000-byte TCP segment is numbered 10001. Find the sequence number of the segment and the acknowledgment number the receiver returns after receiving it correctly. 2 marks
Model answer

The sequence number is the number of the first data byte, so it is 10001. The last byte is 10001 + 1000 − 1 = 11000. TCP acknowledges the next byte it expects, so the acknowledgment number is 11000 + 1 = 11001.

4 What is silly window syndrome in TCP? Give one remedy. 2 marks
Model answer

Silly window syndrome occurs when a sender creates data slowly or a receiver consumes data slowly, so only tiny segments are sent and header overhead dominates. Remedies: Nagle's algorithm at the sender groups small amounts of data; at the receiver, Clark's solution announces a zero window until enough space is free, or acknowledgments are delayed.

5 Differentiate between local logging and remote logging in TELNET. 2 marks
Model answer

In local logging a user logs into the system through a terminal attached directly to it, and the local operating system interprets the keystrokes. In remote logging a TELNET client sends keystrokes over the network, using NVT characters, to a TELNET server. The server passes them through a pseudoterminal driver to the remote operating system.

6 Distinguish between recursive and iterative resolution in DNS. 2 marks
Model answer

In recursive resolution the resolver asks one server, and that server queries other servers on the client's behalf until it can return the final answer. In iterative resolution a server that does not know the answer returns the address of the next server to ask, and the resolver itself queries each server in turn.

10-mark questions

1 Explain the services and features provided by TCP. Describe the format of a TCP segment and the purpose of each header field. 10 marks
Model answer

TCP is a connection-oriented, reliable transport protocol. It provides process-to-process communication between two application programs using port numbers.

Services and features of TCP:

  • Process-to-process communication: port numbers identify the sending and receiving processes.
  • Stream delivery service: data is treated as a stream of bytes, using sending and receiving buffers at the two ends.
  • Full-duplex communication: data flows in both directions at the same time.
  • Connection-oriented service: a logical connection is set up before data is sent and released afterwards.
  • Reliable service: acknowledgments, checksums and retransmission give error-free, in-order delivery.
  • Numbering system: every byte is numbered. The sequence number of a segment is the number of its first byte, and acknowledgments are cumulative.
  • Flow control and congestion control are done with windows.

Segment format: a segment has a header of 20 to 60 bytes followed by data from the application.

TCP segment format (original layout)Diagram in words: a rectangle 32 bits wide made of stacked rows. Row 1 holds Source port (16 bits) and Destination port (16 bits). Row 2 holds Sequence number (32 bits). Row 3 holds Acknowledgment number (32 bits). Row 4 holds HLEN (4 bits), Reserved (6 bits), the six control flags URG, ACK, PSH, RST, SYN, FIN, and Window size (16 bits). Row 5 holds Checksum (16 bits) and Urgent pointer (16 bits). Row 6 holds Options and padding (0 to 40 bytes). A Data block sits below the header.Header (20 to 60 bytes)Source port(16 bits)Destinationport (16 bits)Sequence number(32 bits)AcknowledgmentnumberHLEN (4 bits)Reserved(6 bits)URG ACK PSHRST SYN FINWindow size(16 bits)Checksum(16 bits)Urgent pointer(16 bits)Optionsand paddingData
TCP segment format (original layout)

Note on the current layout: the diagram shows the original layout. Later, Explicit Congestion Notification (RFC 3168) took two of the reserved bits as the flags CWR (congestion window reduced, sent by a sender that has cut its window) and ECE (ECN-echo, sent by a receiver to report congestion marked by a router). So present-day descriptions show HLEN (4 bits), Reserved (4 bits) and eight flags CWR, ECE, URG, ACK, PSH, RST, SYN, FIN. In both layouts these fields together take 16 bits, so the rest of the header is unchanged.

Purpose of the fields: 1. Source and destination port: identify the application processes at the two ends. 2. Sequence number: the number of the first data byte in the segment. During setup each side chooses a random initial sequence number (ISN). 3. Acknowledgment number: the next byte the sender of this segment expects to receive. It is valid only when ACK is set. 4. HLEN: header length in 4-byte words, from 5 (20 bytes) to 15 (60 bytes). 5. Control flags: URG means the urgent pointer is valid; ACK means the acknowledgment field is valid; PSH requests push; RST resets the connection; SYN synchronises sequence numbers; FIN ends the connection. In the current layout, CWR and ECE carry congestion signals as described above. 6. Window size: the receive window (rwnd) in bytes that the other side may send, up to 65,535 (larger with the window scale option). 7. Checksum: mandatory error detection over the pseudoheader, header and data. 8. Urgent pointer: added to the sequence number, it marks the end of urgent data. 9. Options: for example, maximum segment size, window scale, timestamp and SACK.

Conclusion: the rich TCP header, especially the sequence number, acknowledgment number, flags and window, is what lets TCP give reliable, flow-controlled byte-stream delivery over the unreliable IP layer.

2 Explain the three phases of a TCP connection: connection establishment by three-way handshaking, data transfer, and connection termination. Mention half-close and the SYN flooding attack. 10 marks
Model answer

TCP is connection-oriented. Every connection passes through three phases: establishment, data transfer and termination.

1. Connection establishment (three-way handshake). The server first does a passive open: it waits on a well-known port. The client then does an active open.

  • Step 1: the client sends a SYN segment with its initial sequence number, seq = x. It carries no data but consumes one sequence number.
  • Step 2: the server replies with a SYN + ACK segment: seq = y (its own ISN), ack = x + 1. It also announces the server's rwnd.
  • Step 3: the client sends an ACK segment: seq = x + 1, ack = y + 1. A pure ACK consumes no sequence number.

After this both sides know each other's ISN and window, and the connection is open.

TCP three-way handshake and data transferDiagram in words: two vertical time lines, Client on the left and Server on the right. Arrow 1 goes from Client to Server, labelled "SYN, seq = x". Arrow 2 goes from Server to Client, labelled "SYN + ACK, seq = y, ack = x + 1". Arrow 3 goes from Client to Server, labelled "ACK, seq = x + 1, ack = y + 1". Below these, arrows labelled "data" flow in both directions.ClientServerClient sends SYNServer replies,seq = yClient ACK,seq = x + 1Connection openClientsends dataServer receivesServersends dataClient receivesSYN, seq = xSYN + ACK,ack = x + 1ACK, ack= y + 1datadata
TCP three-way handshake and data transfer

2. Data transfer. Data flows in both directions. Acknowledgments are piggybacked on data segments. Each segment's sequence number is its first byte number, and the acknowledgment number is the next byte expected. Example: the client sends bytes 8001 to 9000 (seq = 8001), and the server answers with ack = 9001. The PSH flag asks the receiver to deliver data at once. The URG flag marks urgent data.

3. Connection termination.

  • Three-way: the client sends FIN (seq = u). The server replies FIN + ACK (ack = u + 1). The client sends a final ACK. A FIN segment consumes one sequence number, even when it carries no data.
  • Half-close: one side stops sending but keeps receiving. The client sends FIN and the server ACKs it. The server continues sending data, and the client keeps acknowledging. Later the server sends its own FIN and the client ACKs it. This is a four-segment exchange.
  • After the last ACK, the active closer waits in TIME-WAIT for 2 × MSL (maximum segment lifetime) so that a lost final ACK can be resent.

SYN flooding attack: an attacker sends many SYN segments with forged source addresses. The server allocates resources for each half-open connection and sends SYN + ACK replies that are never acknowledged. Its resources are exhausted, which is a denial of service. Defences include limiting connection requests and SYN cookies, where resources are allocated only after the final ACK arrives.

Conclusion: the handshake synchronises sequence numbers before any data flows, and orderly termination makes sure both directions are closed cleanly.

3 Explain how TCP performs flow control and error control using windows. Include a numerical example of computing the receive window. 10 marks
Model answer

TCP uses windows to control how much data may be outstanding. Flow control stops a fast sender from overflowing the receiver's buffer. Error control makes delivery reliable.

1. Windows in TCP.

  • Each direction has a send window at the sender and a receive window at the receiver. The windows are byte-oriented.
  • Send window size = min(rwnd, cwnd), where rwnd is announced by the receiver and cwnd is the congestion window.
  • The send window divides the sending buffer into four regions: bytes sent and acknowledged, bytes sent but not acknowledged, bytes that may be sent, and bytes that cannot yet be sent.
  • The window opens when the receiver announces more space, closes when acknowledgments move its left edge forward, and shrinks when rwnd decreases. Shrinking is discouraged.
TCP send window over the sending bufferDiagram in words: a horizontal row of numbered byte cells. A bracket marked "send window" covers two adjacent regions, "sent, not acknowledged" and "can be sent". To its left is a region marked "acknowledged". To its right is a region marked "cannot be sent". Arrow "close" moves the left wall to the right. Arrow "open" moves the right wall to the right.Send windowLeft wallRight wallAcknowledgedSent, notacknowledgedCan be sentCannot be sentcloseopen
TCP send window over the sending buffer

2. Flow control.

  • rwnd = receiver buffer size − number of bytes waiting in the buffer to be read by the process.
  • The receiver advertises rwnd in the window field of every segment.
  • Example: the buffer is 4000 bytes. 2500 bytes have arrived and the process has read 1000 of them. Bytes waiting = 2500 − 1000 = 1500, so rwnd = 4000 − 1500 = 2500 bytes. If cwnd = 3000, the send window = min(2500, 3000) = 2500 bytes.
  • If rwnd = 0 the sender stops and uses a persistence timer to send probe segments.

3. Error control.

  • Checksum: every segment carries a mandatory checksum. A corrupted segment is discarded.
  • Acknowledgment: cumulative ACKs give the next byte expected. Selective ACK (SACK) can report out-of-order blocks. ACK segments themselves are not acknowledged.
  • Retransmission after a timeout: if the retransmission timer (RTO), computed from smoothed RTT values, expires, the oldest unacknowledged segment is resent.
  • Fast retransmission: three duplicate ACKs mean a segment is missing, so it is resent at once without waiting for the timer.
  • Out-of-order segments are stored by the receiver, not discarded, and delivered in order once the gap is filled.
  • Duplicate segments are recognised by their sequence numbers and discarded.

Conclusion: the sliding window, governed by rwnd, provides flow control. Checksums, cumulative acknowledgments, timers and fast retransmission together provide error control, giving reliable in-order delivery.

4 Explain TCP congestion control: congestion window, slow start, congestion avoidance and fast recovery. Trace cwnd (in MSS) for ssthresh = 16, a timeout when cwnd = 20, and three duplicate ACKs later when cwnd = 12. 10 marks
Model answer

Congestion occurs when the load on the network exceeds its capacity. TCP controls it at the sender with a congestion window (cwnd), measured in MSS. The actual send window is min(rwnd, cwnd).

Congestion detection: a timeout signals severe congestion. Three duplicate ACKs signal mild congestion, because later segments are still getting through.

1. Slow start (exponential increase): cwnd starts at 1 MSS and increases by 1 MSS for every ACK received, so it doubles every RTT (1, 2, 4, 8 ...). This continues until cwnd reaches ssthresh. 2. Congestion avoidance (additive increase): beyond ssthresh, cwnd grows by 1 MSS per RTT. 3. Reaction to a timeout: ssthresh = cwnd / 2 and cwnd = 1, and slow start begins again. Tahoe TCP does this for both signals. 4. Fast recovery (Reno TCP) on three duplicate ACKs: ssthresh = cwnd / 2 and cwnd = ssthresh + 3. cwnd grows by 1 for each further duplicate ACK. When a new ACK arrives, cwnd = ssthresh and congestion avoidance continues.

This pattern of additive increase and multiplicative decrease is called AIMD.

Trace (values of cwnd per RTT):

  • RTT 1 to 5, slow start: 1, 2, 4, 8, 16. cwnd has reached ssthresh = 16.
  • RTT 6 to 9, congestion avoidance: 17, 18, 19, 20.
  • Timeout at cwnd = 20: ssthresh = 20 / 2 = 10 and cwnd = 1.
  • RTT 10 to 14, slow start: 1, 2, 4, 8, then 10. Doubling 8 would give 16, but growth is capped at ssthresh = 10.
  • RTT 15 to 16, congestion avoidance: 11, 12.
  • Three duplicate ACKs at cwnd = 12: ssthresh = 12 / 2 = 6 and cwnd = 6 + 3 = 9 (fast recovery).
  • A new ACK arrives: cwnd = ssthresh = 6. Congestion avoidance follows: 7, 8, 9 ...
TCP congestion control trace of cwnd (MSS) per RTTDiagram in words: a graph with the x-axis labelled "RTT" and the y-axis labelled "cwnd (MSS)". The curve rises exponentially from 1 to 16 (marked "slow start"), then linearly to 20 (marked "congestion avoidance"). It drops vertically to 1 at a point labelled "timeout, ssthresh = 10", rises exponentially to 10, then linearly to 12. It falls to 9 at a point labelled "3 dup ACKs, ssthresh = 6", then to 6, and rises linearly again. Horizontal dashed lines mark ssthresh = 16, 10 and 6.Slow start:cwnd 1 to 16Congestionavoidance: to 20Timeout,ssthresh = 10Slow start:cwnd 1 to 10Congestionavoidance: to 123 dup ACKs,ssthresh = 6Fast recovery:cwnd = 9cwnd =ssthresh = 6Congestionavoidance: 7, 8ssthresh = 16cwnd = 20cwnd = 1ssthresh = 10cwnd = 12cwnd = 6 + 3new ACK
TCP congestion control trace of cwnd (MSS) per RTT

Conclusion: by probing for bandwidth slowly and halving its rate on loss, TCP shares the network fairly and keeps it out of congestion collapse. Final result of the trace: the last ssthresh is 6, and congestion avoidance resumes from cwnd = 6.

5 Describe the architecture of electronic mail with the roles of UA, MTA and MAA. Explain web-based mail and the mechanisms used for email security. 10 marks
Model answer

Electronic mail is an asynchronous, one-way service. The sender and receiver need not be online at the same time, so the architecture relies on mail servers that hold messages.

1. Components.

  • User Agent (UA): composes, reads, replies to, forwards and stores messages. It may be command-driven or GUI-based. MIME extends the message so it can carry non-ASCII data such as images, audio and video.
  • Message Transfer Agent (MTA): pushes mail using SMTP on port 25. It is a client/server pair: an MTA client sends and an MTA server receives.
  • Message Access Agent (MAA): pulls mail from the receiver's mailbox using POP3 (port 110) or IMAP4 (port 143). IMAP allows folders, searching and partial download.

2. Typical scenario: Alice sends mail to Bob, and each has their own mail server.

  • Alice's UA hands the message to an MTA client, which pushes it to Alice's mail server (SMTP).
  • That server queues the message. Its MTA client pushes it across the Internet to the MTA server on Bob's mail server (SMTP), where it is placed in Bob's mailbox.
  • Bob's UA uses an MAA client to pull the message from the MAA server (POP3 or IMAP4).
Email architecture: Alice sends mail to BobDiagram in words: five boxes from left to right: "Alice UA", "Alice mail server (queue)", "Internet", "Bob mail server (mailbox)", "Bob UA". Arrow from Alice UA to Alice mail server, labelled "MTA, SMTP push". Arrow from Alice mail server through Internet to Bob mail server, labelled "MTA, SMTP push". Arrow from Bob mail server to Bob UA, labelled "MAA, POP3/IMAP4 pull".Alice UAAlice mailserver (queue)InternetBob mail server(mailbox)Bob UAMTA, SMTP pushMTA, SMTP pushMAA, POP3/IMAP4 pull
Email architecture: Alice sends mail to Bob

3. Web-based mail. The UA is a web browser.

  • Alice sends her message to her mail server using HTTP.
  • The message travels between the mail servers using SMTP.
  • Bob logs in to a website and retrieves his mail with HTTP. The server returns the mailbox as HTML pages.

4. Email security. Plain SMTP provides no confidentiality, so two protocols are widely used.

  • PGP (Pretty Good Privacy): the sender hashes the message and signs the digest with the sender's private key, giving authentication and integrity. It compresses the message, encrypts it with a one-time secret session key for confidentiality, and encrypts that session key with the receiver's public key. Trust in keys is built through a web of trust.
  • S/MIME: adds similar signing and encryption services to MIME using new content types. It relies on X.509 certificates issued by certificate authorities.
  • Both provide confidentiality, integrity, sender authentication and non-repudiation.

Conclusion: email uses SMTP to push messages between servers and POP3 or IMAP4 (or HTTP in web mail) to pull them to users. PGP and S/MIME add the security that the basic protocols lack.

6 Explain the architecture of the World Wide Web and the working of HTTP, including URLs, persistent and nonpersistent connections, request and response message formats, cookies and proxy servers. 10 marks
Model answer

The World Wide Web is a distributed client/server service. A browser retrieves web pages stored on servers around the Internet, and the pages are linked by hypertext.

1. Architecture.

  • A browser has a controller, client protocols (HTTP, FTP and others) and interpreters (HTML, JavaScript).
  • Each page is located by a URL with four parts: protocol, host, port and path. Example: http://www.example.com:80/notes/cn.html.
  • Pages may be static (fixed files), dynamic (created by the server when requested) or active (programs run in the browser).

2. HTTP basics. HTTP is a stateless request/response protocol that runs over TCP on port 80. The client opens a TCP connection, sends a request and receives a response.

3. Nonpersistent versus persistent connections.

  • Nonpersistent: one TCP connection is opened for each object and closed after the response.
  • Persistent: the server keeps the connection open for further requests. This is the default in HTTP/1.1.
  • Example: a page with 10 images has 11 objects. Nonpersistent mode needs 11 connections, about 2 RTT each (setup plus request/response), so about 22 RTT plus transmission time. Persistent mode without pipelining needs 1 RTT for setup plus 11 RTT, so about 12 RTT.

4. Request message.

  • Request line: method, URL and version, for example "GET /index.html HTTP/1.1".
  • Header lines, such as Host, User-Agent, Accept and Cookie.
  • A blank line.
  • An optional body, used by POST and PUT.
  • Methods: GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT and OPTIONS.

5. Response message.

  • Status line: version, status code and phrase, for example "HTTP/1.1 200 OK".
  • Headers, such as Date, Server, Content-Type, Content-Length and Set-Cookie.
  • A blank line, followed by the body.
  • Status code classes: 1xx informational, 2xx success, 3xx redirection (301 Moved Permanently), 4xx client error (404 Not Found), 5xx server error (500 Internal Server Error).
HTTP request and response between client and serverDiagram in words: two boxes, "Client (browser)" on the left and "Server" on the right. Arrow from Client to Server labelled "Request: request line, headers, blank line, body". Arrow from Server to Client labelled "Response: status line, headers, blank line, body".Client (browser)ServerRequestmessageResponsemessage
HTTP request and response between client and server

6. Cookies. Because HTTP is stateless, a server that wants to remember a client creates a cookie. It stores the cookie in its database and sends it in a Set-Cookie header. The browser stores the cookie and returns it in a Cookie header on later requests. Cookies support shopping carts, logins and personalisation.

7. Proxy server. A proxy server keeps copies of recently requested responses. Requests are sent first to the proxy, and it contacts the original server only on a cache miss. This lowers load, traffic and latency, and conditional GET keeps copies fresh.

Conclusion: the Web combines URLs, HTML and HTTP. Persistent connections, cookies and proxy caching make this stateless protocol efficient and practical.

Public sources that settled doubtful points

Only the points the second AI pass doubted were looked up. These are the pages that confirmed or contradicted them; nothing here is copied from them.

16 pages

Further reading

Titles only, for your own study. Nothing on this page is copied from them. The units follow the official JNTUK R23 CSE syllabus (PDF) ↗.

  • Computer Networks · Andrew S. Tanenbaum
  • Data Communications and Networking · Behrouz A. Forouzan
  • Data Communications and Networks · Achyut S. Godbole and Atul Kahate