Tuesday, September 21, 2021

CST 311 Intro to Computer Networks Module 3: Transport Layer

 

1.0 Learning Outcomes For the Week
  • 1.1 Learn the principles behind transport layer services.
  • 1.2 Learn how multiplexing and demultiplexing extend host-to-host delivery to process-to-process delivery.
  • 1.3 Learn details about two Internet transport layer protocols: UDP and TCP.
  • 1.4 Understand the principles behind reliable data transfer in the Internet, including flow and congestion control.
  • 1.5 Start a programming assignment to develop a UDP Ping application, and learn its usefulness in computing packet statistics.
  • 1.6 Use a traffic generator in the network emulation program (Mininet) to model the effects of distance, bandwidth, and loss on TCP traffic.
1.1 Learn the principles behind transport layer services.
  •  3.1 Introduction and Transport Layer Services
    • Logical communication - A transport-layer protocol provides for logical communication between application processes running on different hosts. This just means that hosts running applications make it seem that they are directly connected even though they might be in different parts of the planet.
    • Transport-Layer Segments - The transport layer converts application layer messages from the sending application into transport layer packets or segments. The application layer messages may even be broken down to smaller chunks. Within each chunk, the transport layer attaches a "header" which contains information such as the sending and receiving ports.
  • 3.1.1 Relationship between transport and Network Layers
    • The main difference between transport layer and network layer protocol:
      • Transport-layer protocol provides logical communication between processes running on different hosts. These protocols live in end systems. Within the end systems, this protocol moves messages from application processes to the network edge(layer).
      • Network-layer protocol provides logical communication between hosts.
    • House analogy: Each house has 12 kids and send mail to one another. Ann and Bill head each household and each of them collect mail from the kids and gives them to the mail person. Each of them also receives mail from the mail person and re-distributes them to the kids.
      • Application messages : letters in envelopes
      • Processes : kids 
      • Hosts (End Systems) : Houses 
      • Transport-Layer Protocol = Ann and Bill
      • Network-Layer Protocol = Postal Service (Mail Persons)
    • Transport-Layer protocol services are sometimes constrained by the service model of the underlying network-layer protocol. However, certain services that a network-layer protocol does not offer might be offered by a transport layer protocol service. 
  • 3.1.2 Overview of the Transport Layer in the Internet 
    • UDP - The User Datagram Protocol provides a connection-less service that is unreliable to the application.
    • TCP - The Transmission Control Protocol provides a connection-oriented and reliable service to the invoking application.
    • Packets, Segments, Datagram all refer to the transport layer packets.
    • IP(Internet Protocol) - The IP is another name for the Internet's Network Layer Protocol which provides logical communication between hosts.
      • Best-effort Delivery Service - This is the service that the IP provides which means that it tries its best effort in delivering segments between hosts BUT it makes no guarantees
      • Unrealiable Service - The IP does NOT guarantee the delivery of segments, the order of the segments, nor the integrity of the data in the segments. Hence this service is referred to as an unreliable service.
    • Services Provided by TCP but only UDP offers
      • Transport-layer multiplexing and demultiplexing - One of the main jobs of UDP and TCP is to extend its delivery service between the two hosts to a delivery system between two processes running within the hosts.
      • Integrity (ERROR) checking - Segment's headers also include error detection fields. 
    • Services provided by TCP that is not offered by UDP 
      • Reliable data transfer - TCP will guarantee data delivery from and to processes and in the correct order it was sent using techniques such as flow control, sequence numbers, acknowledgements, and timers. In this case, TCP makes the IP protocol a reliable one. 
      • Congestion control - This is a service for the "general good" which prevents any one TCP connection from swamping links and routers between two hosts with lots of traffic. TCP gives connecting links an equal share of the link bandwidth by regulating the rate at which hosts can send traffic into the network. (UDP is not regulated).
1.2 Learn how multiplexing and demultiplexing extend host-to-host delivery to process-to-process delivery.
  • 3.1 Multiplexing and Demultiplexing
    • Sockets - Sockets are like doors that allow data to pass through from the network to a process and vice versa. In terms of data delivery, the sockets are the intermediary between the network and the process. Sockets contain a unique identifier.
    • Multiplexing - Multiplexing is a transport-layer protocol job of gathering data chunks at the source host from different sockets, encapsulating that data with header information (used in demultiplexing) to create segments, and passing segments to the network layer. Requires 2 things:
      • (1)Source port number - Unique identifying numbers in sockets. 
      • (2)Destination port number - Segments in fields that indicate the socket segment that it is to be delivered to. 
    • Demultiplexing - Demultiplexing is one of the jobs of the transport-layer protocol that delivers the transport-layer segment into the correct socket.
    • Port Numbers - Port numbers is a 16-bit number that ranges from 0-65535. 
      • Well-Known Port Numbers - Numbers ranging from 0-1023 which are restricted and reserved for use by well-known application protocols such as HTTP (Port 80) and FTP (Port 21).
    • Connectionless Multiplexing and Demultiplexing (UDP)
      • Creating a UDP Socket in Python: 
        • clientSocket = socket(AF_INET, SOCK_DGRAM)
          • Automatic assignment of port number (1024-65535) to the socket by using this method. 
        • clientSocket.bind(('', 19157))
          • This method bind() binds the UDP socket to a desired port number.
        • Steps of UDP Multiplexing and Demultiplexing (Host A w/ UDP PORT 19157 -> Host B w/ UDP PORT 46428)
          • (1) Host A transport-layer creates transport-layer segement with (1) application data, (2) source port number(19157), (3) Destination Port number(46428), and (4) Two other values. 
          • (2) Transport layer passes segment into network layer.
          • (3) Network layer encapsulates segment in an IP datagram and makes best effort to deliver segment to Host B. 
          • (4) If segment arrives in Host B, Host B Transport layer examines the destination port number and directs the segment to the socket socket with the same destination port number. 
          • Notes: If segments arrives with 2 different source port number and source IP address but the same destination port number and IP address, they will all be directed towards the same socket.
        • recvfrom()
          • This is used to extract the client side (source) port number from the segment it receives from the client.
      • UDP socket is identified by a tuple containing (IP address, Port Number).
    • Connection-Oriented Multiplexing and Demultiplexing (TCP)
      •  TCP Socket Identifier consists of a tuple with 4 elements:
        • (1) Source IP Address
        • (2) Source Port Number
        • (3) Destination IP Address
        • (4) Destination Port Number
      • Two arriving TCP segments with differing source IP address or Port numbers will be directed to two difference sockets. 
        • Welcoming Socket - This socket waits for established connection requests from TCP clients on port number 12000. The TCP client creates a socket and sends a connection establishment request segment.
          • clientSocket = socket(AF_INET, SOCK_STREAM)
          • clientSocket.connect((serverName, 12000))
        • When the host OS of that's running the server process receives this request, it locates the server process that is waiting to accept a connection to port number 1200. The server process then creates another new socket:
          • connectionSocket, add = serverSocket.accept()
        • The Transport Layer on the server side notes these 4 values which becomes the newly created socket's identifying values:
          • (1) Source Port Number in the segment.
          • (2) IP of the Source Host
          • (3) Destination Port Number in the segment
          • (4) Own IP Address
        • TCP Connection is now in place and the client and server can now send data reliably.
    • Web Servers and TCP
      • Persistent HTTP - When the client and server are using this architecture, the client and server will exchange HTTP messages using the same server socket.
      • Non-Persistent HTTP - When the client and server uses this architecture, a new TCP connection will be created and closed for every request/response which can severely impact the performance of a busy web server.
1.3 Learn details about two Internet transport layer protocols: UDP and TCP.
  • 3.3 Connectionless Transport: UDP
    • UDP Protocol Services
      • (1) Multiplexing/Demultiplexing
      • (2) Light error checking
      • (3) No handshaking between client and server (Connectionless) 
    • DNS is an application-layer protocol that uses UDP
    • Why do we want to use UDP over TCP?
      • (1) Finer application-level control (Over what and when data is sent)
        • UDP will immediatly pass segment to network layer without doing any other services such as congestion-control or handshaking between client and server as with TCP.
      • (2) No connection establishment so that segments can be sent faster.
      • (3) No connection state since UDP does not keep track of receiving and sending buffers, congestion control parameters, and sequence and acknowledgement number parameters. This means that a server can support many more active clients over UDP than TCP.
      • (4) Small packet header overhead since UDP uses 8 bytes vs TCP using 20 bytes.
  • 3.3.1 UDP Segment Structure
    • The data field is occupied by the application data which varies depending on the application layer using it. DNS messages will have query/response message, streaming audio will have audio samples, etc. 
    • The header field has 4 fields consisting of 2 bytes.  
      • The Source Port number and the Destination Port number
      • Length field which specifies the number of bytes in the UDP segment
      • Checksum checks whether errors have been introduced in the segments. 
  • 3.3.2 UDP Checksum
    • This provides for error detection that determines whether bits within the UDP segment have been altered by performing a 1s complement of the sum of all the 16 bit words in the segment which is checked by the checksum.
    • No errors would show 1111 1111 1111 1111 but errors occur when one of the bits is a 0. 
    • End-end principle - Certain functionality (error detection must be implemented on an end-end basis). UDP must provide error detection at the transport layer. 
    • While this is a small safety checking procedure, UDP does not provide for error recovery; UDP protocol usually discards damaged segment or passes it on the application without warning.
  • 3.5 Connection-Oriented Transport: TCP
  • 3.5.1 The TCP Connection 
    • Connection-oriented - TCP is said to be connection-oriented because before a connection between client and server is established, there must be a prelimary handshake that occurs which is when some prelimenary segments are sent to each other in order to ensure data transfer. 
    • Logical-Connection - TCP connection is referred to as a logical connection since the common state resides in the TCPs in the two communicating end systems since TCP protocol ONLY runs in the end systems and NOT in the intermediate network (ie routers and switches). 
    • Full Duplex Service - Application layer data can flow between host A to host B simultaneously from host B to host A if there is a TCP connection between the two hosts.
    • Point-to-Point Connection - TCP connection is between a SINGLE sender and a SINGLE receiver. 
    • clientSocket.connect((serverName, serverPot))
      • This code initiates that a client wants to establish a connection to a server process.
    • Three-Way-Handshake - When the client wants to establish a connection to the server, the client first sends a TCP segment to the server, the server responds with a second TCP segment, then the client sends a third segment (which may carry a payload). 
    • Send Buffer - A buffer that is set aside during the initial three-way-handshake. TCP directs data from the client side to the connection's send buffer.
    • Maximum Segment Size (MSS) - This is the maximum size of data that can be grabbed and placed in a segment. 
      • MSS typical value is 1460 bytes
      • TCP/IP header 40 bytes
    • Maximum Transmission Unit (MTU) - This ensures that the TCP segment will fit into a single link-layer frame before being sent.  
      • Ethernet and PPP link-layer protocols have MTU of 1500 bytes
    • TCP Segments - Client data chunk + TCP header which are passed down to the network layer, separately encapsulated within the network-layer IP datagrams, and sent. 
  • 3.5.2 TCP Segment Structure
    • TCP Header Structure includes:
      • Sequence number field - 32 bit
      • Acknowledgement number field - 32 bit 
      • Receive window field - 16 bit used for flow control. It is also used to indicate the number of bytes that a receiver is willing to accept.
      • Header length field - 4 bit that specifies the length of the TCP header in 32-bit words. 
      • Options Field - Used when sender and receiver negotiate the MMS or as a window scaling factor used in high-speed networks. 
      • Flag Field - 6 bits
        • ACK bit - Indicates that the value carried in the acknowledgment field is valid.
        • RST, SYN, FIN bits are used for connection set up and teardown.
        • CWR and ECE bits are used in congestion notification.
        • PSH bit - Indicates receiver should pass data to the upper level.
        • URG bit - Indicates that there is data in this segment that the sender upper-layer entity has marked as "urgent". 
      • Urgent data pointer - The location of the last byte of the urgent data is indicated by this 16 bit data field.
    • Sequence Numbers and Acknowledged Numbers
      • Sequence number for a segment - The byte stream number of the first byte in the segment. This is used because TCP sees data as a stream of bytes.
      • Cumulative Acknowledgements - This is because TCP only acknowledges bytes up to the first missing byte in the stream.
    • Telnet: A Case Study for Sequence and Ackknowledged Numbers
    • d
    • d
  • 3.5.3 Round Trip Time Estimation and Timeout
    • Timeout/Retransmit Mechanism - TCP uses this to recover from lost segments but it is difficult to implement in an actual protocol. 
      • Length of timeout intervals might cause problems
    • Estimating the Round Trip Time
      • Estimated RTT = (1-a) * EstimatedRTT + a*SampleRTT
        • The new value of estimated RTT is a weighted combination of the previous estimated RTT and the new value for sample RTT
        • The value of a = 0.125.
      • Exponential weighted moving average(EWMA) - As the more recent samples better reflect the current congestion in the network. The weight of a given SampleRTT decays exponentially fast as the updates proceed. 
      • DevRTT = (1 - b) * DevRTT + b * |SampleRTT - Estimated RTT| 
        • Measures the variability of the RTT.
    • Setting and Managing the Retransmission Timeout Interval 
      • TimeoutInterval = EstimatedRTT + 4 * DevRTT. 
  •  3.5.4 Reliable Data Transfer
    • Reliable Data Transfer Service - TCP creates this service on top of IP's unreliable service. This service provided by the TCP ensures that data stream that a process reads out of its TCP receive buffer is not corrupted, has no gaps, no duplicates, and in sequential order.
    • TCP timer management procedures - The recommended TCP timer management procedures use only a single re-transmission timer, even if there are multiple transmitted segments.
    • Timeout Interval - The timeout interval is a window of time that the hosts have to receive acknowledgements before resending them in cases where they don't arrive or get lost.
    • Doubling the timeout interval - When a timeout event occurs, TCP re-transmits the segment with a time interval that's twice the previous value. The timer grows exponentially after each re-transmission. This provides a limited form of congestion control.
    • Fast Retransmit - Timer triggered re transmission might have long periods if the packets never get received which increases end-to-end delay. 
      • Duplicate ACK - An ACK that reacknowledges a segment for which the sender has already received an earlier acknowledgement. 
      • Fast Retransmit - When 3 duplicate ACKS are received, the TCP sender performs this fast re-transmit before the segment timer expires.
    • Go-Back-N or Selective Repeat -
      • Selective Acknowledgement - Allows a TCP receiver to acknowledge out-of-order segments selectively as opposed to cumulatively acknowledging the last correctly received, in order segment. 
      • TCP's error-recovery mechanism is a combination of GBN and SR protocols.
  • 3.5.5 Flow Control 
    • Flow-Control Service - TCP provides this service to its applications to eliminate the possibility of the sender overlfowing the receiver's buffer. This service can be seen as a speed matching service matching the rate at which the sender is sending against the rate at which the receiving application is reading. 
    • Congestion Control - TCP sender can also be throttled due to congestion within the IP network. 
    • Receive Window - TCP provides flow control by having the sender maintain a variable called the receive window. This is used to give the sender an idea of how much free buffer space is available at the receiver. 
  • 3.5.6 TCP Connection Management
    • TCP Connection Management is important because one of the most common network attacks such as SYN flood attack exploid vulnerabilities in TCP Connection management. 
    • Client Application Process Establishing connection to Server: 
      • (1). Client side sends special TCP segment (SYN Segment) to server side TCP with a SYN bit set to 1. Client also randomly chooses an initial sequence number(client_isn, protects against security attacks). Then, this segment is encapsulated within the IP datagram and sent to the server.
      • (2). After server receives this segment, it will extract the segment, allocate TCP buffers ad variables to the connection, and send a connection granted segment to the Client TCP. The sent segment will have 3 important items: (1) SYN bit set to 1, acknowledgement field of TCP segment is set to client_isn+1, (3) server chooses its own initial sequence number (server_isn). This segment sent back is referred to as SYNACK Segment. 
      • (3). After client receives the SYNACK segment, it will also allocate buffers and variables. The client also sends another segment back to the server which let's the server know that it received its segment. The SYN bit is set to 0 since the connection is now established. 
    • Shutting down a connection between a process
      • The client application process issues a close command. This causes the client TCP to send a segment to the server process with a flag bit called the FIN bit set to 1. The server receives this then sends the client client an acknowledgement segment. The server then sends a shut down segment with a FIN bit set to 1. The client acknowledges this segment and both host deallocate their resources. 
    • TCP States - There are many TCP states that a client and server side TCP goes through during it's cycle. 
      • Client Side TCP
        • CLOSED -> Client app initiates TCP conn, Send SYN
        • SYN_SENT -> Receive SYN & ACK, send ACK
        • ESTABLISHED -> Send FIN, client app initiates close connection
        • FIN_WAIT_1 -> Receive ACK, send nothing
        • FIN_WAIT_2 -> Receive FIN, send ACK
        • TIME_WAIT -> Wait 30 sec
      • Server Side TCP
        • CLOSED
        • LISTEN
        • SYN_RCVD
        • ESTABLISHED
        • CLOSE_WAIT
        • LAST_ACK
1.4 Understand the principles behind reliable data transfer in the Internet, including flow and congestion control.
  • 3.6 Principles of Congestion Control
  • 3.6.1 The Causes and the Cost of Congestion
    • Two Senders, a Router with Infinite buffers
      • Per-Connection Throroughput - Number of bytes per second at the receiver. 
      • One cost of a congested network is a large queueing delay that happens when packet-arrival rate nears link capacity.
    • Two Senders and a Router with Finite Buffers
      • Offered Load - the rate at which the transport layer sends segments that contain original data and retransmitted data into the network.
      • One cost of a congested network is that the sender must perform retransmissions in order to compensate for dropped(lost) packets due to buffer overflow.
      • Another cost of a congested network is unneeded retransmissions by the sender in the face of large delays may cause a router to use its link bandwidth to forward unneeded copies of a packet. 
    • Four Senders, Routers with Finite Buffers, and Multihop Paths
      • Dropping a packet due to congestion causes a waste in the transmission capacity of using that to transmit the dropped packet.
  • 3.6.2 Approcaches to Congestion Control 
    • End-to-End Congestion Control When TCP segment is lost and a timeout or 3x duplicate acknowledgements have been sent, TCP decreases window size accordingly.
    • Network Assisted Congestion Control - Routers must provide explicit feedback to the sender and/or receiver regarding the congestion state of the network.
      • ATM Available Bit Rate Congestion Control - A router informs the sender of the maximum host sending rate it can support on an outgoing link.
  • 3.7 TCP Congestion Control 
    • Congestion Window - A variable that TCP congestion mechanism operating at the sender keeps track of. (cwnd) imposes a certain limit on the rate that TCP sender can send traffic INTO the network. 
    • Self-Clocking - TCP is called self clocking because it uses acknowledgements to trigger its increase in congestion window size. 
    • TCP congestion control algorithm - 
      • (1) slow start
      • (2) congestion avoidance
      • (3) fast recovery
1.5 PA#2: Start a programming assignment to develop a UDP Ping application, and learn its usefulness in computing packet statistics.
  • My team and I met up this past Sunday to discuss this programming assignment. It didn't seem like it was that difficult. We are going to try tackling it on our own then meeting up again on Thursday to discuss our progress.
 
1.6 Use a traffic generator in the network emulation program (Mininet) to model the effects of distance, bandwidth, and loss on TCP traffic.
  • The lab this week was very straight forward. I learned how to set up a custom topology network using MiniEdit and how to simulate packet loss on the VM. I also learned about threshold and the effects that a connection with a small bandwidth has on the entire packet sending and receiving speed.
 
1.7 Overall Thoughts
  • Overall, this week was pretty challenging. I'm still trying to figure out the best way to tackle this class but so far, getting a head start on the reading material on wednesdays then doing the assignments thursday and friday then reviewing the material monday and tuesday have been a great way to keep up with the material. We also started another programming assignment this past week. Along with the midterm this saturday, it will be hard to allot the time I need to study but I'll manage. 

No comments:

Post a Comment

CST 499 Capstone - Week 8 Learning Journal Final Entry

This is the very last entry of the journal of your CS Online learning!  Keeping regular journals is a great way for us to grow, both profe...