EECS340 Recitation 2: Very helpful to your project Hongyu Gao 1.

Slides:



Advertisements
Similar presentations
Transportation Layer (2). TCP full duplex data: – bi-directional data flow in same connection – MSS: maximum segment size connection-oriented: – handshaking.
Advertisements

TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
CCNA – Network Fundamentals
Intermediate TCP/IP TCP Operation.
Introduction1-1 message segment datagram frame source application transport network link physical HtHt HnHn HlHl M HtHt HnHn M HtHt M M destination application.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
CS 471/571 Transport Layer 5 Slides from Kurose and Ross.
TCP & UDP - Protocol Details Yen-Cheng Chen
1 TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
1 CS 4396 Computer Networks Lab Transmission Control Protocol (TCP) Part I.
Networks I Transmission Control Protocol Instituto Tecnológico y de Estudios Superiores de Monterrey Campus Estado de México Prof. MSc. Ivan A. Escobar.
Transmission Control Protocol (TCP) Basics
CS3505 The Internet and Info Hiway transport layer protocols : TCP/UDP.
Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
Chapter 7 – Transport Layer Protocols
Netprog: TCP Details1 TCP Details. Netprog: TCP Details2 TCP Lingo When a client requests a connection, it sends a “SYN” segment (a special TCP segment)
TRANSPORT LAYER  Session multiplexing  Segmentation  Flow control (TCP)  Connection-oriented (TCP)  Reliability (TCP)
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
Netprog: TCP Details1 TCP Details Introduction to Networking Yan Gao TA Jan 27, 2005 Recital 3.
TCP© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science Department.
Lecture 3 TCP/IP model CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
EEC-484/584 Computer Networks Lecture 15 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
What to do in muxHandler()?. Get the headers  Use function MinetReceive to get the packet p.  Get the TCPHeader and IPHeader of p. You can use the function.
Netprog: TCP Details1 TCP Details Introduction to Networking John Otto TA Jan 31, 2007 Recital 4.
Netprog: TCP Details1 TCP Details Introduction to Networking.
CSE 461: Transport Layer Connections. Naming Processes/Services  Process here is an abstract term for your Web browser (HTTP), servers (SMTP),
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
EEC-484/584 Computer Networks Lecture 13 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
1 ELEN 602 Lecture 15 More on IP TCP. 2 byte stream Send buffer segments Receive buffer byte stream Application ACKs Transmitter Receiver TCP Streams.
Gursharan Singh Tatla Transport Layer 16-May
Module A Panko and Panko Business Data Networks and Security, 9 th Edition © 2013 Pearson.
The Transport Layer.
Networking Basics TCP/IP TRANSPORT and APPLICATION LAYER Version 3.0 Cisco Regional Networking Academy.
6.1. Transport Control Protocol (TCP) It is the most widely used transport protocol in the world. Provides reliable end to end connection between two hosts.
1 Netprog 2002 TCP/IP TCP/IP Transmission Control Protocol / Internet Protocol Based on Notes by D. Hollinger.
Lecture 6 Overview. TCP: Transmission Control Protocol TCP is an alternative transport layer protocol supported by TCP/IP. TCP provides: – Connection-oriented.
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
More on TCP Acknowledgements Sequence Number Field Initial Sequence Number Acknowledgement Number Field.
CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
Networking Basics CCNA 1 Chapter 11.
Slide #1 CIT 380: Securing Computer Systems TCP/IP.
© Jörg Liebeherr (modified by Malathi Veeraraghavan) 1 Overview Formats, Data Transfer, etc. Connection Management.
Hour 6 The Transport Layer 1. What You'll Learn in This Hour Connections oriented and connectionless protocols Ports and sockets TCP UDP 2.
Transport Protocols.
11 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) WiFi, Ethernet Link (Physical)
Two Transport Protocols Available Transmission Control Protocol (TCP) User Datagram Protocol (UDP) Provides unreliable transfer Requires minimal – Overhead.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
Advanced Computer Networks
Fast Retransmit For sliding windows flow control we waited for a timer to expire before beginning retransmission of a packet TCP uses an additional mechanism.
Introduction to Networking Recital 4
5. End-to-end protocols (part 1)
Chapter 17 and 18: TCP is connection oriented
Process-to-Process Delivery
TCP.
TCP - Part I Karim El Defrawy
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Chapter 2 Transport Layer Protocols TCP UDP SCTP
TCP Details.
PART V Transport Layer.
PART 5 Transport Layer.
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Transport Protocols: TCP Segments, Flow control and Connection Setup
Transport Protocols: TCP Segments, Flow control and Connection Setup
Transport Layer 9/22/2019.
Presentation transcript:

EECS340 Recitation 2: Very helpful to your project Hongyu Gao 1

Warming-up Questions If you don’t know your IP address, dig into the old announcement in the newsgroup 2

3 Roadmap r How to run Minet stack r Hints for project 2

4 Need X-server if running remotely Xming for Windows

5 Script to run Minet start_minet.sh somehow doesn’t work properly for me. Use run_modules.sh instead. Remember to set variable MINET_IPADDR and MINET_ETHERNETADD R in minet.cfg or run_modules.sh, depending on which script you use.

6 Connect to tcp_server with nc

7 Script to stop Minet./stop_minet.sh

8 Roadmap r How to run Minet stack r Hints for project 2

9 File to Modify src/core/tcp_module.cc Implement your TCP in this file

10 Refer to udp_module.cc How to pass data to application layer (sockets)? How to receive data from application layer (sockets)? How to pass data to IP layer? How to receive data from IP layer? MinetSend() and MinetReceive()

11 Understand TCP Protocol!

12 Sneak Peek: Talk with IP Layer pt2DFIPFunction DFIPFuncArray[NUM_TCP_STATES] = { &DFIPNull, // CLOSED &DFIPNull, // LISTEN *DFIPListen is not dispatched from this table* &DFIPSynRcvd, // SYN_RCVD &DFIPSynSent, // SYN_SENT &DFIPSynSent1, // SYN_SENT1 &DFIPEstablished, // ESTABLISHED &DFIPSendData, // SEND_DATA &DFIPCloseWait, // CLOSE_WAIT &DFIPFinWait1, // FIN_WAIT1 &DFIPClosing, // CLOSING &DFIPLastAck, // LAST_ACK &DFIPFinWait2, // FIN_WAIT2 &DFIPTimeWait // TIME_WAIT };

13 Sneak Peek: Talk with Sockets pt2DFSOCKFunction DFSOCKFuncArray[NUM_SOCK_TYPES] = { &DFSOCKConnect, // CONNECT &DFSOCKAccept, // ACCEPT &DFSOCKWrite, // WRITE &DFSOCKForward, // FORWARD &DFSOCKClose, // CLOSE &DFSOCKStatus // STATUS };

14 Please make your code well- commented Next, some slides that previous TAs gave to the previous students…

What to do in muxHandler()? (starting from line 50) From Anonymous TA1

Get the headers r Use function MinetReceive to get the packet p. r Get the TCPHeader and IPHeader of p. You can use the function in class Packet. For example, FindHeader function. You can get the Tcpheader by using p.FindHeader(Headers::TCPHeader);

Find the connections r Extract information from the IPHeaders and TCPHeaders. For example, src ip & port and dest ip &port. For example, using iph.GetDestIP function.(suppose iph is the ip header) r Use the information above to find the connection the packet belongs in Clist. Clist is used for keeping all connections built. For example, using ConnectionList ::iterator cs = clist.FindMatching(c);// Specify c with src & dest information

Parse tcp header r Get the state of current connection. You may need to modify it based on the packet received. For example, using (*cs).state.GetState(); r Get the flags of TCP header, using tcph.GetFlags(f). Then check whether it is SYN, ACK, FIN.. And do corresponding action based on current state.

For Example r if( IS_ACK(f) && IS_SYN(f) ) r { r cout<<"SYN ACK packet Received. will have to send ACK packet"<<endl; r p.Print(cout); r if( state == SYN_SENT ) r { r connstate.state.SetState(ESTABLISHED); r unsigned int newack,last_recvd; r tcph.GetAckNum(newack); r tcph.GetSeqNum(last_recvd); r connstate.state.SetLastAcked( newack ); r connstate.state.SetLastRecvd( last_recvd ); r connstate.timeout=Time() + ACK_TIMEOUT; r char *data1 = "ACTIVE:in active connection\n"; r Buffer b(data1,strlen(data1)); r Packet psh; r unsigned int old_time; r TCPOptions opt; r tcph.GetOptions(opt); r old_time = ntohl(*(int *)(opt.data+8)); r craftSynPacket(&psh,connstate,PSH_ACK_HEADER,0,old_time); r psh.Print(cout); r MinetSend(mux,psh); r connstate.state.SetLastSent(connstate.state.GetLastSent()); r status=STATUS; r MinetSend(sock,write); r }

Netprog: TCP Details 21 TCP Details Introduction to Networking From Anonymous TA2

Netprog: TCP Details 22 The TCP Project Important Handouts: r Minet  The Minet Technical Report The Minet Technical Report  The Minet Socket Interface The Minet Socket Interface r TCP Guides  RFC (in convenient HTML format), RFC RFC 793RFC 1122  A very useful summary and picture of the TCP State diagram (TCP_IP_State_Transition_Diagram.pdf)  TCP, UDP and IP pocket guide (TCP_UDP_IP_packet_guide.pdf) includes header details  Brief overview of TCP ( contains a nice summary of the essentials  Here is a page with nice TCP animations ( They explain TCP connection startup, termination, data flow and flow control and cumulative ack concepts.

Netprog: TCP Details 23 TCP Lingo r When a client requests a connection, it sends a “SYN” segment (a special TCP segment) to the server port. r SYN stands for synchronize. The SYN message includes the client’s ISN. r ISN is Initial Sequence Number.

Netprog: TCP Details 24 More... r Every TCP segment includes a Sequence Number that refers to the first byte of data included in the segment. r Every TCP segment includes a Request Number (Acknowledgement Number) that indicates the byte number of the next data that is expected to be received.  All bytes up through this number have already been received.

Netprog: TCP Details 25 And more... r There are a bunch of control flags:  URG: urgent data included.  ACK: this segment is (among other things) an acknowledgement.  RST: error - abort the session.  SYN: synchronize Sequence Numbers (setup)  FIN: polite connection termination.

Netprog: TCP Details 26 And more... r MSS: Maximum segment size (A TCP option) r Window: Every ACK includes a Window field that tells the sender how many bytes it can send before the receiver will have to toss it away (due to fixed buffer size, “flow control”).

Netprog: TCP Details 27 TCP Connection Creation r A server accepts a connection.  Must be looking for new connections! r A client requests a connection.  Must know where the server is!

Netprog: TCP Details 28 Client Starts r A client starts by sending a SYN segment with the following information:  Client’s ISN (generated pseudo-randomly)  Maximum Receive Window for client.  Optionally (but usually) MSS (largest datagram accepted).  No payload! (Only TCP headers)

Netprog: TCP Details 29 Sever Response r When a waiting server sees a new connection request, the server sends back a SYN segment with:  Server’s ISN (generated pseudo-randomly)  Request Number is Client ISN+1  Maximum Receive Window for server.  Optionally (but usually) MSS  No payload! (Only TCP headers)

Netprog: TCP Details 30 Finally r When the Server’s SYN is received, the client sends back an ACK with:  Request Number is Server’s ISN+1

Netprog: TCP Details 31 Client Server SYN ISN=X SYN ISN=X 1 SYN ISN=Y ACK=X+1 SYN ISN=Y ACK=X+1 2 ACK=Y+1 3 time

Netprog: TCP Details 32 Why 3-Way? r Why is the third message necessary? r HINTS:  TCP is a reliable service.  IP delivers each TCP segment.  IP is not reliable.

Netprog: TCP Details 33 TCP Data and ACK r Once the connection is established, data can be sent. r Each data segment includes a sequence number identifying the first byte in the segment. r Each segment (data or empty) includes a request number indicating what data has been received.

Netprog: TCP Details 34 TCP Buffers r Both the client and server allocate buffers to hold incoming and outgoing data  The TCP layer does this. r Both the client and server announce with every ACK how much buffer space remains (the Window field in a TCP segment).

Netprog: TCP Details 35 Send Buffers r The application gives the TCP layer some data to send. r The data is put in a send buffer, where it stays until the data is ACK’d.  it has to stay, as it might need to be sent again! r The TCP layer won’t accept data from the application unless (or until) there is buffer space.

Netprog: TCP Details 36 ACKs r A receiver doesn’t have to ACK every segment (it can ACK many segments with a single ACK segment). r Each ACK can also contain outgoing data (piggybacking). r If a sender doesn’t get an ACK after some time limit (MSL) it resends the data.

Netprog: TCP Details 37 Termination r The TCP layer can send a RST segment that terminates a connection if something is wrong. r Usually the application tells TCP to terminate the connection politely with a FIN segment.

Netprog: TCP Details 38 FIN r Either end of the connection can initiate termination. r A FIN is sent, which means the application is done sending data. r The FIN is ACK’d. r The other end must now send a FIN. r That FIN must be ACK’d.

Netprog: TCP Details 39 App1 App2 FIN SN=X FIN SN=X 1 ACK=X+1 2 ACK=Y+1 4 FIN SN=Y FIN SN=Y 3...