#LyX 1.3 created this file. For more info see http://www.lyx.org/ \lyxformat 221 \textclass report \begin_preamble \input{preamble} \end_preamble \language english \inputencoding auto \fontscheme times \graphics default \paperfontsize 11 \spacing double \papersize letterpaper \paperpackage a4 \use_geometry 1 \use_amsmath 1 \use_natbib 1 \use_numerical_citations 1 \paperorientation portrait \leftmargin 1.5in \topmargin 0.9in \rightmargin 1in \bottommargin 1in \headsep 0.17in \footskip 0in \secnumdepth 4 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \quotes_times 2 \papercolumns 1 \papersides 1 \paperpagestyle fancy \layout Chapter Assessment on how INET processes TCP/IP packets \begin_inset LatexCommand \label{cha:A3-Assessment on TCP} \end_inset \layout Standard \begin_inset ERT status Collapsed \layout Standard \backslash thispagestyle{empty} \end_inset \begin_inset ERT status Collapsed \layout Standard \backslash renewcommand \backslash figurename{Fig.} \end_inset The last section was about the UML tool. This section is about how Linux's TCP suite, INET, Handles TCP packets. This section will give a slight overview of the TCP/IP layers and then in the next section go into more detail over some of the major structures in the INET. These next two sections are helpful to understanding the kernel modifications, and how the Linux kernel handles the TCP protocol. The INET (Linux implementation of the TCP IP suite) is purely the same as the RFC's and some explanation of the differences are needed. \layout Section Overview of TCP \layout Standard The TCP is the transport communication protocol. In the protocol stack it is four (transport) right above the Internet Protocol (IP). The TCP guarantees the arrival of the packets. The way the Linux kernel uses TCP is the packet arrives at the network card and the information (digital signals) is transferred to memory. The Linux kernel creates a structure in memory (called a sk_buff) which has pointers to the newly received digital transmission now in memory. Each transmission is a packet â a part of the original transmitted data with the headers attached. Each TCP packet consist of three different types of headers (Ethernet, IP, TCP) and the data . The need for TCP and other transport layer protocols is to allow the partitioni ng of data. \layout Standard If a user is downloads a modestly size file, say the latest UML root_fs from sourceforge (the file would be roughly 16 megs). Transferring all this file in one big packet (one set of headers) would be cumbersome. If another user else wants to use the bandwidth, they would have to wait until the transmission of 16 megabytes is complete. With a transport layer protocol, like TCP, the users share bandwidth. \layout Standard The data is partition into small packets (roughly 1500 bits a piece) each having their own set of headers. The TCP protocol was developed for the department of defense. If a network connection was broke and other routes were available, the department of defense wanted a way to ensure the data's arrival. These headers tell the packet where to go and ensures the packet gets there. This is what the Ethernet and IP headers do. The Ethernet and IP headers contain sets of address (kind of like street address) to tell the packet where to go. \layout Standard he data packets are divided into pieces, and the Internet is not all the same bandwidth and reliability. Some packets will arrived mixed up, corrupted, twice or not at all. The TCP headers contain information to manage the arrival of the packets and makes sure the application receives the data in order. \layout Section TCP Header and Sk_buff \layout Standard Fig.\SpecialChar ~ \begin_inset LatexCommand \ref{fig:TCP Header} \end_inset shows the TCP header and Fig.\SpecialChar ~ illistrates the TCP header structure in the Linux code. The total length of the TCP header is 20 bytes; four bytes for each row. Eight bits equal one byte; the TCP header is 160 bits. Of those 160 bits, 64 bits are used for the sequence and acknowledgment numbers (32 bits for the sequence and 32 bits for the acknowledgment number). The Seq and Ack numbers are how the TCP keeps packets in order. \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Standard \align center \begin_inset Graphics filename Figures/a1tcpHeader.eps display none \end_inset \layout Caption \begin_inset LatexCommand \label{fig:TCP Header} \end_inset Tcp header \end_inset \layout Standard The header has all sorts of information. In the kernel, TCP header is accessed by a pointer in the sk_buff (stands for socket buffer). The sk_buff is the most important structure in the networking of the kernel because it references the incoming network packet and a cental hub for routing information. In Fig.\SpecialChar ~ \begin_inset LatexCommand \ref{fig: headers of skbuf} \end_inset is a code sniped of the sk_buff: \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Standard \align center \begin_inset Tabular \begin_inset Text \layout Standard \paragraph_spacing single \align left struct sk_buff { \newline \SpecialChar ~ \SpecialChar ~ /* These two members must be first. */ \newline \SpecialChar ~ \SpecialChar ~ struct sk_buff * next; /* Next buffer in list */ \newline \SpecialChar ~ \SpecialChar ~ struct sk_buff * prev; /* Previous buffer in list */ \newline \SpecialChar ~ \SpecialChar ~ struct sk_buff_head * list; /* List we are on */ \newline \SpecialChar ~ \SpecialChar ~ struct sock *sk; /* Socket we are owned by */ \newline \SpecialChar ~ \SpecialChar ~ struct timeval stamp; /* Time we arrived */ \newline \SpecialChar ~ \SpecialChar ~ struct net_device *dev; /* Device we arrived on/are leaving by */ \newline \SpecialChar ~ \SpecialChar ~ /* Transport layer header */ \newline \SpecialChar ~ \SpecialChar ~ union { \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct tcphdr *th; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct udphdr *uh; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct icmphdr *icmph; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct igmphdr *igmph; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct iphdr *ipiph; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct spxhdr *spxh; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ unsigned char *raw; \newline \SpecialChar ~ \SpecialChar ~ } h; \newline \SpecialChar ~ \SpecialChar ~ /* Network layer header */ \newline \SpecialChar ~ \SpecialChar ~ union { \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct iphdr *iph; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct ipv6hdr *ipv6h; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct arphdr *arph; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct ipxhdr *ipxh; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ unsigned char *raw; \newline \SpecialChar ~ \SpecialChar ~ } nh; \newline \SpecialChar ~ \SpecialChar ~ /* Link layer header */ \newline \SpecialChar ~ \SpecialChar ~ union { \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ struct ethhdr *ethernet; \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ unsigned char *raw; \newline \SpecialChar ~ \SpecialChar ~ } mac; \newline \SpecialChar ~ \SpecialChar ~ struct dst_entry *dst; \newline \SpecialChar ~ \newline \end_inset \end_inset \layout Caption \begin_inset LatexCommand \label{fig: headers of skbuf} \end_inset header section of the sk_buff \end_inset \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Standard \align center \begin_inset Tabular \begin_inset Text \layout Standard \paragraph_spacing single \align left struct tcphdr { \newline \SpecialChar ~ \SpecialChar ~ __u16 source; \newline \SpecialChar ~ \SpecialChar ~ __u16 dest; \newline \SpecialChar ~ \SpecialChar ~ __u32 seq; \newline \SpecialChar ~ \SpecialChar ~ __u32 ack_seq; \newline \SpecialChar ~ \SpecialChar ~ #if defined(__LITTLE_ENDIAN_BITFIELD) \newline \SpecialChar ~ \SpecialChar ~ __u16 res1:4, \newline \SpecialChar ~ \SpecialChar ~ doff:4, \newline \SpecialChar ~ \SpecialChar ~ fin:1, \newline \SpecialChar ~ \SpecialChar ~ syn:1, \newline \SpecialChar ~ \SpecialChar ~ rst:1, \newline \SpecialChar ~ \SpecialChar ~ psh:1, \newline \SpecialChar ~ \SpecialChar ~ ack:1, \newline \SpecialChar ~ \SpecialChar ~ urg:1, \newline \SpecialChar ~ \SpecialChar ~ ece:1, \newline \SpecialChar ~ \SpecialChar ~ cwr:1; \newline \SpecialChar ~ \SpecialChar ~ #elif defined(__BIG_ENDIAN_BITFIELD) \newline \SpecialChar ~ \SpecialChar ~ __u16 doff:4, \newline \SpecialChar ~ \SpecialChar ~ res1:4, \newline \SpecialChar ~ \SpecialChar ~ cwr:1, \newline \SpecialChar ~ \SpecialChar ~ ece:1, \newline \SpecialChar ~ \SpecialChar ~ urg:1, \newline \SpecialChar ~ \SpecialChar ~ ack:1, \newline \SpecialChar ~ \SpecialChar ~ psh:1, \newline \SpecialChar ~ \SpecialChar ~ rst:1, \newline \SpecialChar ~ \SpecialChar ~ syn:1, \newline \SpecialChar ~ \SpecialChar ~ fin:1; \newline \SpecialChar ~ \SpecialChar ~ #else \newline \SpecialChar ~ \SpecialChar ~ #error "Adjust your defines" \newline \SpecialChar ~ \SpecialChar ~ #endif \newline \SpecialChar ~ \SpecialChar ~ __u16 window; \newline \SpecialChar ~ \SpecialChar ~ __u16 check; \newline \SpecialChar ~ \SpecialChar ~ __u16 urg_ptr; \newline }; \newline \SpecialChar ~ \newline \end_inset \end_inset \layout Caption \begin_inset LatexCommand \label{fig:IP-error messages} \end_inset IP tunnel error messages \end_inset \layout Section Establishing a TCP connection \layout Standard The sequence and acknowledgment numbers mentioned earlier manages the arrival and order of the packets. The Linux kernel labels each packet that is sent with a beginning sequence number on each side. This sequence number is incremented by a known value. If the packets become out of sequence, the receiver can tell by the sequence number. \layout Standard The initial sequence number is determined by the sender. It creates a packet (sk_buff) and sends it down the protocol stack and out to the Internet. The TCP header has a section of one bit FLAGS. There are six flags: URG, ACK, PSH, RST, SYN, and FIN. The initial packet send by the sender not only has the initial sequence number, but also has the SYN flag set. When the receiver gets the initial packet. It processes the packet and sends its own sequence number and places the just received sequence number in the acknowledgment field. The sender then sets two flags in the TCP header: SYN and ACK. \layout Standard How the INET starts the connection is discussed in Section\SpecialChar ~ \layout Standard \the_end