23 October 2012

802.11n deployment strategie

To achieve maximum output, a pure 802.11n 5 GHz network is recommended. The 5 GHz band has substantial capacity due to many non-overlapping radio channels and less radio interference as compared to the 2.4 GHz band. An 802.11n-only network may be impractical for many users because they need to support legacy equipment that still is 802.11b/g only. Consequently, it may be more practical in the short term to operate a mixed 802.11b/g/n network until 802.11n hardware becomes more prevalent.

In a mixed-mode system, an optimal solution would be to use a dual-radio access point and place the 802.11b/g traffic on the 2.4 GHz radio and the 802.11n traffic on the 5 GHz radio. This setup assumes that all the 802.11n clients are 5 GHz capable. A technique called "band steering" is used to send 802.11n clients to the 5 GHz band, leaving the 2.4 GHz band for legacy clients. Band steering works by responding only to 5 GHz association requests and not the 2.4 GHz requests from dual-band clients.

802.11n protection mechanisms kick in as soon as an access point hears a legacy device transmitting on the same channel. The legacy device does not have to be associated to the 802.11n access point; the access point just needs to hear it on the same channel. 802.11n standardized support for increased data rate, short guard interval (800us to 400us), 40 MHz channels etc...

MIMO techniques:
- Spatial Multiplexing - this requires MIMO client capable of receiving and de-multiplexing N spatial streams. a 3x3:2 MIMO access point can transmit and receive 2 data streams on its 3 antennas.
- Maximal Ratio Combining (MRC) - MRC is a receive-side MIMO technique that takes RF signals from multiple receive antennas and combines them within the radio to effectively boost the signal strength.
- Transmit Beamforming (TxBF) - focus RF energy toward the target receiver (only supported for 802.11n clients). client send special frequency characteristics and channel response information to the access point. This information is used by the AP in calculating the phase adjustment for its next transmission.

Frame Aggregation Techniques:
- MSDU Aggregation (A-MSDU) - The maximum A-MSDU size allowed by 802.11n is 8192 bytes. The disadvantage of aggregating A-MSDU is that each frame is only protected by a single checksum and the overhead of having to retransmit the entire A-MSDU again.
- MPDU Aggregation with Block ACKs - MPDU (MAC Protocol Data Unit) aggregation gathers 802.11 frames, which each already have an 802.11 header for the same destination and transmits them as a single frame. One of the disadvantages of MPDU aggregation is that each 802.11 frame needs to be encrypted separately, adding encryption overhead.
- Reduced Interframe Spacing (RIFS)



Reference:
http://en.wikipedia.org/wiki/IEEE_802.11n-2009#Deployment_strategies
http://mcsindex.com/
http://www.motorola.com/web/Business/_Documents/White%20Paper/_Static%20files/802%2011nDEM_WP_v4_0209.pdf

21 October 2012

memory allocator

In C - dynamic memory allocation is done using malloc, realloc, calloc and free.

In linux kernel:
__get_free_pages() allocates memory from buddy system
-> /proc/buddyinfo
kmalloc() returns memory from slab caches
-> with slab allocation, memory chunks suitable to fit data objects of certain type or size are preallocated.
-> good for 32bytes to 32pages
-> /proc/slabinfo

In linux user space:
The GNU C library (glibc) uses an allocator based on dlmalloc ("Doug Lea's Malloc").
Allocated memory contains an 8 or 16 byte overhead for the size of the chunk and usage flags.

For requests below 256 bytes (a "smallbin" request), a simple two power best fit allocator is used. If there are no free blocks in that bin, a block from the next highest bin is split in two.

For requests of 256 bytes or above but below the mmap threshold, dlmalloc use an in-place bitwise trie algorithm.

For requests above the mmap threshold (a "largebin" request), the memory is always allocated using the mmap system call. The threshold is usually 256 KB.


Reference:
http://en.wikipedia.org/wiki/C_dynamic_memory_allocation#dlmalloc
http://www.win.tue.nl/~aeb/linux/lk/lk-9.html#ss9.3
http://en.wikipedia.org/wiki/Slab_allocation
http://en.wikipedia.org/wiki/Trie#Bitwise_tries

19 October 2012

TLB

Why Virtual Memory?
 - to handle shortage of memory
   - more active process than physical memory can hold
 - to handle excess memory
   - 32bit processor could support 64GB of RAM
 - to support multiprogramming
   - memory protection
   - memory sharing

Advantages of paging
 - allocation of memory is easy and cheap
 - no external fragmentation
Disadvantages of paging
 - mapping table overhead
 - internal fragmentation

A TLB is part of the chip’s memory-management unit (MMU), and is simply a hardware cache of popular virtual-to-physical address translations. A typical TLB might have 32, 64, or 128 entries.

The MIPS R4000 supports a 32-bit address space with 4KB pages. The VPN translates to up to a 24-bit PFN, and hence can support systems with up to 64GB of (physical) main memory (2^24 4KB pages).
- global bit (G), globally-shared page
- address space identifier (ASID)
- Coherence (C) bits, how a page is cached by the hardware
- a valid bit, a valid translation present in the entry.
- a page mask, for multiple page sizes




if the number of pages a program accesses in a short period of time exceeds the number of pages that fit into the TLB, the program will generate a large number of TLB misses, and thus run quite a bit more slowly.
- database management system (a DBMS), which have certain data structures that are both large and randomly-accessed.

Reference:
http://pages.cs.wisc.edu/~remzi/OSFEP/vm-tlbs.pdf
http://cs.nyu.edu/~gottlieb/courses/2000-01-fall/arch/lectures/lecture-23.html
http://www.slideshare.net/vitlic/linux-memory