03 April 2013

TCP/IP Buffer Sizes in Linux


TCP along with managing the basic data transfer process, also ensures that data is sent reliably. It manage the flow of data between devices to ensure that data is transferred efficiently without either device sending data faster than the other can receive it.

Managing Retransmission for reliability


To ensure the delivery of data packets, TCP has its own mechanism of retransmission.
The TCP system works according to the following specific sequence:

Placement On Retransmission Queue: As soon as a segment containing data is transmitted, a copy of the segment is placed in a data structure called the retransmission queue. A retransmission timer is started for the segment when it is placed on the queue. The queue is kept sorted by the time remaining in the retransmission timer, so the TCP software can keep track of which timers have the least time remaining before they expire.

Acknowledgment Processing
: If an acknowledgment is received for a segment before its timer expires, the segment is removed from the retransmission queue.

Retransmission Timeout
: If an acknowledgment is not received before the timer for a segment expires, a retransmission timeout occurs, and the segment is automatically retransmitted.


What does TCP Window mean?

Client's Receive window: In a client server connection, the client tells the server the number of bytes it can receive at a time from the server. This is client's receive limit at a time and this becomes server's send window.

Server's Receive Window: Similarly, he server tells the client how many bytes of data it can take from the client at one time; this is the server's receive window and the client's send window.

TCP Window Size

TCP Window Size



TCP/IP related parameters in Linux


All TCP/IP tunning parameters are located under /proc/sys/net/...  Here is a list of the most important tunning parameters, along with short description of their meaning:


/proc/sys/net/core/rmem_max - Maximum read buffer size for all protocols
/proc/sys/net/core/wmem_max - Maximum write buffer size for all protocols

/proc/sys/net/ipv4/tcp_rmem - TCP read buffer size
/proc/sys/net/ipv4/tcp_wmem - TCP write buffer size

/proc/sys/net/ipv4/tcp_timestamps - timestamps add 12 bytes to the TCP header
/proc/sys/net/ipv4/tcp_sack - tcp selective acknowledgements.
/proc/sys/net/ipv4/tcp_window_scaling - support for large TCP Windows. Needs to be set to 1 if the Max TCP Window is over 65535.


Keep in mind everything under /proc is volatile, so any changes you make are lost after reboot.

Linux Tune Network Buffers for improved performance

The Linux network stack is not configured for high speed network transfers. This is done to preserve the kernel memory resources. The developers can easily tune these network stack parameters to meet their needs at server/client side.

You can easily find the actual values of network buffer parameters using the cat command as below:

$ cat /proc/sys/net/ipv4/tcp_rmem                 // read the tcp buffer size

To tune the parameters, make the changes to /etc/sysctl.conf

1. Tune the core buffer sizes
echo 'net.core.wmem_max = 12582912'  >>  /etc/sysctl.conf
echo 'net.core.rmem_max = 12582912' >> /etc/sysctl.conf

2. Tune the TCP receive and send buffers

echo 'net.ipv4.tcp_rmem = 10240 87380 12582912'  >>  /etc/sysctl.conf
echo 'net.ipv4.tcp_wmem = 10240 87380 12582912'  >>  /etc/sysctl.conf


3. Turn on window scaling to enlarge the transfer window:
echo 'net.ipv4.tcp_window_scaling = 1'  >>  /etc/sysctl.conf

4. Enable timestamps and selective acknowledgements:
echo 'net.ipv4.tcp_timestamps = 1'  >>  /etc/sysctl.conf
echo 'net.ipv4.tcp_sack = 1'  >>  /etc/sysctl.conf

5. Now reload the changes:
sysctl -p

Use Wireshark to monitor TCP Window

There are a few ways to monitor the tcp window with Wireshark. By default, the TCP window of the packet sender is displayed in the info summary view for each ACK packet.

Another way to show this is by using the I/O Graphs looking for the TCP Window Size to drop. To do this, use the tcp.analysis.window_update filter. Try it with the sample trace file using these settings. 

TCP Window on Wireshark

TCP Window on Wireshark


This graph shows the full size TCP Window dropping to nothing several times. While the window is down near zero, data is halted while the sender waits for the receive buffer to clear. Watch for these dips during large data transfers. The I/O graph makes them easier to see than combing through packet by packet!

If there are any questions about the sample trace file, or more about the function of the TCP Window, feel free to email or comment.

07 February 2013

General Packet Radio Service (GPRS)


Introduction

GPRS, as it reads General Packet Radio Service, was initialized by ETSI/SMG in 1994, to provide end-to-end packet-switched services to mobile users. GPRS was important as a migration step toward third-generation (3G) networks and allows network operators to implement an IP-based core architecture for data applications, which will continue to be used and expanded for 3G services for integrated voice and data applications.

Many Problems Solved 

GPRS enabled a variety of new and unique services to the mobile wireless subscriber. These features include the following:

Mobility: The ability to maintain constant voice and data communications while on the move.

Immediacy: Allowed subscribers to obtain connectivity when needed, regardless of location and without a lengthy login session.

Localization: Allowed subscribers to obtain information relevant to their current location.



GPRS Architecture

GPRS is a data network that overlays a second-generation GSM network. This data overlay network provides packet data transport at rates from 9.6 to 171 kbps. Additionally, multiple users can share the same air-interface resources simultaneously.

Following is the GPRS Architecture diagram:

GPRS Architecture

GPRS Architecture




Following two new components, called GPRS support nodes (GSNs), are added into existing GSM architecture with a few modifications in BSS and BSC:

Gateway GPRS support node (GGSN):
The Gateway GPRS Support Node acts as an interface and a router to external networks. The GGSN contains routing information for GPRS mobiles, which is used to tunnel packets through the IP based internal backbone to the correct Serving GPRS Support Node. The GGSN also collects charging information connected to the use of the external data networks and can act as a packet filter for incoming traffic.

Serving GPRS support node (SGSN):
The Serving GPRS Support Node is responsible for authentication of GPRS mobiles, registration of mobiles in the network, mobility management, and collecting information for charging for the use of the air interface.


GPRS MS Classses

The handset is probably the most well-known piece of equipment, because this is the part we use to make phone calls and to access data services. When we talk about advanced services, the handset is commonly called an MS, which consists of terminal equipment (TE) and a mobile terminal (MT). TE is the device that hosts the applications and the user interaction, while the MT is the part that connects to the network.

In order to take advantage of the new GPRS services, we need new GPRS enabled handsets. There are three different classes of GPRS terminal equipments:

Class A:
Class A terminals can handle packet data and voice at the same time. In other words, we need two transceivers because the handset has to send and/or receive data and voice at the same time. This situation makes class A terminals significantly more expensive to manufacture than class B and C terminals.

Class B:
Class B terminals can handle both packet data and voice, but not at the same time. In other words, you can use the same transceiver for both, keeping the cost of the terminals down.

Class C:
Class C terminals can only handle either voice or data. Examples of class C terminals are GPRS PCM/CIA cards, embedded modules in vending machines, and so on.


Network Processes

This gives a brief description of the basic processes used in GPRS networks:
  • Attach process: Process by which the MS attaches (i.e, connects) to the SGSN in a GPRS network
  • Authentication process: Process by which the SGSN authenticates the mobile subscriber
  • PDP activation process: Process by which a user session is established between the MS and the destination network
  • Detach process: Process by which the MS detaches (i.e., disconnects) from the SGSN in the GPRS network
  • Network-initiated PDP request for static IP address: Process by which a call from the packet data network reaches the MS using a static IP address
  • Network-initiated PDP request for dynamic IP address: Process by which a call from the packet data network reaches the MS using a dynamic IP address 
All the latest GSM phones available in the market are enabled to use GPRS services. So if you are planning to buy a GPRS enabled mobile phone then most probably you have to choose one GSM Mobile Phone unless you are using CDMA technology.

GPRS is a crucial step in the mobile evolution, and it opens endless possibilities for application developers and users. In the next article I will talk about UMTS and other 3G technologies.


23 January 2013

GPRS signalling in Dual Transfer Mode


A MS in Dual Transfer Mode (DTM) has resources for an RR (Radio Resource) connection and is simultaneously allocated resources for one or more TBFs (Temporary Block Flow in GPRS network), provided that the BSS co-ordinates its allocation of radio resources. DTM is optional
both for the MS and the network. A DTM mobile is a class A mobile.

Introduction

The definition of GPRS class A mode of operation in Release 97 assumes a total independence between the CS and PS domains. Thus the direct implementation would result in MS that are required to operate in two different frequencies either in the same time slot or different time slots.

Also, operators have expressed their needs to offer services that allow the simultaneous existence of a CS connection and a PS session in GSM/GPRS coverage area due to unavailability of UMTS in all areas.

The DTM solution overcomes the restrictions mentioned above and makes possible to have simultaneous CS and PS active connections. This is achieved by sending PS data (signaling and user data) on the time slot used by the CS connection or other time slot(s) that in both directions are contiguous with the time slot used by the CS connection.

PS data established over DTM

PS data established over DTM


GPRS signalling over DCCH

In DTM, the MS has resources allocated for an RR connection and for one or more TBFs. So the current GPRS resources are used for the transfer of GPRS signalling instead of the main DCCH (Dedicated Control Channel).
The use of the main DCCH  is only allowed when the MS is in dedicated mode.

GPRS signaling over DCCH

GPRS signaling over DCCH


MS-SGSN tunnelling

If GPRS signaling needs to be sent during a voice call (i.e. in dedicated mode), then LLC (Logical Link Connection) frames are sent on the main DCCH with Layer 2 SAPI 0. This uses a new Protocol Discriminator in Signaling Layer 3 message structure for LLC: GTTP (GPRS Transparent Transport Protocol).

The GPRS information from upper layers (i.e. GMM or SM) is always sent inside an LLC frame. This LLC frame can now be passed down:
  • to RLC (Radio Link Control) and transmitted on a TBF; or
  • to RR, if the MS is in dedicated mode, and transmitted on the main DCCH.
The new tunneling mechanism for the transmission of the LLC frame is shown graphically.

LLC PDU over DCCH

LLC PDU over DCCH


The LLC PDU is inserted in a new Layer 3 message, with a new Protocol Discriminator (GTTP) so that the BSC identifies the tunneling mechanism without the need to analyze the Message Type. This Layer 3 message is sent to the BSC on the main DCCH, with the existing Layer 2 mechanisms. The BTS re-assemblies the Layer 3 message and sends it to the BSC.

Single slot operation


If the MS in DTM has one TimeSlot allocated for the CS services, it is possible to reuse the same TS for the transmission of GPRS signaling and user data. In such case the CS information and RLC/MAC blocks are multiplexed in the same TS of the TDMA frame.

The configuration of logical channels used in that case is called ‘TCH/H+ PDCH/H’, which means that on one physical channel network configures one CS half rate connection and PS connection uses the remaining half of the physical channel.

This configuration is very useful when it is impossible for the network to allocate a TBF in some circumstances on separate TS (e.g. congested cell, multi slot capabilities not supported in the serving cell). 

On the 'TCH/H' part, the support of AMR as the speech codec is mandatory.
The PDCH/H is a resource dedicated (allocated exclusively) to the MS in both directions and can not be shared with other GPRS MS. For instance, if an uplink TBF is established, the network may send a control message in any of the downlink blocks. No downlink data, however, are sent without a previous downlink assignment.
In the uplink, the MS transmits in any of the blocks of the PDCH/H, irrespective of the USF in the previous blocks.

Multi slot operation


In multi slot operation, the GPRS data is sent on a PDCH. The number of time slots comprising the PDCH is decided by the network after taking into account the multi slot capabilities supported by the MS. The PDCH/F may be shared with other GPRS MS.

This article explains the basic GPRS signaling in DTM. More would be coming up to explain the signaling procedures during MO and MT call. Furthermore, I will discuss the need of DTM in today's scenario where UMTS and HSPA are taking lead.

About Me

My photo
Passionate about technology and humans