title: How is data divided into packets?
body: <p>Hi sorry if this is a stupid question (I just started learning network programming), but I've been looking all over google about how files/data are divided into packets. I've read everywhere that somehow files are broken up into packets have headers/footers applied as they go through the OSI model and are sent through the wire where the recipient basically does the reverse and removes the headers.</p>
  
  <p>My question is how exactly are files/data broken up into packets and how are they reassembled at the other end? </p>
  
  <p>How does whatever doing the reassembling know when the last packet of the data has arrived and etc? </p>
  
  <p>Is it possible to reassemble packets captured from another machine? And if so how?</p>
  
  <p>(Also if it means anything I'm mostly interested in how this work for TCP type packets) </p>
  
  <p>I also have some packets captured from an application on my computer through WireShark, they're labeled as TCP protocol, what I want to do is reassemble them back into the original data, but how can you tell which packets belong to which set of data? </p>
  
  <p>Any pointers towards resources is much appreciated, thank you!</p>