Presentation is loading. Please wait.

Presentation is loading. Please wait.

Experiential Learning Workshop on Basics of Transport/Network Layer

Similar presentations


Presentation on theme: "Experiential Learning Workshop on Basics of Transport/Network Layer"— Presentation transcript:

1 Experiential Learning Workshop on Basics of Transport/Network Layer
July 05, 2018 Dr. Ram P Rustagi Professor, CSE Dept KSIT, Bangalore RPR/Experiential Learning - Transport Layer

2 Resources & Acknowledgements
Learning.html Articles in ACCS Journal du Slides ms Example web pages, and programs Acknowledgements: Computer Networking: Kurose, Ross RPR/Experiential Learning - Transport Layer

3 Day 1: Basics of Networking
Overview Introduction to basic networking Tools Handson 1: using networking tools IP and TCP Headers Analysis of layers in IP, TCP/UDP Handson-2: Analyze IP and TCP headers Fragementation and PMTU Discovery ICMP Errors, NAT Handson-3: ICMP errors, NAT, PMTU ARP, DHCP, Proxy, Gratuituous ARP Handson-4: ARP protocol Summary RPR/Experiential Learning - Transport Layer

4 RPR/Experiential Learning - Transport Layer
Day 2: Basics of HTTP Overview: HTTP and Versions Request and Response Format, Basic headers Handson-1: Analyze HTTP headers, status codes HTTP persistent and non-persistent connections Apache config support for persistent connections Handson-2: Configuring persistent connections Web caching, HTTP headers for cache control Handson-3: Cachecing, E-tags HTTP cookies mechanisms Secure cookies, sub-domains, HTTP only cookies Handson-4: using cookies, secure cookies Summary RPR/Experiential Learning - Transport Layer

5 Day 3: Basics of Transport Layer
Overview: Transport layer, requirements Connection less and connection oriented transport Handson-1: Analyze TCP 4-tuple and UDP 2- tuple Pseudo headers in TCP/UDP Concurrent communications : UDP and TCP Handson-2: Using data with same checksum TCP and UDP Error control, TCP flags Handson-3: Connection Mgmt, Queues, and states TCP Streaming, Reliability misnomer, UDP message boundaries Handson-4: TCP Streams and UDP messages Summary RPR/Experiential Learning - Transport Layer

6 Day 4: Basics of Web Security
Overview: HTTPS protocol Server certificate and server authentication Mixed content and browser warnings Locks icons and HTTP Status Handson-1: HTTPS website with mixed content MITM attack and ARP spoofing MITM with browser and information stealing Understanding HSTS, CSP Handson-2: Implementing ARP Spoofing Summary RPR/Experiential Learning - Transport Layer

7 Day 3: Basics of Transport Layer
Overview: Transport layer, requirements Connection less and connection oriented transport Handson-1: Analyze TCP 4-tuple and UDP 2- tuple Pseudo headers in TCP/UDP Concurrent communications : UDP and TCP Handson-2: Using data with same checksum TCP and UDP Error control, TCP flags Handson-3: Connection Mgmt, Queues, and states TCP Streaming, Reliability misnomer, UDP message boundaries Handson-4: TCP Streams and UDP messages Summary RPR/Experiential Learning - Transport Layer

8 Internet transport-layer protocols
reliable, in-order delivery (TCP) congestion control flow control connection setup unreliable, unordered delivery: UDP no-frills extension of “best- effort” IP services not available: delay guarantees bandwidth guarantees application transport network data link physical network data link physical network data link physical network data link physical logical end-end transport network data link physical network data link physical network data link physical application transport network data link physical network data link physical Source: Kurose, Ross: Computer Networking, A Top Down Approach RPR/Experiential Learning - Transport Layer

9 RPR/Experiential Learning - Transport Layer
Port Numbers IANA ranges for port numbers Well known ports: 1 to 1023 Assigned and controlled by IANA Reserved ports: to 49151 Only registered with IANA Not assigned or controlled by IANA Dynamic ports: to 65535 Can be used by any process Also used as ephemeral ports RPR/Experiential Learning - Transport Layer

10 Transport layer protocol
How would you design it What would you like to achieve At simplest level Multiplex/de-multiplex At advanced level Reliable delivery i.e. Data integrity Include error detection and retransmissions Sequential delivery Would need buffer Message boundaries Security RPR/Experiential Learning - Transport Layer

11 Multiplexing/demultiplexing
handle data from multiple sockets, add transport header (later used for demultiplexing) multiplexing at sender: use header info to deliver received segments to correct socket demultiplexing at receiver: application application P1 P2 application socket P3 P4 transport process transport network transport link network network physical link link physical physical Source: Kurose, Ross: Computer Networking, A Top Down Approach RPR/Experiential Learning - Transport Layer

12 Connectionless demux: example
clientSocket = (9157); clientSocket = (5775); application application application P1 P3 P4 transport transport transport network network network link link link physical physical physical source port: 6428 dest port: 9157 source port: ? dest port: ? source port: 9157 dest port: 6428 source port: ? dest port: ? Source: Kurose, Ross: Computer Networking, A Top Down Approach RPR/Experiential Learning - Transport Layer

13 Connection-oriented demux
Transport layer socket identified by 4(or 5)- tuple: source IP address source port number dest IP address dest port number (Protocol (TCP)) demux: receiver uses all four (or five) values to direct segment to appropriate socket server host may support many simultaneous TCP sockets: each socket identified by its own 4-tuple web servers have different sockets for each connecting client non-persistent HTTP will have different socket for each request RPR/Experiential Learning - Transport Layer

14 Connection-oriented demux: example
Source: Kurose, Ross: Computer Networking, A Top Down Approach application application application P4 P5 P6 P3 P2 P3 transport transport transport network network network link link link physical physical physical server: IP address B source IP,port: B,80 dest IP,port: A,9157 host: IP address C host: IP address A source IP,port: C,5775 dest IP,port: B,80 source IP,port: A,9157 dest IP, port: B,80 source IP,port: C,9157 dest IP,port: B,80 three segments, all destined to IP address: B, dest port: 80 are demultiplexed to different sockets RPR/Experiential Learning - Transport Layer

15 Connection-oriented demux: example
threaded server application application application P4 P3 P2 P3 transport transport transport network network network link link link physical physical physical server: IP address B source IP,port: B,80 dest IP,port: A,9157 host: IP address C host: IP address A source IP,port: C,5775 dest IP,port: B,80 source IP,port: A,9157 dest IP, port: B,80 source IP,port: C,9157 dest IP,port: B,80 Source: Kurose, Ross: Computer Networking, A Top Down Approach RPR/Experiential Learning - Transport Layer Transport Layer 3-14

16 Transport Layer Protocol Characteristics
Connection less May arrive out of order In order delivery requires pkts to be numbered. No acknowledgement, Packets may be lost No prior handshake Connection oriented Setup, data transfer and teardown phase Provides reliability, ordered delivery Handles error control in a better way * RPR/Experiential Learning - Transport Layer

17 Transport Layer Reliability Support
Needs error and flow control, loss detection Compels slower service Unreliable protocol No extra overheads Reliability at data link layer Provides error and flow control Why do we need it at Transport layer when Link layer provides the same * RPR/Experiential Learning - Transport Layer

18 UDP Design Requirement
How to design a simple transport layer ? Just provide transport on top of IP Multiplexing and demultiplexing Little bit of error checking No handshake Rest all has to be managed by application Application practically talks to IP DNS uses UDP What happens when query/response is lost? * RPR/Experiential Learning - Transport Layer

19 RPR/Experiential Learning - Transport Layer
UDP: segment header length, in bytes of UDP segment, including header 32 bits source port # dest port # length checksum includes pseudo header application data (payload) UDP segment format Source: Kurose, Ross: Computer Networking, A Top Down Approach RPR/Experiential Learning - Transport Layer

20 Pseudo header for checksum
| source address | | destination address | | zero |protocol| UDP length | Pseudo Headers | Source | Destination | | Port | Port | | | | | Length | Checksum | | data octets ... Actual Headers Src: RFC 768 RPR/Experiential Learning - Transport Layer

21 Internet checksum: example RFC 1071
Consider 3 words x6660 x5555 x8F0C x14AC1 Wrapping around the overflow bit makes it x4AC2 1’s complement will be xB53D RPR/Experiential Learning - Transport Layer

22 Data with Same Checksum
Adding 0xFFFF to checksum results in same value In UDP checksum computation length is used twice Once in UDP header, once in psuedo headers Consider the data addition that adds up to 0xFFFF First thought: use 0x5555 (i.e. ‘UU’) three times This increases length by 6, (which is counted twice) Thus addition of 6 bytes should add to 0xFFF3 Add 0xUQUQUQ (0x ) Yields same checksum Any other combination? RPR/Experiential Learning - Transport Layer

23 Data with Same Checksum
Given the data text ‘ABCDEF’, How it can be changed to use same checksum Swapping two bytes? e.g. CDABEF, or EFCDAB, or ABEFCD etc. Modifying the data without swapping BCBCEF? AAAAIL? RPR/Experiential Learning - Transport Layer

24 RPR/Experiential Learning - Transport Layer
TCP Characteristics point-to-point: One sender, one receiver reliable, in-order byte steam: No “message boundaries” pipelined: TCP congestion and flow control set window size full duplex data: Bi-directional data flow in same connection MSS: maximum segment size, determined from link/frame size connection-oriented: Handshaking (exchange of control msgs) inits sender, receiver state before data exchange flow controlled: Sender will not overwhelm receiver * RPR/Experiential Learning - Transport Layer

25 RPR/Experiential Learning - Transport Layer
Basis of TCP Handshake Q: will 2-way handshake always work in network? variable delays retransmitted messages (e.g. req_conn(x)) due to message loss message reordering can’t “see” other side 2-way handshake: Let’s talk ESTAB OK ESTAB choose x req_conn(x) ESTAB acc_conn(x) ESTAB Source: Kurose, Ross: Computer Networking, A Top Down Approach RPR/Experiential Learning - Transport Layer

26 Basis of TCP Handshake 2-way handshake failure scenarios:
Source: Kurose, Ross: Computer Networking, A Top Down Approach 2-way handshake failure scenarios: choose x req_conn(x) ESTAB acc_conn(x) client terminates ESTAB choose x req_conn(x) acc_conn(x) data(x+1) accept connection x completes server forgets x retransmit req_conn(x) ESTAB half open connection! (no client!) retransmit req_conn(x) ESTAB data(x+1) accept client terminates server forgets x connection x completes RPR/Experiential Learning - Transport Layer

27 RPR/Experiential Learning - Transport Layer
TCP 3-Way Handshake client state LISTEN server state SYNSENT SYNbit=1, Seq=x choose init seq num, x send TCP SYN msg SYN RCVD ESTAB SYNbit=1, Seq=y ACKbit=1; ACKnum=x+1 choose init seq num, y send TCP SYNACK msg, acking SYN ACKbit=1, ACKnum=y+1 received SYNACK(x) indicates server is live; send ACK for SYNACK; this segment may contain client-to-server data received ACK(y) indicates client is live ESTAB Source: Kurose, Ross: Computer Networking, A Top Down Approach RPR/Experiential Learning - Transport Layer

28 RPR/Experiential Learning - Transport Layer
TCP Timeouts On timer expiration Retransmits the segment that is not yet acked Sets the TimeoutInterval double of previous value Example: First time out 0.75s 2nd/3rd/… timeout will be 1.5s,3.0s,… On receipt of Ack, it is computed again Provides a limited form of congestion control * RPR/Experiential Learning - Transport Layer

29 TCP Flow Control buffered data free buffer space
to application process buffered data free buffer space RcvBuffer rwnd TCP segment payloads receiver-side buffering src: Computer Networking : Kurose, Ross * RPR/Experiential Learning - Transport Layer

30 Typical Understanding of TCP
src: ftp:// RPR/Experiential Learning - Transport Layer

31 TCP Client/Server Communication
3-way handsake Conn Establishment { Data Request Data Response Connecion Close RPR/Experiential Learning - Transport Layer

32 RPR/Experiential Learning - Transport Layer
\ active OPEN | CLOSED | \ < \ \ create TCB | ^ \ \ snd SYN passive OPEN | | CLOSE \ \ | | \ \ create TCB | | delete TCB \ \ V | \ \ CLOSE | \ | LISTEN | | | delete TCB | | rcv SYN | | SEND | | | | | V snd SYN,ACK / \ snd SYN | |< >| | | SYN | rcv SYN | SYN | | RCVD |< | SENT | | | snd ACK | | | | | | rcv ACK of SYN \ / rcv SYN,ACK | | | | x | | snd ACK | V V | CLOSE | | ESTAB | | snd FIN TCP Connection State Diagram TCP State Transition Diagram src: RFC 793 RPR/Experiential Learning - Transport Layer

33 RPR/Experiential Learning - Transport Layer
| CLOSE | | ESTAB | | snd FIN | CLOSE | | rcv FIN V | | snd FIN / \ snd ACK | FIN |< >| CLOSE | | WAIT-1 | | WAIT | rcv FIN \ | rcv ACK of FIN | CLOSE | | snd ACK | | V x V snd FIN V |FINWAIT-2| | CLOSING | | LAST-ACK| | rcv ACK of FIN | rcv ACK of FIN | | rcv FIN | Timeout=2MSL | | x V x V \ snd ACK delete TCB >|TIME WAIT| >| CLOSED | TCP Connection State Diagram TCP State Transition Diagram src: RFC 793 RPR/Experiential Learning - Transport Layer

34 RPR/Experiential Learning - Transport Layer
TCP Connection State Use netstat -nat to know the current state LISTEN SYN-RECD SYN-SENT ESTABLISHED CLOSED -> LAST_ACK FIN_WAIT1 FIN_WAIT2 TIME_WAIT Note: you may have to install net-tools sudo apt install net-tools RPR/Experiential Learning - Transport Layer

35 Setup Requirement: TCP/UDP
RPR/Experiential Learning - Transport Layer

36 Hands-On 1a: UDP Checksum
Between two machines communicate UDP packets using nc (-u option). Send data content as below and compute the checksum using the IP Address and port number used and verify it with checksum value in wireshark capture. “ABCDE” and “ABCDEUQUQUQ” Are the two checksum same? Why or why not? What other characters can you attach to “ABCDE” to have the same checksum value DrAIT/Basics of Socket Programming RPR

37 Hands-On 1b: UDP Msg Boundary
Data Transfer Clients sends data (100 bytes) every 2s (10 times) AA.. (1st pkt), BB..(2nd pkt), …, JJ..(10th pkt) Server reads 40 bytes at a time What would server receive and display? S1 S2 DrAIT/Basics of Socket Programming RPR

38 Hands-On 1c: UDP Packet Loss
Data Transfer Clients sends data (100 bytes) every 2s (10 times) AA.. (1st pkt), BB..(2nd pkt), …, JJ..(10th pkt) Break the link between switch at 7th sec and restore after 12 sec Server reads full 100 bytes. What would server receive and display? S1 S2 DrAIT/Basics of Socket Programming RPR

39 Hands-On 1d: TCP Streaming
Data Transfer Clients sends data (100 bytes) every 2s (10 times) AA.. (1st pkt), BB..(2nd pkt), …, JJ..(10th pkt) Server reads 30 bytes at a time What would server display S1 S2 DrAIT/Basics of Socket Programming RPR

40 Hands-On 1e:TCP Recovery
Data Transfer Clients sends data (100 bytes) every 2s (10 times) AA.. (1st pkt), BB..(2nd pkt), …, JJ..(10th pkt) Break the link between switch at 7th sec and restore after 12th sec Server reads 30 bytes at a time What would server receive: S1 S2 DrAIT/Basics of Socket Programming RPR

41 Hands-On 1f:TCP Timeouts
TCP timeout study T0: break the link between S1 and S2 Connect client to server How many SYN packets are transmitted What is the time difference between SYN pkts When does client give up Repeat the experiment, but with restoring the link after 1 minute. S1 S2 DrAIT/Basics of Socket Programming RPR

42 Hands-On 1g:TCP Recovery & Streaming
Data Transfer Clients sends data (100 bytes) every 2s (10 times) AA.. (1st pkt), BB..(2nd pkt), …, JJ..(10th pkt) Break the link between switch at 7th sec and restore after 12th sec Server reads 30 bytes at a time Study the timeouts of retransmission Analyze the segments on retransmission Do multiple segments combine in a single transmit What happens if combination is more than MTU? DrAIT/Basics of Socket Programming RPR

43 Handson 1h: Study of TCP Queuing
Run TCP server (nc -l <port>) Connect multiple clients to it Look the TCP connections at both clients and server All should show ESTABLISHED Exchange data from all clients When server responds, which client gets it What happens to data of other clients What happens to other clients when communicating client closes the connection RPR/Experiential Learning - Transport Layer

44 RPR/Experiential Learning - Transport Layer
Session 2 : setup A …… RPR/Experiential Learning - Transport Layer

45 RPR/Experiential Learning - Transport Layer
Session 2: Setup B 1 2 Router N1 N2 Switch 2 Ha: /24 Hc: /24 Hb: /24 RPR/Experiential Learning - Transport Layer

46 ARP - Address Resolution Protocol
Packet delivery to a host requires two addresses Logical address - IP Address Physical address - MAC address Need to find mapping from logical to physical ARP is used - RFC 826 Src: Forouzan - Computer Networking RPR/Experiential Learning - Network Basics

47 RPR/Experiential Learning - Network Basics
ARP - 4 cases MAC MAC Src: Forouzan - Computer Networking RPR/Experiential Learning - Network Basics

48 RPR/Experiential Learning - Network Basics
ARP ARP Request and Reply ARP Request is broadcast ARP Reply is Unicast Other forms of ARP Proxy ARP (RFC 1027) Reverse ARP (RFC 903) Gratuitous ARP RPR/Experiential Learning - Network Basics

49 RPR/Experiential Learning - Network Basics
Proxy ARP Router (Proxy ARP Server) replied to all requests Used when Splitting a network w/o changing hosts netmask Mobile IP Src: Forouzan - Computer Networking RPR/Experiential Learning - Network Basics

50 RPR/Experiential Learning - Network Basics
Reverse ARP Reverse ARP (RARP) : RFC 903 Used for diskless stations Organization does not have enough IP Address Target as MAC Bcast does not cross the router Needs one RARP server for each subnet BOOTP Improvement over RARP Has a relay agent to forward across network Static mapping of MAC to IP Manageability issues DHCP - replaces BOOTP RPR/Experiential Learning - Network Basics

51 RPR/Experiential Learning - Network Basics
Gratuitous ARP Ref: Gratuitous ARP Request Both src and dstn IP is set to that of m/c Dstn MAC is broadcast i.e. ff:ff:ff:ff:ff:ff Ordinarily, no reply will occur normally if a m/c exists, it may respond Gratuitous ARP Reply (for HA, LB, Spoofing) A reply to which no request has occurred RPR/Experiential Learning - Network Basics

52 RPR/Experiential Learning - Network Basics
Gratuitous ARP Why Gratuitous ARP Help detect IP conflicts if a m/c receives G-ARP req which is its own, implies IP conflict Helps in updating other m/cs ARP tables Used in clustering solutions, when IP is moved Helps inform the switch to update its port table Each time an i/f comes up (after down), sends G- ARP RPR/Experiential Learning - Network Basics

53 Life of Packet in Internet
DNS Record: -> Q: User at host ‘A’ types ping -c1 What is the packet flow? RPR/Experiential Learning - Network Basics

54 RPR/Experiential Learning - Network Basics
DHCP Goal: allow host to dynamically obtain its IP address Renew its lease on address in use, on lease expiry Preferably gets the same address, not guaranteed Support for mobile users who join network Guarantee: only one address to only one client Retain DHCP client address across reboots not guaranteed Retain DHCP client configs across server reboot Must coexist with statically assigned addresses Should work with DHCP server failovers Interoperate with BOOTP relay agents RPR/Experiential Learning - Network Basics

55 DHCP: more than IP addresses
DHCP can return more than just allocated IP address on subnet: Address of first-hop router for client Name and IP address of DNS sever Network mask (indicating network versus host portion of address) RPR/Experiential Learning - Network Basics

56 DHCP: Dynamic Host Configuration Protocol
DHCP overview: An extension of BOOTP mechanism Host broadcasts “DHCP Discover” msg [optional] DHCP server responds with “DHCP Offer” msg more than one server can make the offer client can choose which server to send request to Host requests IP address: “DHCP Request” msg DHCP server sends address: “DHCP Ack” msg Renewal happens with DHCP Request/ack On completion, client sends DHCP Release msg Practically not seen RPR/Experiential Learning - Network Basics

57 RPR/Experiential Learning - Transport Layer
Handson-2a: ARP Understand ARP working. Know current ARP working arp -an ping Hx (where Hx is not in ARP table) but live See the ARP table to have Hx entry ping Hy (where Hy is not live) What does ARP table shows RPR/Experiential Learning - Transport Layer

58 RPR/Experiential Learning - Transport Layer
Handson-2b: ARP …… Create state ARP entry for Hz not in ARP table sudo arp -s <IP Addr> <MAC Addr> ping Hz No ARP Request should be transmitted. ping -b -c5 <Broadcast address> RPR/Experiential Learning - Transport Layer

59 Handson-2c: Gratuituos ARP
…… Use arping to issue gratuituous ARP On Ha, assign IP of Hc sudo ip addr del /24 dev eth0 sudo ip addr add /24 dev eth0 sudo arping -A -I eth Analyze ARP table of Hb RPR/Experiential Learning - Transport Layer

60 Handson-2d: ICMP Redirect
Ha: 10.x.1.1/24 Hc: 10.x.1.201/24 1 2 Hb:10.x.1.101/24 Switch lo:10.x.2.101/24 lo:10.x.3.201/24 On Ha sudo ip route add 10.x.2.0/24 via 10.x.1.201 sudo ip route add 10.x.3.0/24 via 10.x.1.101 On Hb sudo ip route add 10.x.3.0/24 via 10.x.1.201 On Hc sudo ip route add 10.x.3.0/24 via 10.x.1.101 RPR/Experiential Learning - Network Basics

61 Handson-3a: Basic Routing
Hc: /24 1 2 Router Hb-e2: /24 Hb-e1: /24 Enable routing on Hb sudo sysctl -w net.ipv4.ip_forward=1 Define routing of /24 on Ha Define routing of /24 on Hc Ping Hc from Ha Note down the ARP table of Ha and Hc. It should show MAC addresses of Hb RPR/Experiential Learning - Transport Layer

62 RPR/Experiential Learning - Transport Layer
Handson-3b: Proxy ARP Ha: /22 Hc: /22 1 2 Router Hb-e2: /24 Hb-e1: /24 Enable proxy ARP, and routing on Hb sudo sysctl -w net.ipv4.conf.all.proxy_arp=1 sudo sysctl -w net.ipv4.ip_forward=1 Ping Hc from Ha Note down the ARP table of Ha and Hc. It should show MAC addresses of Hb RPR/Experiential Learning - Transport Layer

63 Handson-3c: PMTU Discovery
Ha: 10.x.1.1/24 Hc: 10.x.3.201/24 1 2 Hb-e1:10.x.1.101/24 Router Hb-e2:10.x.3.1/24 Router On Hb sudo ip link set dev eth2 mtu 1000 sudo sysctl -w net.ipv4.ip_forward=1 On Ha ping -c 2 —s p RPR/Experiential Learning - Network Basics

64 Handson-3d: IP Fragmentation
Ha: 10.x.1.1/24 Hc: 10.x.3.201/24 1 2 Hb-e1:10.x.1.101/24 Router Hb-e2:10.x.3.1/24 Router On Hb sudo ip link set dev eth2 mtu 1000 sudo sysctl -w net.ipv4.ip_forward=1 On Ha ./udp_client -b s p c 2 RPR/Experiential Learning - Network Basics

65 Handson-4a: Longest Prefix Match
LAN: eno1 eno1 eno1 Hb Router Router …… USB USB Routing table of Hb 10.x.1.65/24 10.x.1.34/27 10.x.1.129/26 RPR/Experiential Learning - Transport Layer

66 RPR/Experiential Learning - Transport Layer
Summary Transport Layer Multiplexing UDP Message boundary TCP Streaming TCP Reliability: timeouts and retransmits ICMP errors: Redirect, TTL expiry ARP, Gratuituous ARP IP routing, Longest prefix match RPR/Experiential Learning - Transport Layer

67 RPR/Experiential Learning - Transport Layer
Thank You RPR/Experiential Learning - Transport Layer


Download ppt "Experiential Learning Workshop on Basics of Transport/Network Layer"

Similar presentations


Ads by Google