Vous êtes sur la page 1sur 13

# TCP sequence numbers

Numbering is as follows: Suppose that the first sequence number is 8000, and we are sending 3000 octets of data. In the opposite direction, the first sequence number is 15000 and 2000 octets are to be sent.

## 8001 8000 8002

SYN

11001

11000
... data ... FIN

Any message not including any of the above do not use any sequence numbers In particular, ACK-only messages, including those sent for connection or disconnection cannot use up sequence numbers.

## TCP connection sequence numbers

SYN: carries no data consumes 1 sequence number example: SYN; seq = 8000, ack = 0 SYN + ACK: carries no data consumes 1 sequence number example: SYN + ACK; seq = 15000, ack = 8001 ack increases by 1 to acknowledge SYN in opposite direction. ACK: if no data carried, no sequence number consumed in the forward direction ack increases by 1 to acknowledge SYN in opposite direction. example: ACK; seq = 8000, ack = 15001 First data, from initiating host: seq = 8001 First data, from receiving host: seq = 15001

## TCP simultaneous disconnect sequence numbers

FIN: if no data carried, consumes 1 sequence number but carrying data is allowed example (no data): FIN; seq = 11001, ack = 17001 FIN + ACK: carries no data consumes 1 sequence number example: FIN + ACK; seq = 17001, ack = 11002 ack increases by 1 to acknowledge FIN in opposite direction. ACK: no data carried, so no sequence number consumed in the forward direction ack increases by 1 to acknowledge FIN in opposite direction. example: ACK; seq = 11001, ack = 17002

## TCP half-close sequence numbers (1)

FIN: if no data carried, consumes 1 sequence number but carrying data is allowed example: FIN; seq = 11001, ack = 16000 ACK: if no data carried, no sequence number consumed in the forward direction therefore, we have to re-use the previous sequence number so that there is no gap in sequence numbers used by data octets ack increases by 1 to acknowledge FIN in opposite direction. example: ACK; seq = 15999, ack = 11002

## TCP half-close sequence numbers (2)

Later on, when the other half closes... FIN: if no data carried, consumes 1 sequence number but carrying data is allowed and then example: FIN; seq = 17001, ack = 11002 ACK: if no data carried, no sequence number consumed in the forward direction therefore, we have to re-use the previous sequence number so that there is no gap in sequence numbers used by data octets ack increases by 1 to acknowledge FIN in opposite direction. example: ACK; seq = 11001, ack = 17002

## Determine routing table for B

Network 137.122.20.0 137.122.30.0 137.122.40.0 Next hop

137.122.50.0
137.122.60.0 137.122.70.0 137.122.80.0

## Determine routing table for B

Network 137.122.20.0 137.122.30.0 137.122.40.0 Next hop 137.122.40.1 137.122.40.1 local

137.122.50.0
137.122.60.0 137.122.70.0 137.122.80.0

local
137.122.40.1 local 137.122.70.2

## Use Bellman-Ford algorithm to find shortest paths from node A

6
B 3 5 A 4 C 5
Node Least cost after stage 1 Least cost after stage 2 Least cost after stage 3 Next hop

D 2

3 1 5

2
1 E

B C D E F

## Use Bellman-Ford algorithm to find shortest paths from node A

6
B 3 5 A 4 C 5
Node Least cost after stage 1 Least cost after stage 2 Least cost after stage 3 Next hop

D 2

3 1 5

2
1 E

B C D E F

3 4

10

## Use Bellman-Ford algorithm to find shortest paths from node A

6
B 3 5 A 4 C 5
Node Least cost after stage 1 Least cost after stage 2 Least cost after stage 3 Next hop

D 2

3 1 5

2
1 E

B C D E F

3 4

3 4

5
5 8

11

## Use Bellman-Ford algorithm to find shortest paths from node A

6
B 3 5 A 4 C 5
Node Least cost after stage 1 Least cost after stage 2 Least cost after stage 3 Next hop

D 2

3 1 5

2
1 E

B C D E F

3 4

3 4

3 4

5
5 8

5
5 6

12

## Use Bellman-Ford algorithm to find shortest paths from node A

6
B 3 5 A 4 C 5
Node Least cost after stage 1 Least cost after stage 2 Least cost after stage 3 Next hop

D 2

3 1 5

2
1 E

B C D E F

3 4

3 4

3 4

B C

5
5 8

5
5 6

C
B B

13