# Maximum file size for TCP

## dE_logics

I was wondering that the sequence number part of the header is limited to 32 bits, that means it can store only ~4 billion packet number... so what happens after all these numbers has been utilized?... i.e a unique number cannot be generated within the 32 bit limit. So if I have to transfer a single very large file with has to be split to for e.g. 6 billion packets, then is this possible using the TCP protocol?

----------

## Sadako

Oh, you again.  :Razz: 

The tcp sequence numbers loop around, if the "maximum" value is used then the next value should be 0.

Two things to point out, the initial sequence number need not be 0, in fact it should be completely random, therefore it could even be the last available number (2^32), and they are per connection, so for one single connection to use up all available sequence numbers and loop around to whatever it's initial value was, you are talking about a transfer of 10's of terabytes...

----------

## dE_logics

Ok, got that. Thanks for the info.

----------

## John R. Graham

Well, not exactly.  Sequence numbers count data bytes, not packet numbers, so the amount of data transferred before a sequence number wrap is exactly 4TiB.  However, sequence numbers are not required not to wrap.  They just need to not wrap while the data is still in transit.  This is can become problematic on networks where  very high data rates meet relatively high latencies but work is being done to address the issues.  See RFC #1323.

In practice, on networks that we are likely to encounter, it's a non-issue.  And there's no limit on the number  of bytes that can be transferred in a single intact TCP/IP session.

- John

----------

## Sadako

 *John R. Graham wrote:*   

> Sequence numbers count data bytes, not packet numbers

 Poop...

It's been a while since I covered this stuff, getting rusty.

----------

## John R. Graham

When I went to work for Cisco, I thought I knew a fair amount about networks.  Now, 4 years in, I'm much more aware of my own ignorance.   :Razz: 

- John

----------

## dE_logics

 *Quote:*   

> Sequence numbers count data bytes

 

That means a sequence number might contain 1.5 packets?

----------

## papahuhn

 *dE_logics wrote:*   

>  *Quote:*   Sequence numbers count data bytes 
> 
> That means a sequence number might contain 1.5 packets?

 

What do you mean by contain? Btw. it's 4GiB not 4TiB.

----------

## John R. Graham

Of course, you're correct.  You know, I almost wrote 2**32, but then I got fancy and mis-converted in my head.  Thanks for the clarification.

 *dE_logics wrote:*   

> That means a sequence number might contain 1.5 packets?

 Nope, since packets always contain an integral number of payload data bytes.

- John

----------

## dE_logics

 :Confused:  This appears confusing...

----------

## John R. Graham

So, ask a question.    :Wink: 

- John

----------

## dE_logics

Anyway, I don't need that much of details... the standards keep changing. However this wont I guess.

----------

## John R. Graham

You're right:  the handling of the Sequence Number in the TCP header is today still essentially the same as defined in RFC 675, dated December 1974.

- John

JRG:  Edited out one incorrect statement. 

----------

## oRDeX

 *John R. Graham wrote:*   

> In IPv4, I guess you're right:  the handling of the Sequence Number in the TCP header is today still essentially the same as defined in RFC 675, dated December 1974.  However, the IPv6 TCP header doesn't even contain a sequence number.  Change is coming.   
> 
> - John

 

?? Should the TCP header be the same either on IPv4 or IPv6?!

----------

## John R. Graham

Sorry; you're right.  Taking the opportunity to edit out one silly statement from my previous post.

- John

----------

