title: IP Fragmentation and Reassembly
body: <p>I am currently going through my networking slides and was wondering if someone could help me with the concept of fragmentation and reassembly.</p>
  
  <p><img src="https://i.stack.imgur.com/0XaEs.png" alt="enter image description here"></p>
  
  <p>I understand how it works, namely how datagrams are split into smaller chunks because network links have a MTU. However the example in the picture is confusing me.</p>
  
  <p>So the first two sections show a length of 1500, because this is the MSU, but shouldn't this mean that the last one should have 1000 (for a total of 4000 bytes) and not 1040? Where did these extra 40 bytes come from? My guess is that because the previous two fragments both had a header of 20 bytes, this extra 40 bytes of data needed to go somewhere, so it will arrive in the last fragment?</p>
  
  <p>Fragflag essentially means that there is another fragment, so all of them will have a Fragflag of 1 except the last fragment which will be at zero. However I don't understand what offset is or how it is calculated. Why is the first offset at zero? Why did we divide the bytes in the datafield (1480) by 8 to get the second offset? Where did this 8 come from? Aside from that, I am assuming that each fragments offset will just increase by this value?</p>
  
  <p>For example, the first fragment will have a offset of 0, the second 185, the third 370 and the fourth 555? (370+185)</p>
  
  <p>Thanks for any help!</p>