CS492B project - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

CS492B project

Description:

CS492B project – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 20
Provided by: pankaj95
Category:
Tags: cs492b | ms | project | tutorial

less

Transcript and Presenter's Notes

Title: CS492B project


1
CS492B project 2tutorial
  • 2003. 9. 17
  • Jin Hyun Ju
  • This material is from Stanford cs244A

2
Assignment overview
  • Client/server (client.c, server.c)
  • File download application
  • Mysocket layer (mysock.c)
  • Replacement for socket API (myopen, myread, etc.)
  • STCP (transport.c)
  • Transport layer You fill this in!
  • Network layer (network.c)
  • Simulates random packet loss, delay, duplication
  • network_send(), network_recv()datagram service
    used by STCP

client
server
mysocket
mysocket
transport
transport
network
network
3
What is STCP?
  • TCP lite
  • Simplified connection setup
  • Two-way handshake
  • No piggybacking of data with acknowledgement
    packets
  • No congestion control
  • No slow-start, fast retransmissions, delayed
    ACKs, etc.
  • Still provides reliable, connection-based,
    byte-oriented transport between two endpoints
  • Flow control (sliding sender/receiver window)
  • Go-back N
  • Retransmissions

4
STCP packets
  • Simplified version of TCP segments
  • SYN packet start a connection
  • ACK packet acknowledge reception of data (next
    seq)
  • No data payload permitted in STCP
  • SYN-ACK passive side completes connection
  • FIN packet end a connection
  • FIN-ACK passive side closed connection
  • Data packet Any packet without these flags set
  • SYN/data packets sequence numbers
  • No advertised window

5
STCP model
  • Each side of connection two processes
  • Parent (application/mysocket layer)
  • Child (your STCP implementation/network layer)
  • Why this model?
  • Simulates real O/S implementation
  • User-level socket library interfaces to kernel
    functionality
  • Network data arrival is asynchronous
  • STCP implementation can sleep until an
    interesting event happens
  • Timeout, packet arrival, etc.

6
STCP model
Parent
client
server
mysocket
mysocket
transport interface
transport interface
Child
transport implementation
transport implementation
network
network
7
Function calls
  • one STCP connection
  • socket() close() in server and client
  • mysocket(), mybind()
  • wrapper function
  • myconnect(), myaccept() -gt transport_inite()
  • mywrite(), myread()
  • -gt write(), read() -gt control_loop()
  • myclose()

8
transport initiation
comm_sd
bind()
syn_sd
data_sd
connect()
fork()
9
STCP transport layer initiation
myconnect(), myaccept()
Parent (app)
  • transport_init() creates two socket pairs, forks
    parent blocks until connected
  • In STCP, a SYN received from peer by child
  • Parent/child communicate via local sockets (a la
    pipe)
  • syn_sdnotify parent of connection completion
  • data_sdpass data between app/transport layer

fork
syn_sd0 (syn pipe) data_sd0 (data
pipe) syn_sd1 data_sd1
transport_init()
Data pipe
Syn pipe
IPC
Child (transport)
syn_sd0 data_sd0 syn_sd1 (syn
pipe) data_sd1 (data pipe) comm_sd (peer
socket)
10
STCP IPC details
  • Forking, IPC is provided already in transport.c
  • You shouldnt need to touch much of
    transport_init(), except to
  • Add your SYN/SYN-ACK handling
  • Change/add the transport layer state setup as
    needed
  • Sockets created in transport_init() (using
    localsocketpair()) before forking
  • Descriptors valid in both parent/child processes
  • Syn_sd used only for connection setup
  • Data_sd used for all data sent between
    application and transport layer
  • Only one of each socket is used in parent/child
    to communicate, a la pipe/FIFO
  • transport_init() closes unneeded sockets in
    parent and child

11
STCP/application interaction
  • Connection establishment (myconnect, myaccept)
  • Application blocks until SYN received
  • STCP wakes up blocked parent process using syn
    pipe
  • syn_sd is finished with at this point
  • Data read/write (myread, mywrite)
  • Application reads from/writes to its end of the
    data pipe
  • STCP writes to/reads from its end of the data
    pipe
  • Whenever data is available (from app or peer) and
    you have space in your window
  • Just assume data written to application has been
    read

12
STCP main control loop
client
server
mysocket
mysocket
transport interface
transport interface
local_data_sd data_sd1
local_data_sd data_sd1
transport implementation
transport implementation
network
network
comm_sd
13
STCP main control loop
  • Main loop repeatedly waits for event on
    application socket (local_data_sd), peer socket
    (comm_sd), timeout (in part B onwards)
  • Select to see which event happened

14
STCP/application interaction
  • Connection teardown (myclose)
  • Application closes stream socket returned by
    transport_init()
  • Pay attention to delivery semantics in assignment
    handout
  • Multiple connections
  • A unique child process is forked by
    transport_init(), so you dont have to worry
    about session demultiplexing

15
Select
  • Online information
  • man s 3c select
  • Looks in section 3c of manual (C library)
  • Also useful section 2 (system calls), 3socket
    (socket calls)

16
context_t ctx
  • global variable
  • you can add new variable
  • see struct tcpcb

17
STCP in reliable mode
  • Network layer is reliable
  • All packets delivered in sequence, no losses
  • You implement connection setup/teardown,
    acknowledgements, send/receive windows
  • Client/server pair should be able to download
    files after youve finished this

18
STCP in unreliable mode
  • Network layer becomes obnoxious
  • Packets reordered, dropped, duplicated
  • See network_send() in network.c
  • You must handle retransmissions, timeouts,
    Go-back N, buffering of data,
  • Minimum RTT estimate is 20 ms
  • Five retransmissions of any segment
  • Careful about packets crossing ends of receive
    window
  • Client, server pair should now work with U flags
  • Your modified transport.c is the only file needed
    (and accepted) for testing and the final
    submission

19
General comments
  • See TCP FSM diagram (R. Stevens)
  • Keep track of SYN_SENT, SYN_WAITING, etc.
  • STCP state machine is simpler
  • Network layer uses UDP datagrams
  • Treat it like an IP implementation
  • Packet-oriented rather than byte-oriented service
  • Be sure to read the maximum length datagram!
  • Unread bytes in a datagram are discarded by
    recv()
  • Portability
  • Dont forget to use htonX()/ntohX() as
    appropriate in STCP header fields
Write a Comment
User Comments (0)
About PowerShow.com