Você está na página 1de 7

Introduction:

Simulation is the imitation of some real thing available, state of affairs, or process. Simulation is used in
many

contexts,

such

as

of technology for

simulation

performance

optimization, safety

engineering, testing, training, education, and video games.


There are four basic steps in simulation of communication networks:
i)
ii)
iii)
iv)

Model the network by specifying important parameters


Identify data to be collected
Run the simulations and collect statistics
Post-simulation: To view and analyze results

The Transmission Control Protocol (TCP) is one of the core protocols of the Internet Protocol

Suite. TCP is one of the two original components of the suite, complementing the Internet
Protocol (IP), and therefore the entire suite is commonly referred to as TCP/IP. TCP provides reliable,
ordered delivery of a stream of bytes from a program on one computer to another program on another
computer. TCP

is

the

protocol

that

major

Internet

applications

such

as

the World

Wide

Web, email, remote administration and file transfer rely on. Other applications, which do not require
reliable

data

stream

service,

may

use

the User

Datagram

Protocol (UDP),

which

provides

a datagram service that emphasizes reduced latency over reliability. TCP is responsible for keeping the
unordered segments in the right order. TCP assures a reliable delivery by resending anything that gets
lost while traveling the network. TCP also implements a congestion control mechanism.
TCP provides the following facilities:

i)

Stream data transfer: The TCP is able to transfer a continuous stream of octets in each
direction between its users by packing some numbers of octets into segments for
transmission through the internet system. Applications working at the Application Layer
transfer a continuous stream of bytes to the bottom layers. It is the duty of TCP to pack this
byte stream to packets, known as TCP segments, which are passed to the IP layer for
transmission to the destination device. The application does not have to bother to chop the

ii)

byte stream data packets.


Reliability: The most important feature of TCP is reliable data delivery. In order to provide
reliability, TCP must recover from data that is damaged, lost, duplicated, or delivered out of
order by the Network Layer. TCP assigns a sequence number to each byte transmitted, and
expects a positive acknowledgment (ACK) from the receiving TCP layer. If the ACK is not
received within a timeout interval, the data is retransmitted. The receiving TCP uses the
sequence numbers to rearrange the segments when they arrive out of order, and to eliminate
duplicate segments. A number of mechanisms help provide the reliability TCP guarantees

iii)

such as checksums, duplicate data detection, retransmission, sequencing and timers.


Flow control: In data communications, flow control is the process of managing the
pacing of data transmission between two nodes to prevent a fast sender from outrunning a

slow receiver. It provides a mechanism for the receiver to control the transmission speed, so
that the receiving node is not overwhelmed with data from transmitting node. Flow control
should be distinguished from congestion control, which is used for controlling the flow of
data when congestion has actually occurred. TCP provides a means for the receiver to
govern the amount of data sent by the sender. This is achieved by returning a Window with
every ACK indicating a range of acceptable sequence numbers beyond the last segment
successfully received, The window indicates an allowed number of octets that the sender
transmit

before

receiving

further

permission.

The

TCP

at

the

receiving device,

when sending an ACK back to the sender, also indicates to the TCP at the sending device,
the number of bytes it can receive without causing serious problems in its internal buffers.
iv)

Multiplexing: To allow for many processes within a single host to use TCP communication
facilities simultaneously, the TCP provides a set of addresses or ports within each host.
Concatenated with the network and host addresses from the Internet communication layer,
this forms a socket (see Figure 1). A pair of sockets uniquely identifies each connection.

v)

Logical connections: The reliability and flow control mechanisms described

above

require

that

TCPs

initializes

and

maintains

certain

status

information for each data stream. The combination of this status including
sockets, sequence numbers, window sizes is called a logical connection.
When two processes wish to communicate, Their TCPs must first establish
a connection. When their connection is completed, the connection is
terminated or closed to free the resources for other users. Since
connections must be established between unreliable hosts and over the
unreliable internet communication system, a handshake mechanism with
clock-based sequence numbers is used to avoid erroneous initialization of
connections.
vi)

Full Duplex: TCP establishes a full duplex virtual connection between two

endpoints. Each endpoint is defined by an IP address and a TCP port


number. The operation of TCP is implemented as a finite state machine.

Reliable Transmission and Congestion Control in TCP:


Reliable transmission: TCP uses a sequence number to identify each byte of data. The sequence
number identifies the order of the bytes sent from each computer so that the data can be reconstructed in

order, regardless of any fragmentation, disordering, or packet loss that may occur during transmission.
For every payload byte transmitted, the sequence number must be incremented. In the first two steps of
the 3-way handshake, both computers exchange an initial sequence number (ISN). This number can be
arbitrary, and should in fact be unpredictable to defend against TCP Sequence Prediction Attacks.
TCP primarily uses a cumulative acknowledgment scheme, where the receiver sends an acknowledgment
signifying that the receiver has received all data preceding the acknowledged sequence number. The
sender sets the sequence number field to the sequence number of the first payload byte in the segment's
data field, and the receiver sends an acknowledgment specifying the sequence number of the next byte
they expect to receive. For example, if a sending computer sends a packet containing four payload bytes
with a sequence number field of 100, then the sequence numbers of the four payload bytes are 100, 101,
102 and 103. When this packet arrives at the receiving computer, it would send back an acknowledgment
number of 104 since that is the sequence number of the next byte it expects to receive in the next packet.
In addition to cumulative acknowledgments, TCP receivers can also send selective acknowledgments to
provide further information.
If the sender infers that data has been lost in the network, it retransmits the data.

Congestion control
The final main aspect of TCP is congestion control. TCP uses a number of
mechanisms to achieve high performance and avoid congestion collapse, where
network performance can fall by several orders of magnitude. These mechanisms
control the rate of data entering the network, keeping the data flow below a rate
that

would

trigger

collapse.

They

also

yield

an

approximately max-min

fair allocation between flows.


Acknowledgments for data sent, or lack of acknowledgments, are used by senders
to infer network conditions between the TCP sender and receiver. Coupled with
timers, TCP senders and receivers can alter the behavior of the flow of data. This is
more generally referred to as congestion control and/or network congestion
avoidance.
Modern implementations

of

TCP

contain

four

intertwined

algorithms: Slow-

start, congestion avoidance, fast retransmit, and fast recovery. To support the
congestion avoidance algorithm, the sender keeps two state variables: congestion
window, cwnd and a threshold ssthresh which is used to indicate the adjustment of
the congestion window. So the algorithm adjusts the window to safe operating point
then additive increase takes over and slowly increases the window size to probe for

more bandwidth. This enables TCP to deliver its data reliably and efficiently even in
a congested environment.
Conclusions
TCP is a fairly complex protocol that handles the brunt of functionality in a packet switched
network such as the Internet. Supporting the reliable delivery of data on a packet switched
network is not a trivial task. This document only scratches the surface of the TCP internals,
but hopefully provided the reader with an appreciation and starting point for further interest
in TCP. Even after almost 20 years of standardization, the amount of work that goes into
supporting and designing reliable packet switched networks has not slowed. It is an area of
great activity and there are many problems to be solved. As the Internet continues to grow,
our reliance on TCP will become increasingly important. It is therefore imperative for network
engineers, designers and researchers to be as well versed in the technology as possible.

Time

Type

Sequence

Sent

Receive

No

from

d at

DATA

0.2016

DATA

0.2016

ACK

0.4032

ACK

0.4032

DATA

0.6448

DATA

0.6448

ACK

0.8464

ACK

0.8464

DATA

10

1.088

DATA

11

1.088

ACK

12

1.2896

ACK

13

1.2896

DATA

14

1.5312

DATA

15

1.5312

ACK

16

1.7328

ACK

17

1.7328

DATA

1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0

18

1.9744

DATA

19

1.9744

ACK

20

2.176

ACK

Time

Type

Sequence

2.176

DATA

Sent from node 0

2.176

DATA

Dropped on link 0 to

3.176

DATA

1
Sent from node 0

3.4176

DATA

Received at node 1

3.4176

ACK

Sent from node 1

3.6192

ACK

Received at node 0

3.6192

DATA

Sent from node 0

3.8608

DATA

Received at node 1

3.8608

ACK

Sent from node 1

10

4.0624

ACK

Received at node 0

11

4.0624

DATA

Sent from node 0

12

4.304

DATA

Received at node 1

13

4.304

ACK

Sent from node 1

14

4.5056

ACK

Received at node 0

15

4.5056

DATA

Sent from node 0

16

4.7472

DATA

Received at node 1

17

4.7472

ACK

Sent from node 1

18

4.9488

ACK

Received at node 0

19

4.9488

DATA

Sent from node 0

20

4.9488

DATA

Dropped on link 0 to

1
1
0

Remarks

No

21

5.9488

DATA

Sent from node 0

22

6.1904

DATA

Received at node 1

23

6.1904

ACK

Sent from node 1

24

6.392

ACK

Received at node 0

Size

Bytes Transmitted

4
5
6
7
8

538.0
671.0
804.0
936.0
1068.0

Size

Bytes Transmitted

1
2
3
4
5
6
7
8

10.0
20.0
29.0
38.0
46.0
54.0
62.0
70.0

Kbytes
Kbytes
Kbytes
Kbytes
Kbytes
Kbytes
Kbytes
Kbytes

No of pairs

Duration

Bytes Transmitted

Delay

6s

350 Kbytes

0.2498 s

6s

175 Kbytes

0.3397 s

6s

105.166 Kbytes

0.3561 s

6s

83.625 Kbytes

0.3796 s

10

6s

67.599 Kbytes

0.3624 s

12

6s

56.332 Kbytes

0.3674 s

14

6s

48.284 Kbytes

0.3685 s

16

6s

42.625 Kbytes

0.3950 s

Você também pode gostar