FRTP Implementation

Download Report

Transcript FRTP Implementation

FRTP Implementation
SENDER
• Create TCP socket & bind it to port no.
specified.
• listen() for the Receiver to connect() and
accept() when it does.
• Get information (data channel port on
Receiver, rate, secondary NIC IP address)
on this channel.
• Connect a UDP channel to Receiver.
SENDER
• Create a new thread (“network” thread NT) to
handle data transfer; previous “disk” thread DT
handles disk access.
• DT open()s the file requested and calls send() to
send the file block by block (7.86 MB each).
• Insert this application buffer (a block of the file)
into the sender buffer linked list.
• Signal the condition variable m_SendDataCond;
this informs the NT that new data is available to
be sent.
SENDER
Sender Buffer
Sender buffer
m_pCurrAckBlk
m_pLastBlk
m_pCurrSendBlk
m_pBlock
Contains:
Contains:
Contains:
Contains:
Pointer to data
Pointer to data
Pointer to data
Pointer to data
Pointer to next
block
Pointer to next
block
Pointer to next
block
Pointer to next
block
Length of data
Length of data
Length of data
Length of data
Block info.
m_lCurrSendPnt
m_lCurrAckPnt
unACKed data
SENDER
Sender Buffer
• The sender buffer is an area of memory (default 40MB),
blocks of which (usually 8MB) are written by the DT.
• Each block of data has an associated Block info.
structure, which has a pointer to its block, length of the
block and a pointer to the next block info. structure.
• There are pointers to the block info. structures of the first
, last block, block from which the most recently ACKed
data was sent and the block from which data was sent
most recently (could be unACKed). Note that these need
not always be 4 different pointer values (e.g. the most
recent ACKed and unACKed data could have been sent
from the same block).
• There are offset values to track the offset of the most
recently sent ACKed and unACKed data in the blocks.
SENDER
Network Thread NT
• Record time: entertime
• If entertime > next expiry time (EXP timer
= 1 sec), call processfeedback() to add all
unACKed packets to losslist.
• If no data to send wait on condition
variable m_SendDataCond.
• Poll control channel. If control packets
rxed call processfeedback(). Reset expiry
time.
SENDER
Network Thread NT
• If losslist is not empty, get first sequence
no. in loss list. Read from buffer into data
packet.
• Else read new data from buffer into data
packet.
• Send the data packet on UDP channel.
• Wait for the inter packet interval to finish.
RECEIVER
• Create a TCP socket and connect to the Sender.
• Send data channel port, secondary NIC IP
address on this channel.
• Wait for Sender to connect on UDP socket.
• Create a new “network” thread NT to handle
data transfer to the network. Previous “disk”
thread DT handles disk access.
RECEIVER
• DT calls recv() with pointer to where the
received data should be written and length of
data expected.
• If requested length of ACKed data is available in
protocol buffer recv() returns. Write this data into
the file and go to previous step.
• Else wait on condition variable
m_RecvDataCond. Set m_bReadBuf variable.
RECEIVER
Network Thread NT
• Initialize the next ACK and SYN times.
• Check if m_bReadBuf is set. If set (=> DT
is waiting for data), try to read requested
amount of data from protocol buffer.
• If requested amt. of ACKed data is
available signal the condition variable
m_RecvDataCond.
RECEIVER
Network Thread NT
• Else call registerUserBuffer(). This function
copies data from protocol buffer to user
buffer. The copied data includes ACKed
and unACKed data till m_lMaxOffset.
• Check if ACK, ERR or SYN timers have
expired and call feedback() to send them.
• Assign the pointer where next received
packet should be placed.
RECEIVER
Network Thread NT
• Wait for a maximum of 100 uS to read a
data packet from the UDP channel.
• If no packet go back to step 2.
• Find out offset of received packet seq. no.
w.r.t. last ACKed packet.
• If received packet is not the expected one,
then it has been received into the wrong
memory location. Copy it to correct
position.
RECEIVER
Network Thread NT
• If received seq. no. > expected seq. no. then
packet(s) has been lost. Add lost packet seq. no.
to losslist. Call feedback() to send ERR packet
on TCP channel.
• If received packet is not 1472B then add it to
irregularPktList.
• If received seq. no. > current largest seq. no.
update largest seq. no.. Else remove received
seq. no. from losslist.
• Update next expected seq. no. and go to step 2.
IMPROVEMENTS
• Remove flow control window
• Add the interface (function) to set port
number, UDP buffer size, FRTP buffer
size, packet size, and block size.
• No multiple application-level buffers/
copies.
• Implementation CPU utilization should be
independent of other processes.