Networking 05 — Inside IPv4: The Header, Options, Fragmentation, TTL and Routing
Field by field through the IPv4 header, how fragments are cut and reassembled, why TTL exists, and how routers choose a path.
These notes began as two handwritten notebooks for COM 3401 — Data Communication and Networking at Rajarata University. I OCR'd them, rewrote them in English, and paired every section with a Sinhala explanation so the concept comes first and the English terms stay intact for the exam. Diagrams are redrawn as vector graphics.
The IPv4 Header
අයිපීවී4 ශීර්ෂකය
The IP header has a fixed part of 20 bytes and a variable options part of up to 40 bytes, so the maximum header size is 60 bytes and the minimum is 20 bytes.
සිංහලෙන්: IP ශීර්ෂයට බයිට් 20 ක ස්ථාවර කොටසක් සහ බයිට් 40 දක්වා විචල්ය විකල්ප කොටසක් ඇත, එබැවින් උපරිම ශීර්ෂ ප්රමාණය බයිට් 60 ක් වන අතර අවමය බයිට් 20 කි.
IPv4 header — 20 fixed bytes + up to 40 option bytes
- Version is four bits and indicates whether the packet is IPv4 or IPv6.
- Header length is four bits. Because four bits can only count from 0 to 15, the value is stored in units of four bytes. So the actual header length divided by four gives the value in the packet.
- Type of service carries priority, delay, throughput and reliability preferences. Based on priority the packet is transferred to an intermediate router. More routers means more delay, and fewer routers means less delay. Cost is calculated considering bandwidth, number of routers, error rate and the distance among the routers. Reliability represents the error rate, and throughput depends on the bandwidth.
- The sixteen bit datagram length gives a maximum total packet size of 64 kilobytes.
- The sixteen bit datagram number is a sequence number. Every datagram is associated with a sequence number starting with zero.
- MF means more fragments and DF means do not fragment.
- The offset indicates the number of data bytes ahead of this fragment in that particular packet. Because the offset field is only thirteen bits, it is stored in units of eight bytes, which is why the constant scale factor is eight.
- The header checksum is carried out at every router and only over the header, not over the data.
සිංහලෙන්: අනුවාදය බිටු හතරක් වන අතර පැකට්ටුව IPv4 ද IPv6 ද යන්න පෙන්නුම් කරයි.ශීර්ෂයේ දිග බිටු හතරකි. බිටු හතරකට ගණන් කළ හැක්කේ 0 සිට 15 දක්වා පමණක් බැවින්, අගය බයිට් හතරක ඒකකවල ගබඩා වේ. එබැවින් සැබෑ ශීර්ෂ දිග හතරෙන් බෙදූ විට පැකට්ටුවේ අගය ලබා දෙයි.සේවා වර්ගය ප්රමුඛතාවය, ප්රමාදය, ප්රතිදානය සහ විශ්වාසනීය මනාපයන් දරයි. ප්රමුඛතාවය මත පදනම්ව පැකට්ටුව අතරමැදි රවුටරයකට මාරු කරනු ලැබේ. වැඩි රවුටර යනු වැඩි ප්රමාදයක් වන අතර, රවුටර අඩු නම් ප්රමාදය අඩු වේ. කලාප පළල, රවුටර ගණන, දෝෂ අනුපාතය සහ රවුටර අතර ඇති දුර සැලකිල්ලට ගනිමින් පිරිවැය ගණනය කෙරේ. විශ්වසනීයත්වය දෝෂ අනුපාතය නියෝජනය කරයි, සහ ප්රතිදානය කලාප පළල මත රඳා පවතී.බිට් දහසය දත්ත ග්රෑම් දිග උපරිම සම්පූර්ණ පැකට් ප්රමාණය කිලෝබයිට් 64 ක් ලබා දෙයි.දහසය බිට් දත්ත ග්රෑම් අංකය අනුක්රමික අංකයකි. සෑම දත්ත ග්රෑම් එකක්ම ශුන්යයෙන් ආරම්භ වන අනුක්රමික අංකයක් සමඟ සම්බන්ධ වේ.MF යන්නෙන් අදහස් කරන්නේ වැඩිපුර කොටස් සහ DF යන්නෙන් අදහස් කරන්නේ කැබලි නොකරන්න.ඕෆ්සෙට් එකෙන් පෙන්නුම් කරන්නේ එම පැකට්ටුවේ ඇති මෙම කොටසට ඉදිරියෙන් ඇති දත්ත බයිට් ගණනයි. ඕෆ්සෙට් ක්ෂේත්රය බිටු දහතුනක් පමණක් වන නිසා, එය බයිට් අටක ඒකකවල ගබඩා කර ඇත, එබැවින් නියත පරිමාණ සාධකය අටක් වේ.ශීර්ෂ පිරික්සුම සෑම රවුටරයකම සිදු කරනු ලබන අතර දත්ත මත නොව ශීර්ෂය හරහා පමණක් සිදු කෙරේ.
IP Options
අයිපී විකල්ප
- Strict source routing: each and every route is specified by the source.
- Loose source routing: only the important routers are specified, and the route is generated based upon those routers. This is the practical one.
- Record routing: the router decides the route and each router records itself in the packet.
- Time stamp: the arrival time and the departure time of each and every packet is stored.
- Security: mails are sent along with a certification which provides secured access for a page.
සිංහලෙන්: දැඩි මූලාශ්ර මාර්ගගත කිරීම: සෑම මාර්ගයක්ම මූලාශ්රය මගින් නියම කර ඇත.ලිහිල් මූලාශ්ර මාර්ගගත කිරීම: වැදගත්රවුටර පමණක් සඳහන් කර ඇති අතර, එම රවුටර මත පදනම්ව මාර්ගය ජනනය වේ. මේක තමයි ප්රායෝගික එක.වාර්තා මාර්ගගත කිරීම: රවුටරය මාර්ගය තීරණය කරන අතර සෑම රවුටරයක්ම පැකට්ටුවේ සටහන් වේ.කාල මුද්දරය: සෑම පැකට්ටුවකම පැමිණීමේ වේලාව සහ පිටත්වීමේ වේලාව ගබඩා කර ඇත.ආරක්ෂාව: පිටුවක් සඳහා ආරක්ෂිත ප්රවේශයක් සපයන සහතිකයක් සමඟ තැපැල් යවනු ලැබේ.
Strict source routing and loose source routing must be available in all the fragments, while record routing and time stamp are necessary in any one of the fragments only.
සිංහලෙන්: දැඩි මූලාශ්ර මාර්ගගත කිරීම සහ ලිහිල් මූලාශ්ර මාර්ගගත කිරීම සියලුම කොටස්වල තිබිය යුතු අතර, වාර්තා මාර්ගගත කිරීම සහ කාල මුද්රාව අවශ්ය වන්නේ ඕනෑම කොටසක පමණි.
Fragmentation and Reassembly
ෆ්රැග්මන්ටේෂන් සහ ප්රතිසංයෝජනය
The maximum transfer unit is the largest packet a particular link can carry. If a datagram is larger than the MTU of the next link, the router splits it into fragments. Fragmentation is applicable only to the datagram and not to the header, which is copied into each fragment.
සිංහලෙන්: උපරිම හුවමාරු ඒකකය යනු විශේෂිත සබැඳියකට ගෙන යා හැකි විශාලතම පැකට්ටුවයි. Datagram එකක් මීළඟ සබැඳියේ MTU ට වඩා විශාල නම්, රවුටරය එය කොටස් වලට බෙදයි. ඛණ්ඩනය අදාළ වන්නේ එක් එක් ඛණ්ඩනයට පිටපත් කරන ලද ශීර්ෂයට නොව දත්ත ග්රාමයට පමණි.
Fragmentation at an MTU of 200
Fragment data must be divisible by eight. If it is not, you adjust the number downwards so that it is divisible by eight. This rule is applicable for all the fragments except for the last fragment.
සිංහලෙන්: කොටස් දත්ත අටකින් බෙදිය යුතුය. එය එසේ නොවේ නම්, ඔබ සංඛ්යාව අටකින් බෙදිය හැකි පරිදි පහළට සකසන්න. මෙම නියමය අවසාන කොටස හැර අනෙකුත් සියලුම කොටස් සඳහා අදාළ වේ.
For example, if a packet carries 600 bytes of data plus a 20 byte header and the MTU is 200, then each fragment can carry 180 bytes of payload, but 180 is not divisible by 8, so each fragment carries 176 bytes and the last one carries the remainder of 72 bytes. The offsets are then 0, 22, 44 and 66, because the offset is counted in units of eight bytes.
සිංහලෙන්: උදාහරණයක් ලෙස, පැකට්ටුවක දත්ත බයිට් 600ක් සහ බයිට් 20ක ශීර්ෂයක් සහ MTU 200 නම්, එක් එක් කැබැල්ලකට බයිට් 180ක් ගෙවිය හැකි නමුත්, 180ක් 8න් බෙදිය නොහැක, එම නිසා සෑම කැබැල්ලකටම බයිට් 176ක් ද, අවසාන එක බයිට් 72ක ඉතිරි කොටසද රැගෙන යයි. එවිට ඕෆ්සෙට් 0, 22, 44 සහ 66 වේ, මන්ද ඕෆ්සෙට් එක බයිට් අටක ඒකක වලින් ගණනය කෙරේ.
The reassembly algorithm at the destination works as follows. Classify fragments based on the sixteen bit datagram number. Identify the fragment with offset equal to zero and designate it as the first fragment. Identify the fragment with MF equal to zero and designate it as the last fragment. Identify the data length in the first fragment and look for the fragment with the same offset value and designate it as the second fragment. Repeat the previous step as many times as possible to cover all the fragments.
සිංහලෙන්: ගමනාන්තයේ නැවත එකලස් කිරීමේ ඇල්ගොරිතම පහත පරිදි ක්රියා කරයි. දහසය බිට් දත්ත ග්රෑම් අංකය මත පදනම්ව කොටස් වර්ග කරන්න. ශුන්යයට සමාන ඕෆ්සෙට් සහිත කොටස හඳුනාගෙන එය පළමු කොටස ලෙස නම් කරන්න. ශුන්යයට සමාන MF සහිත කොටස හඳුනාගෙන එය අවසාන කොටස ලෙස නම් කරන්න. පළමු ඛණ්ඩයේ දත්ත දිග හඳුනාගෙන එම ඕෆ්සෙට් අගයම ඇති කොටස සොයා දෙවන කොටස ලෙස නම් කරන්න. සියලුම කොටස් ආවරණය කිරීම සඳහා පෙර පියවර හැකි තරම් වාර ගණනක් නැවත කරන්න.
If both the offset and MF are zero, the packet is the original unfragmented packet. If any one of them is non zero, it is a fragment.
සිංහලෙන්: ඕෆ්සෙට් සහ එම්එෆ් දෙකම ශුන්ය නම්, පැකට්ටුව මුල් නොකැඩූ පැකට්ටුව වේ. ඒවායින් එකක් ශුන්ය නොවන නම්, එය ඛණ්ඩනයකි.
Time To Live
ටයිම් ටු ලිව්
The time to live field is decremented by every router the packet passes through, and when it reaches zero the packet is discarded and an ICMP message is sent back to the source. It has four applications.
සිංහලෙන්: පැකට්ටුව ගමන් කරන සෑම රවුටරයක්ම සජීවී ක්ෂේත්රය සඳහා වන කාලය අඩු වන අතර, එය බිංදුවට ළඟා වූ විට පැකට්ටුව ඉවත දමනු ලබන අතර ICMP පණිවිඩයක් මූලාශ්රය වෙත ආපසු යවනු ලැබේ. එහි යෙදුම් හතරක් ඇත.
- To avoid infinite looping of packets in the network.
- To identify the number of routers between the source and the destination.
- To debug the network, which is exactly how the traceroute tool works.
- To help the upper layer in timer management.
සිංහලෙන්: ජාලය තුළ පැකට් අසීමිත ලූප වළක්වා ගැනීමට.මූලාශ්රය සහ ගමනාන්තය අතර රවුටර ගණන හඳුනා ගැනීමට.traceroute මෙවලම හරියටම ක්රියා කරන ආකාරය වන ජාලය නිදොස් කිරීමට.ටයිමර් කළමනාකරණයේ ඉහළ ස්ථරයට උපකාර කිරීමට.
Routing
රවුටින්
Routing is a process that is performed by network layer devices in order to deliver the packets by choosing an optimal path from one network to another. All the information needed for a router to forward packets to a hop can be found in the router's routing table.
සිංහලෙන්: මාර්ගගත කිරීම යනු එක් ජාලයකින් තවත් ජාලයකට ප්රශස්ත මාර්ගයක් තෝරා ගැනීමෙන් පැකට් බෙදා හැරීම සඳහා ජාල ස්ථර උපාංග මඟින් සිදු කරන ක්රියාවලියකි. රවුටරයකට පැකට් හොප් එකකට යොමු කිරීමට අවශ්ය සියලුම තොරතුරු රවුටරයේ රවුටින් වගුවෙන් සොයාගත හැකිය.
Static routing occurs when you manually add a route in each router's routing table. Dynamic routing is the process of using protocols to find and update routing tables on routers and to maintain a loop free single path to each network.
සිංහලෙන්: ඔබ එක් එක්රවුටරයේ රවුටින් වගුවෙහි ඔබ අතින් මාර්ගයක් එක් කරන විට ස්ථිතික මාර්ගගත කිරීම සිදුවේ. ඩයිනමික්රවුටින් යනු රවුටරවල රවුටර වගු සොයා ගැනීමට සහ යාවත්කාලීන කිරීමට සහ එක් එක් ජාලයට ලූප රහිත තනි මාර්ගයක් පවත්වා ගැනීමට ප්රොටෝකෝල භාවිතා කිරීමේ ක්රියාවලියයි.
The common fields in a routing table are the mask, the network address, the next hop address, the interface and the flags. The flags are U for up, G for gateway, H for host specific, D for added by redirection and M for modified by redirection.
සිංහලෙන්: රවුටින් වගුවක ඇති පොදු ක්ෂේත්ර වන්නේ වෙස්මුහුණ, ජාල ලිපිනය, මීළඟ හොප් ලිපිනය, අතුරු මුහුණත සහ කොඩි වේ. කොඩි වන්නේ U සඳහා ඉහළ, G සඳහා Gateway, H සඳහා H සඳහා විශේෂිත, යළි-යොමු කිරීම් මගින් එකතු කිරීම සඳහා D සහ යළි-යොමුවීම් මගින් වෙනස් කරන ලද M සඳහා.
- Unicast delivers a message to a single specified node.
- Broadcast delivers a message to all nodes in the network.
- Multicast delivers a message to a group of nodes that have expressed interest in receiving the message.
සිංහලෙන්: යුනිකාස්ට් තනි නිශ්චිත නෝඩයකට පණිවිඩයක් ලබා දෙයි.විකාශනය ජාලයේ සියලුම නෝඩ් වෙත පණිවිඩයක් ලබා දෙයි.Multicast පණිවිඩය ලැබීමට කැමැත්ත පළ කර ඇති නෝඩ් සමූහයකට පණිවිඩයක් ලබා දෙයි.
The control plane is that part of a network that controls how data packets are forwarded. For example, the process of creating a routing table is considered part of the control plane.
සිංහලෙන්: පාලන තලය යනු දත්ත පැකට් ඉදිරියට යවන ආකාරය පාලනය කරන ජාලයක කොටසකි. උදාහරණයක් ලෙස, මාර්ගගත වගුවක් නිර්මාණය කිරීමේ ක්රියාවලිය පාලන තලයේ කොටසක් ලෙස සැලකේ.
An autonomous system is a group of networks and routers under the authority of a single administration. Routing inside an autonomous system is called intradomain routing and routing between autonomous systems is called interdomain routing.
සිංහලෙන්: ස්වයංක්රීය පද්ධතියක් යනු තනි පරිපාලනයක අධිකාරිය යටතේ ඇති ජාල සහ රවුටර සමූහයකි. ස්වයංක්රීය පද්ධතියක් තුළ මාර්ගගත කිරීම අභ්යන්තර ඩොමේන්රවුටිං ලෙසද ස්වයංක්රීය පද්ධති අතර මාර්ගගත කිරීම අන්තර් ඩොමේන්රවුටින් ලෙසද හැඳින්වේ.
Routing protocol families
Intradomain routing protocols are of two kinds. Distance vector routing is used by RIP and link state routing is used by OSPF. Interdomain routing uses path vector routing, which is used by BGP.
සිංහලෙන්: Intradomain routing protocols වර්ග දෙකකි. දුරස්ථ දෛශික රවුටිං RIP විසින් භාවිතා කරන අතර සබැඳි රාජ්ය මාර්ගගත කිරීම OSPF විසින් භාවිතා කරයි. Interdomain routing භාවිතා කරන්නේ path vector routing, එය BGP විසින් භාවිතා කරයි.
Keep going: ← Previous chapter · Next chapter → · Networking stage in the Self Guide
Finished this one?
Part of Self Guide · Stage 2: Networking fundamentals. Progress is saved in this browser.
Projects in this lesson

Education
Data Communication & Computer Networking Hub
Interactive TCP/IP model simulator, network design workbook, and bilingual Sinhala networking knowledge portal.

Education
AI Network Labs
A free course, graded labs and a 40-device campus capstone built around cisco-pt-mcp — the open-source MCP server for Cisco Packet Tracer by Muhammad Balawal.