#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 Comments on TCP structures \begin_inset LatexCommand \label{cha:tcpStructs} \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 This next section is about the different structures that make up the Linux kernel's networking and will be touching on the most important structures. Major points about the networking section in the Linux code can be covered with the sk_buff, and sockets. This next section is mainly a reference describing the different structures. This information would assist in creating a new protocol or changing the TCP/IP (INET implementation) for research needs. \layout Section sk_buff \layout Standard The sk_buff contains all the information the packet needs to get to the destination. ip_output.c:ip_queue_xmit() is the last place in the call stack the inet socket is used to give extensive information about the packet then the sk_buff is the only parameter (and maybe the routing tables) passed through the call stack to the network device \begin_inset LatexCommand \citep{Cox1996,Rubini2001} \end_inset . \layout Standard For the TCP, the sk_buff is created for outbound packets in tcp_output.c:tcp_v4_c onnect() and released at net/core/dev.c:dev_queue_xmit(). For the incoming packet the sk_buff is created in the process_backlog, one reference was not entirely sure where the incoming packet is created and believed the packet was created in dev_alloc_skb ( ) \begin_inset LatexCommand \citep{Beck2002} \end_inset . \layout Standard The sk_buff partitions into six different parts: the link list, packet header, routing, control buffer, stats, and markers. \layout Subsection Link list \layout Standard The sk_buff is a structure attached to other sk_buff's in a linked list structure and has pointers to control it location, having pointers to the head, next, and prev. This link list contains other sk_buff structures heading to the same destinatio n generally going to the common router gateway. This linked list is a little different. \layout Standard n each sk_buff in the link list, there are two additional pointers to a network device (*dev) and to the inet socket (* sk). In addition to being double linked to each other with pointers to the head and tail, there are also pointers pointing to the device driver and the socket. Now, when the sk_buff is being populated with packet information it is just pointing to the socket. As the routing information is calculated, the device pointer is populated. At one point, every sk_buff in the link list is pointing to both a device and socket. And, as the packets are about to be setup to hardware, the socket pointer is set to null and only pointing to the device. This section of pointers groups the sk_buff based on connection and then on outbound device \begin_inset LatexCommand \citep{Welte2000} \end_inset . \layout Subsection Packet header \layout Standard This section talks about the packet header information. The sk_buff and most of the kernel is designed for abstraction using pointer arithmetic. With many different standards, each of the protocols have to correspond by having a similar interface, so the same network mechanism works with different protocols (e.g., UDP and TCP protocols). \layout Standard The sk_buff allows different protocols by using C Unions. There are three different headers (same as theOSI network stack): Transport, Network, and Link (or hardware). In the sk_buff, these headers are all pointers. A kmalloc (oppose to malloc) is called using sk_put( ). When receiving a packet, the header type is determined and the sk_buff maps a poitner to the correct packet header structure. The sk_put reserves the memory for each header. Since memory is allocated going from a top down structure, the timing of when sk_put is called is important. The IP header cannot be populate before populating the TCP header. The timing of when everything is done is just as or more important as what is populated into the sk_buff. \layout Standard Networks have different type of computers on them. These computers read information differently in memory. Most of the higher end systems (newer Apples, Suns, and HP Unix) use big endian. Intel uses little endian (for performance). The big and little endians needs to be accounted for when storing data. The difference between big and little endian is four bytes: little endian has bytes in reverse (not the bits, the bytes). An IP address: 172.31.0.173 (hex: ac 1f 00 1d) would be stored as (hex: 1d 00 f1 ac). The network send data as big endian does not reverse the bytes. When creating a iphdr (IP header), there are preprocessor statements which line the flags and other fields in the right order. One important and simple concept is he difference between the actual packet in memory and the sk_buff, an independent structure pointing to memory. \layout Standard sk_put ( ) reserves or expands the memory space of the packet. The sk_buff structure consists of pointers referencing the data area memory. In the Linux source code ( net/ipv4/ip_output.c:ip_queue_xmit()), a call to skb_push reserves memory for the entire socket structure. \layout Standard As information passes through each of the layers, additional headers are added using the skb_push function. In addition to the actual header, routing information is also stored in the dst_entry. \layout Subsection Routing \layout Standard When sending a packet, the dst_entry actually dictates the header information. The dst_entry stores the destination and mac addresses for transmission. The dst_entry stands for \begin_inset Quotes eld \end_inset destination entry \begin_inset Quotes erd \end_inset . In the 2.4 kernel the dst_entry is assigned for a new connection in the tcp_ipv4.c:tcp_v4_connect() \begin_inset LatexCommand \citep{Guffens2002} \end_inset . \layout Standard Going through each of the parameters in the call above, tt is a routing table structure, and nexthop is the gateway address. RT_CONN_FLAGS(sk) sets the connection flag, and sk->bound_dev_if is the outbound device. Generally, the packet goes to a network device (e.g., eth0). If the packet is heading towards an ip tunnel, the packet heads towards tunnel network driver (tunl1). The only thing populated from the ip_route_connect() is the routing table. The routing table is populated based off the actual IP routing table listed in the /proc/route and arp cache entry. \layout Standard The dst_entry is part of the routing table with other routing information, like the gateway, routing destination, and routing source. The routing table is placed inside of the INET sock, and the sk_buff has a pointer to dst_entry set by the INET socket. \layout Standard One of the entries on the dst_entry the hh (cached hardware header) determines in the ip_output.c:ip_finish_ouptput2 if the packet is destined for an IP tunnel or regular transmission. The source follows a different path in ip_finish_output2 based on hh value. If the hh is set to null, the sk_buff will be directed down another source path which eventually leads to the ipip.c functions (functions for IP tunneling) , otherwise the sk_buff continues neigh_resolve_output() uninterrupted. \layout Standard The dst_entry also contains a pointer to the dev. The dev pointer points to the network device the packet is sent and received. The network device also contains pointers to a lot of abstract functions. These functions pointers allow for the correct function to be called providing a layer of abstraction. \layout Standard Occasionally, information needs to be able to cross the OSI layers and be available for the developer to change. The next section of code, called the control buffer, deal with a buffer available for miscellaneous information storage. \layout Subsection Control buffer \layout Standard The control buffer is 48 bytes and is static stored. In this statically declared memory there is the tcp_option and other values which is the engine managing the TCP layer. \layout Standard The control buffer has preprocessor defined macros which allow easier assignment of the individual fields. For example, in the tcp_ipv4.c:tcp_v4_rcv there are statements like: TCP_SKB_CB( skb)->seq = ntohl(th->seq); where the TCP_SKB_CB assigns the seq in the host bit order to the control buffer. The macro TCP_SKB_CB hides all the type casting to tcp_skb_cb structure which is stored in the tcp.h. TCP uses the control buffer but not UDP. UDP not using the control buffer make sense because of the less overhead for UDP. IP uses the the control buffer by the inet_sk_param struct for the first field of the tcp_skb_cb struct. The TCPSKB_CB is used for the Ipv4 and has a separate processor condition for Ipv6 (IP version 6), if called. \layout Standard Inside the inet_sk_param, the ip_option structure is stored. The ip_option structure is used in addition to the other statically values in the sk_buff to record things like the first IP hop (generally a gateway) and various flags such as: if a time stamp is needed or if strict source route is used. The inet_sk_param also contains a flag stating what type of route: masquerade, translated, or IP forwarding. The remainder of the tcp_skb_cb structure consists of the TCP related informati on. \layout Standard There are four remaining fields for the TCP: sequence, end sequence, time stamp to help compute round trip time, and TCP header flags. The sequence number is actually populated by adding the previous sequence number and the size of the data payload. \layout Subsection Stats and Markers \layout Standard The last section of the sk_buff consist of a few static variables used to store measure ment and classification information. \layout Standard The remaining pointers (towards the end of the sk_buff) are pointers to different position of the outgoing packet in memory. There are four different pointers to the data: head, data, tail, and end. The head points to the beginning of the buffer, and the end points to the end of the buffer. The data points to the beginning of the data, and the tail points to the end of the data. Sometimes the tail and end pointers are different because Ethernet frames have two sections, a front and a back. The packet header is stored in the area between the head and the data pointers. \layout Standard The next section will describe the socket layers. The socket layers consist of the INET socket and the BSD socket and interfaces with the user and kernel processes. \layout Section BSD and INET Sockets \begin_inset LatexCommand \label{sec:BSD-and-INET} \end_inset \layout Standard One of the major differences between the INET implementation of the TCP/IP for Linux oppose to other UXIX operating systems is the use of an additional structure called the INET Socket. In this sub-section, I am going to give a quick over view of the BSD socket's use and then go into detail about the INET socket's. For INET implementations, the INET socket does most of the connection oriented work. And for opening a connection, the whole process still starts at the application layer or with the user. \layout Subsection TCP connection using sockets \layout Standard The application (at the user's discretion) starts the whole process by calling the operating system through a system call. There is a whole set of system calls that are standard for Unix favor operating systems called, POSIX. The system call for starting a network connection is sys_socketcall( ) and sys_connect( ) both located in net/socket.c \begin_inset LatexCommand \citep{Insolvibile2002,Troan1999} \end_inset . The sys_socketcall( ) transfers information from the user and calls sys_connect ( ). sys_connect ( ) looks up the bsd_socket and sets up the bsd_socket. \layout Standard The bsd_socket (or BSD socket) is common in all Unix favor operating systems. Microsoft has their own favor of the BSD sockets called winsock. The difference between the Linux socket and most other Unix favor operating systems is Linux has an additional socket, which is part of the BSD socket, called the INET socket. Again, the main difference between the BSD and INET sockets is BSD sockets interface with the user or application while the INET sockets are connection based. So within a BSD socket there is one for port 80 (default web server port) but there are multiple INET sockets handling all the connections going into port 80. \layout Standard Once the BSD socket is setup. The sys_connect ( ) calls the inet_stream_connect ( ) which sets the INET socket's state, and from this point on, the INET socket is passed into the code separately from the BSD socket. The BSD looks up the INET socket using a hash table with destination address and port. Then the inet_stream_connect ( ) calls many other methods which populate the INET socket's connection information (i.e., routing information). The Fig.\SpecialChar ~ \begin_inset LatexCommand \ref{SectionsOFINET} \end_inset gives a visual representation of the different layers. For a back trace of the code, please reference Table\SpecialChar ~ \begin_inset LatexCommand \ref{table:RecvBacktrace} \end_inset . \layout Standard There are two sockets, INET and BSD. They are activated by systems calls initiated by the user or the application. Of these two sockets, INET socket has the most control over the connection. \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Standard \align center \begin_inset Graphics filename Figures/socketLevels.eps display none \end_inset \layout Caption \begin_inset LatexCommand \label{SectionsOFINET} \end_inset Sections of the linux networking code \end_inset \layout Standard The INET socket is what maintains and manages the connection. This includes keeping track of the sequence numbers in the TCP headers. There are dozens of entries in the INET socket structure and they do not partition off nicely like the sk_buff. This next section is going to cover work done with the INET source code. \layout Standard The INET socket is created in sys_socketcall ( ) when it calls the sys_socket( ) and sock_create(family, type, protocol, &sock) functions. \layout Subsection INET Socket: IP routing \layout Standard In Fig.\SpecialChar ~ \begin_inset LatexCommand \ref{socket structure} \end_inset is a code snip of the beginning of the INET socket structure. Four variable declarations tell the code which connection the socket belongs. This include multiple applications using the same port. For example, if there are five web browsers on one page all downloading information from a website. If the destination addresses and ports are the same, TCP is smart enough to transfer all the traffic through one connection. These connections are defined by the four variables below. \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 sock { \newline \SpecialChar ~ \SpecialChar ~ /* Socket demultiplex comparisons on incoming packets. */ \newline \SpecialChar ~ \SpecialChar ~ __u32 daddr; /* Foreign IPv4 addr */ \newline \SpecialChar ~ \SpecialChar ~ __u32 rcv_saddr; /* Bound local IPv4 addr */ \newline \SpecialChar ~ \SpecialChar ~ __u16 dport; /* Destination port */ \newline \SpecialChar ~ \SpecialChar ~ unsigned short num; /* Local port */ \newline \SpecialChar ~ \SpecialChar ~ ... \newline \SpecialChar ~ \SpecialChar ~ unsigned short family; /* Address family */ \newline \SpecialChar ~ \SpecialChar ~ ... \newline \SpecialChar ~ \SpecialChar ~ struct dst_entry *dst_cache; /* Destination cache */ \newline \SpecialChar ~ \SpecialChar ~ ... \newline \SpecialChar ~ \SpecialChar ~ __u32 saddr; /* Sending source */ \newline \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \newline \end_inset \end_inset \layout Caption \begin_inset LatexCommand \label{socket structure} \end_inset Socket structure \end_inset \layout Standard The __u32 means the variable is atomic. Atomic is an operating system terms which mean the value cannot be modified unless the associated mask is checked and modified first \begin_inset LatexCommand \citep{whatis} \end_inset . The mask is a way to prevent deadlock. Another worthy variable to mention is family. There is a list of all the different families in include/linux/socket.h. The family variable tells the code what type of socket. AF_INET (which equals 2) is the family for the TCP/IP protocols. Having a family variable shows the pains taking detail to make the socket conform to abstract interfaces allowing for multiple of types of protocols. \layout Standard The dst_cache is really a pointer to the dst_entry. This was talked about in detail in the sk_buff section above. The dst_entry in the sk_buff comes and goes with the packet. This variable in the socket is where the dst_entry (routing information) is kept for the connection. In the net/ipv4/ip_queue_xmit (where the IP header is added to the sk_buff), the sk_buff copies the dst_cache and stores it. Finally, there is the saddr (source address). This is probably a constant stored somewhere in the operating system and just assigned to the at the creation of the socket. \layout Subsection INET Socket: TCP management engine \layout Standard One of the most interesting parts of the socket is how it manages the sequence numbers. Since the socket uses the object-based programming technique abstraction, different protocols can have the socket manage connection information. Under the union structure tcp-pinfo, the values which control the connection are kept. These connection values are stored in the tcp_opt called af_tcp, shown in Fig.\SpecialChar ~ \begin_inset LatexCommand \ref{tp_pinfo structure} \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 union { \newline \SpecialChar ~ \SpecialChar ~ struct tcp_opt af_tcp; \newline \SpecialChar ~ \SpecialChar ~ #if defined(CONFIG_IP_SCTP) || defined (CONFIG_IP_SCTP_MODULE) \newline \SpecialChar ~ \SpecialChar ~ struct sctp_opt af_sctp; \newline \SpecialChar ~ \SpecialChar ~ #endif \newline \SpecialChar ~ \SpecialChar ~ #if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE) \newline \SpecialChar ~ \SpecialChar ~ struct raw_opt tp_raw4; \newline \SpecialChar ~ \SpecialChar ~ #endif \newline \SpecialChar ~ \SpecialChar ~ #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) \newline \SpecialChar ~ \SpecialChar ~ struct raw6_opt tp_raw; \newline \SpecialChar ~ \SpecialChar ~ #endif /* CONFIG_IPV6 */ \newline \SpecialChar ~ \SpecialChar ~ #if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE) \newline \SpecialChar ~ \SpecialChar ~ struct spx_opt af_spx; \newline \SpecialChar ~ \SpecialChar ~ #endif /* CONFIG_SPX */ \newline } tp_pinfo;struct sock { \newline \SpecialChar ~ \newline \end_inset \end_inset \layout Caption \begin_inset LatexCommand \label{tp_pinfo structure} \end_inset Tp_pinfo union structure \end_inset \layout Standard The tcp_opt stands for tcp options and manages the sequence numbers and acknowledgment numbers used by the TCP protocol. In the previous appendix, I talked about these values in detail and how TCP uses them for creating a reliable connection. \layout Standard The tcp options structure shown in Fig.\SpecialChar ~ \begin_inset LatexCommand \ref{tcp_opt} \end_inset , stores many management variables which serve as the engine of the TCP connection. One variable of interest is the rcv_nxt. The rcv_nxt hold the next expected TCP sequence number. This value is used in deciding if a packet goes onto the buffer, talked about in Section\SpecialChar ~ \begin_inset LatexCommand \ref{sec:Packet-buffering} \end_inset . If the incoming packet's sequence number does not match what is expect. The packet is out of order. Using a buffer hides the latency of the correct packet and corrects any out of order sequence. \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 tcp_opt { \newline int tcp_header_len; /* Bytes of tcp header to send */ \newline \SpecialChar ~ \SpecialChar ~ __u32 pred_flags; \newline \SpecialChar ~ \SpecialChar ~ __u32 rcv_nxt; /* What we want to receive next */ \newline \SpecialChar ~ \SpecialChar ~ __u32 snd_nxt; /* Next sequence we send */ \newline \SpecialChar ~ \SpecialChar ~ __u32 snd_una; /* First byte we want an ack for */ \newline \SpecialChar ~ \SpecialChar ~ __u32 snd_sml; /* Last byte of the most recently transmitted small packet */ \newline \SpecialChar ~ \SpecialChar ~ __u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ \newline \SpecialChar ~ \SpecialChar ~ __u32 lsndtime; /* timestamp of last sent data packet (for restart window) */ \newline \SpecialChar ~ \SpecialChar ~ ... \newline \SpecialChar ~ \SpecialChar ~ /* Data for direct copy to user */ \newline struct { \newline \SpecialChar ~ \SpecialChar ~ struct sk_buff_head prequeue; \newline \SpecialChar ~ \SpecialChar ~ struct task_struct *task; \newline \SpecialChar ~ \SpecialChar ~ struct iovec *iov; \newline \SpecialChar ~ \SpecialChar ~ int memory; \newline \SpecialChar ~ \SpecialChar ~ int len; \newline } ucopy; \newline \SpecialChar ~ \SpecialChar ~ \newline __u32 snd_wl1; /* Sequence for window update */ \newline __u32 snd_wnd; /* The window we expect to receive */ \newline __u32 max_window; /* Maximal window ever seen from peer */ \newline ... \newline __u8 reordering; /* Packet reordering metric. */ \newline __u8 queue_shrunk; /* Write queue has been shrunk recently.*/ \newline ... \newline __u8 keepalive_probes; /* num of allowed keep alive probes */ \newline unsigned int keepalive_time; /* time before keep alive takes place */ \newline unsigned int keepalive_intvl; /* time interval between keep alive probes */ \newline ... \newline } \newline \SpecialChar ~ \newline \end_inset \end_inset \layout Caption \begin_inset LatexCommand \label{tcp_opt} \end_inset Abreviated version of the tcp option structure \end_inset \layout Standard The final two parts touchs on is the timers and the abstract function pointers. Timers are events scheduled on the Linux kernel. This is similar to simulations. When we want to determine the round trip time, the Linux kernel grabs the time stores it in a time stamp variable which a structure timeval which has second and microsecnods encapsulated. There is also a link list of timeval used for determining when the TCP connection times out. Final part of the sock structure talks about is the abstract function. \layout Standard Located at the end of the sock structure, six function pointers allow interchang eable functions to be assigned to the socket. These function pointers allow functions for the UDP to be used when the INET socket is used for a UDP connection or allows for TCP functions for a TCP connection; this is all done using abstraction. The next section will talk about about a couple of kernel tricks with the Linux Kernel. \layout Section Kernel network tips and tricks \layout Subsection Changing a packets sending address \layout Standard To change the address of an outing packet from the destination the user originally intended, change the nexthop value in the ip_output.c:ip_queue_xmit(s truct sk_buff *skb, int ipfragok) function. \layout Subsection Sending a packet \begin_inset LatexCommand \label{sub:Sending-a-packet} \end_inset \layout Standard The easiest way to send a packet is using the tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts) located in the tcp_ipv4.c. This function outlines a blueprint of sending a packet. If the packet starts a new connection, creating and populating the INET socket is a gigantic task. For extra reference, below is a stack trace of establishing a TCP connection from the client's side. \layout Standard \begin_inset Float table placement H wide false collapsed false \layout Standard \begin_inset Tabular \begin_inset Text \layout Standard Function \end_inset \begin_inset Text \layout Standard description \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none dev_queue_xmit \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Skb is freed. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none nf_hook_slow \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none arp_send \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none arp_solicit \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none __neigh_event_send \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none neigh_resolve_output \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_finish_output2 \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none hh = null determines if tunl1 or eth0 device used. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none nf_hook_slow \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_output \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Increments IP stat. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_queue_xmit2 \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Adds IP checksum; sets the sk peer and IP ID field. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none nf_hook_slow \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_queue_xmit \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Rt is copied to skb's dest_entry; IP header is built \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none tcp_transmit_skb \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none TCP header is built, tcp_otions are built/updated; \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none adds TCP checksum; sets sk in skb. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none tcp_connect \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none INET socket's destination IP/port are set. \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none DST entry is created and set in socket. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none inet_stream_connect \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Marks the INET socket state. \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none At this point the INET socket is sent apart from the BSD socket. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none sys_connect \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none System call. Looks up and sets up the BSD socket. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none sys_socketcall \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Copies info from the user. \end_inset \end_inset \layout Caption \begin_inset LatexCommand \label{table:SendBacktrace} \end_inset Backtrace of sending a packet \end_inset \layout Subsection Receiving a packet \begin_inset LatexCommand \label{sub:Receiving-a-packet} \end_inset \layout Standard Every packet that is received through a TCP connection goes through the function tcp_v4_rcv from there the packet is processed by the TCP sections of code and is sorted based on the packet's flags and the state of the TCP connection. \begin_inset Float table placement H wide false collapsed false \layout Standard \begin_inset Tabular \begin_inset Text \layout Standard Function \end_inset \begin_inset Text \layout Standard description \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none tcp_v4_rcv \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Sets up the TCP information before sending it to be processed. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_local_delivery_finish \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Determines the transport protocol, TCP. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none nf_hook_slow \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_local_delivery \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Reassembles IP fragments \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_rcv_finish \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Creates the correct dst_entry and ip_option structure is populated. \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Calls ip_local_delivery using an abstract function pointer. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none nf_hook_slow \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none ip_rcv \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Assigns the correct IP version and points the iphdr to the \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none correct spot in memory and validates the checksum \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none netif_rcveive_skb \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Packet is tagged for the correct protocol, IP/TCP. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none process_back_log \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Retrives packet from backlog activated by soft interupt. \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none net_rx_action \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none do_soft_irq \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none Main difference between 2.2 and 2.4 is \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \family roman \series medium \shape up \size normal \emph off \bar no \noun off \color none the inclusion of a soft interupt. \end_inset \end_inset \layout Caption \begin_inset LatexCommand \label{table:RecvBacktrace} \end_inset Backtrace of receiving a packet \end_inset \the_end