TCP/IP Implementation Paper

TCP/IP Implementation Paper

TEL-AVIV UNIVERSITY אוניברסיטת תל-אביב הפקולטה להנדסה FACULTY OF ENGINEERING בי"ס להנדסת חשמל School of Electrical Engineering TCP/IP IMPLEMENTATION PROJECT NUMBER: 14-1-1-816 FINAL REPORT AUTHOR TOM MAHLER 029234402 ADVISOR: PROF. PATT-SHAMIR TEL AVIV UNIVERSITY LOCATION IN WHICH THE PROJECT WAS DONE: ALGORITHMS LAB, ROOM 210, SOFTWARE BUILDING, ENGINEERING FACULTY, TEL AVIV UNIVERSITY Abstract The purpose of this project is to provide a simple C++ implemented of a full TCP/IP (layer 3 and layer 4 of the OSI model) stack for educational purposes. The project expanded to also include layer 2, layer 1 and layer 5 thus resulting in the creation of a full networking operating system that I call "inet_os". The implementation is based on the 4.4BSD-Lite2 [1] distribution, a UNIX based operating system, which is implemented in C. Using C++ instead of C was a huge step, however necessary in order to better implement the code, and provide a cleaner implementation. Figure 0.1: inet_os, top view This figure shows the relations between the layers, under inet_os. Incoming data arrives from the NIC module, which pass it upwards to Layer 2 (Ethernet), Layer 3 (IP), Layer 4 (TCP), Layer 5 (sockets) which can pass the data to an application. Note that the ARP module is not part of the OSI module and acts as a side layer for a specific purpose: resolving network address. 1 Table of Contents ABSTRACT ................................................................................................................................................. 1 TABLE OF CONTENTS ................................................................................................................................ 2 TABLE OF FIGURES ................................................................................................................................... 4 1 INTRODUCTION............................................................................................................................. 6 2 CODE REVIEW OF EXISTING DESIGNS........................................................................................... 7 2.1 4.4BSD LITE [3] .......................................................................................................................... 7 2.2 FREEBSD .................................................................................................................................... 9 2.3 OBJECT ORIENTED PROGRAMING................................................................................................... 10 3 THEORETICAL BACKGROUND ..................................................................................................... 11 3.1 LAYER 0: THE WIRE .................................................................................................................... 11 3.2 LAYER 1: NETWORK INTERFACE CARD ............................................................................................. 11 3.3 LAYER 2: ETHERNET .................................................................................................................... 11 3.4 THE ADDRESS RESOLUTION PROTOCOL ........................................................................................... 12 3.5 LAYER 3: IP ............................................................................................................................... 13 3.6 LAYER 4: TCP ............................................................................................................................ 14 3.6.1 The 3-Way Handshake ..................................................................................................... 14 3.6.2 TCP State Machine ........................................................................................................... 15 3.6.3 TCP Timers [16] ................................................................................................................ 16 3.6.4 TCP Options [16]............................................................................................................... 18 3.6.4.1 Window Scale Option .................................................................................................................. 19 3.6.4.2 Timestamp Option ....................................................................................................................... 19 4 IMPLEMENTATION ...................................................................................................................... 21 4.1 THE INET_OS ........................................................................................................................... 21 4.2 LAYER 1: NETWORK INTERFACE CARD ............................................................................................. 23 4.2.1 The NIC_Cable and the L0_buffer Classes ............................................................. 25 4.3 LAYER 2: ETHERNET .................................................................................................................... 27 4.4 THE ADDRESS RESOLUTION PROTOCOL ........................................................................................... 28 4.5 PROTOCOLS ............................................................................................................................... 30 4.6 LAYER 3: IP ............................................................................................................................... 31 4.7 LAYER 4: TCP ............................................................................................................................ 32 4.8 LAYER 5: SOCKETS ...................................................................................................................... 34 4.9 ADDITIONAL DETAILS................................................................................................................... 36 4.10 DEBUGGING .............................................................................................................................. 36 2 5 TESTING AND USE CASES ............................................................................................................ 37 5.1 BASIC USE CASE ......................................................................................................................... 38 5.2 RESOLVING AN IP ADDRESS USING ARP .......................................................................................... 40 5.3 OPENING A TCP CONNECTION USING THE TCP 3-WAY HANDSHAKE .................................................... 41 5.4 SENDING A SMALL PACKET USING TCP ........................................................................................... 42 5.5 SENDING A LARGE PACKET USING TCP ........................................................................................... 43 5.6 CLOSING A TCP CONNECTION ....................................................................................................... 47 5.7 SHUTTING DOWN A TCP CONNECTION ........................................................................................... 49 5.8 COMBINED TEST: UNRELIABLE AND DELAYED CHANNEL ..................................................................... 52 5.9 APPLICATION USE CASE ............................................................................................................... 58 5.9.1 Part 1: ARP ....................................................................................................................... 59 5.9.2 Part 2: Connecting to the Server ...................................................................................... 60 5.9.3 Part 2: Chatting through the Server ................................................................................. 61 5.9.3.1 Automatic Port Assigning Under User Privileges ......................................................................... 62 5.9.4 Part 3: Closing the connection ......................................................................................... 63 5.10 CWND FALL TEST ........................................................................................................................ 64 5.11 ADVERTISE WINDOW GETS FULL ................................................................................................... 65 6 SUMMARY, CONCLUSIONS AND SUGGESTIONS FOR FUTURE WORK ....................................... 66 7 BIBLIOGRAPHY ............................................................................................................................ 67 8 APPENDIX .................................................................................................................................... 71 8.1 THE SOURCE CODE ..................................................................................................................... 71 8.2 THE SITE ................................................................................................................................... 73 8.3 THE PDF DOCUMENTATION ......................................................................................................... 73 3 Table of Figures FIGURE 0.1: INET_OS, TOP VIEW ...................................................................................................................... 1 FIGURE 2.1: VARIOUS BSD RELEASES WITH IMPORTANT TCP/IP FEATURES .............................................................. 8 FIGURE 2.2: THE DEVELOPMENT OF BSD .......................................................................................................... 9 FIGURE 3.1: TRADITIONAL ETHERNET FRAME STRUCTURE [7] .............................................................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    74 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us