# How many IP packets are sent for a smartphone image?

## Problem

Let's say, my image file has a size of 2 megabytes. It is sent over TCP/IP/Ethernet.

I want to know roughly how many IP packets are sent.

The purpose of this example is to get better intuition/understanding.

## Calculation 1

So, the Maximum Segment Size is 1460 (= 1500 - 20 -20) bytes.

Number of IP packets:

2,000,000 bytes / 1,460 bytes = 1,369.86...

So, 1370 IP packets are sent.

## Calculation 2

The maximum possible IP packet size is 65,535 bytes. If fragmentation is used in the Ethernet header, the number of IP packets could be lower.

Alternative size of IP packet: 60,000 bytes

2,000,000 / 60,000 = 33.33...

In this case, 34 packets would be sent. However, there would be computation overhead for fragmentation, because Ethernet only accepts a payload of 1,500 bytes.

## Question

I would have expected way fewer IP packets for an image file.

Which of the two calculations is more reasonable?

Fragmentation is only done when the MTU changes along the path. With two Ethernet clients and no bottleneck in between, the standard MTU over Ethernet of 1500 bytes is used, resulting in a maximum TCP payload of 1460 bytes. Accordingly, your calculation 1 is correct. Calculation 2 is technically possible but requires an ignorant source node.

Fragmentation is inefficient and may cause stress on the router doing the fragmentation, so everyone tries to avoid it. Fragmentation within the path (=on an intermediate router) has even been completely removed from IPv6 (by requiring using path MTU discovery).

You need to distinguish IP packets from Ethernet frames.

I didn't check the math (sounds good at quick glance) but the fact is that you sent 34 IP packets of size 65,535 bytes (except the last which is smaller), and each of this IP packets is divided and sent in around 40 frames, ending in a total of 1370 frames.

And if a lower MTU is encountered along the path each frame may be further divided and the receiver may get 2740 frames/fragments for example.

Those 2740 fragments are reassembled to 1370 frames and the content is extracted and reassembled into the original 34 IP packets.