SlideShare una empresa de Scribd logo
1 de 34
M. S. Ramaiah School of Advanced Studies 1
CSN2503 NP Presentation
IrDA in Linux Kernel
Anshuman Biswal
PT 2012 Batch, Reg. No.: CJB0412001
M. Sc. (Engg.) in Computer Science and Networking
Module Leader: Rinki Sharma
Module Name: Network Programming
Module Code : CSN2503
M. S. Ramaiah School of Advanced Studies 2
Presentation Outline
• Introduction
– IrDA
– Security and Operating Range
• Linux architecture with IrDA
• IrDA Stack
• IrDA in the Linux Kernel
• Communicating using IrDA
– SIR mode
– FIR mode
– Transferring of Files
• IrDA sockets
– Hint Bits
– Socket options
– Sample code to discover IrDA devices
– Sample code of simple echo server
• Conclusion
• References
M. S. Ramaiah School of Advanced Studies 3
Introduction - Infrared
• Infrared is a legacy technology. It has lousy range
and can be a hassle to set up, but sometimes, it's
the only common communications medium
between your Linux box and something you want
to talk to.
• Infrared is a wireless communication technology
that makes use of the invisible spectrum of light
that is just beyond red in the visible spectrum.
• It's suitable for applications that require short-
range, point-to-point data transfer. Because it uses
light, line of sight is a prerequisite for using
infrared.
• In terms of operating range, infrared devices can
communicate up to one or two meters. Depending
on the implementation, if a device uses a lower
power version, the range can be stepped down to a
mere 20 to 30 cm. This is crucial for low-power
devices.
M. S. Ramaiah School of Advanced Studies 4
Introduction- IrDA
• Founded in 1993 as a nonprofit organization, the Infrared Data Association
(IrDA) is an international organization that creates and promotes interoperable,
low-cost infrared data interconnection standards that allow users to transfer
data from one device to another. The term IrDA is typically used to refer to
the protocols for infrared communications, not exclusively to the
nonprofit body.
• There are currently four versions of IrDA; their differences are mainly in the
transfer speed:
Serial Infrared (SIR)- The original standard with a transfer speed of up
to 115 kbps
Medium Infrared (MIR)- Improved transfer speed of 1.152 Mbps; it is
not widely implemented
Fast Infrared (FIR)- Speed of up to 4 Mbps; most new computers
implement this standard
Very Fast Infrared (VFIR)-Speed of up to 16 Mbps; it is not widely
implemented yet
• When two devices with two different IrDA implementations communicate,
one steps down to the lower transfer speed.
M. S. Ramaiah School of Advanced Studies 5
Introduction-Security and Operating Range
• A Cyclic Redundancy Check (CRC), which uses a number
derived from the transmitted data to verify its integrity,
protects all exchanged data packets. CRC-16 is used for
speeds up to 1.152 Mbps, and CRC-32 is used for speeds
up to 4 Mbps. The IrDA also defines a bi-directional
communication for infrared communications.
• An infrared connection operates at a range of 0 to 1 meter,
with peak intensity within a 30-degree cone. With more
power, a longer operating range is possible with a
reduction in transfer speed. In addition, an infrared
connection requires a visual line of sight in order to work,
so there cannot be any direct obstruction between the two
communicating devices.
M. S. Ramaiah School of Advanced Studies 6
Linux Architecture with IrDA
M. S. Ramaiah School of Advanced Studies 7
• Linux supports IR communication on two planes:
• Intelligent data-transfer via protocols specified by the Infrared Data
Association (IrDA). This is implemented by the Linux-IrDA project.
• Controlling applications via a remote control. This is implemented by the Linux
Infrared Remote Control (LIRC) project.
• Device drivers constitute the bottom layer. SIR chipsets that are 16550-compatible uses the
native Linux serial driver after porting it using the IrDA line discipline with IrTTY. An
alternative to this combo is the IrPort driver. FIR chipsets have their own special drivers.
• Next comes the core protocol stack. This consists of the IR Link Access
Protocol (IrLAP), IR Link Management protocol (IrLMP), Tiny Transport
Protocol (TinyTP), and the IrDA socket (IrSock) interface.
• Higher regions of the stack join IrDA to data-transfer applications. IrLAN and IrNET
enable networking, while IrComm allows serial communication.
• openobex which implements the OBject EXchange (OBEX) protocol is used to exchange
objects such as documents and visiting cards.
• To configure Linux-IrDA, you need the irda-utils. This provides tools such
as irattach, irdadump, and irdaping.
Linux Architecture with IrDA
M. S. Ramaiah School of Advanced Studies 8
IrDA Stack
The IrDA protocol consist manily of three diffrent layers:
M. S. Ramaiah School of Advanced Studies 9
• Physical layer -
• first layer from bottom up in hierarchical stack
• deals directly with
– bit encoding
– error checking and correction
– transmiting and receiving data
• Network Layer: Link Access Protocol (IrLAP)
• second layer on hierarchical stack
• uses services provided by physical layer
• defines services provided by the protocol
• sets vocabulary, encoding and procedures rules
• provides a reliable transport as well as the state machine to discover
neighboring devices
IrDA Stack
M. S. Ramaiah School of Advanced Studies 10
• Transport layer: Link Management Protocol (IrLMP)
• support walk-up and point to point connection between IrDA devices
• provides and supports for multiple software applications
• allows entities to operate independently
• IrLMP is a multiplexer over IrLAP
• TinyTP provides segmentation, reassembly, and flow control.
• IrSock offers a socket interface over IrLMP and TinyTP.
IrDA Stack
M. S. Ramaiah School of Advanced Studies 11
IrDA in the Kernel
• If your hardware supports SIR mode, this is usually straightforward. FIR configuration
is still somewhat difficult, unless you have a system that's supported right out of the
box.
• Most modern notebooks support FIR by default, but you can often go into the BIOS
setup and change it to SIR. Even if you want FIR to work, be sure to try SIR first,
because it's usually the simplest.
• Most modern kernels have all the support that you need to get infrared to work. If you
build your own kernel, make sure that you've enabled infrared support. Most of the
infrared support is configured under the IrDA (Infrared) Support section that appears in
the kernel configuration.
• To enable IrDA support in your Kernel first get the kernel source from
http://kernel.org/pub/linux/kernel
• To know your current kernel version you can type in the command uname –r . So to
upgrade the kernel download the version above the current version from the above site.
• The kernel tar ball is distributed in both GNU zip (gzip) and bzip2 (better compressed)
format.
• The Linux kernel tar ball in bzip2 format is named linux-x.y.z.tar.bz2, where x.y.z is the
version of that particular release of the kernel source.
M. S. Ramaiah School of Advanced Studies 12
• After downloading the source, uncompressing and un tarring it.
• If your tar ball is compressed with bzip2, run
• $ tar xvjf linux-x.y.z.tar.bz2
• If it is compressed with GNU zip, run
• $ tar xvzf linux-x.y.z.tar.gz
• This un tars the source to the directory linux-x.y.z.
• Before we do anything with the sources, we should make sure the source tree
does not contain any old object files or configuration information...That got
there accidentally.
• This is especially true for distribution kernels-they tend to contain various stale
files.
• To do this, go into the source directory and run the command:
$ sudo make mrproper
$sudo make clean
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 13
• Several configuration programs are supported by the kernel. But best is to use
$ sudo make menuconfig . If you get error while running this command
because of nCurses library then install the library as
– sudo apt-get install libncurses5-dev
before running make menuconfig
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 14
• IrDA is a network protocol, so it can be found under the networking main
menu in the menuconfig.
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 15
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 16
• Save the menuconfig
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 17
• Once configured, Compiling the kernel is easy.
• To compile the kernel's main part
$ sudo make bzImage
If the make is success you will get the output as
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 18
• SYSCALL arch/i386/kernel/vsyscall-int80.so gcc: error: elf_i386: No such file
or directory make[1]: if you get this error while doing a make bzImage then go
to arch/x86/vdso/Makefile and search for word VDSO_LDFLAGS there exists
two lines one for x64 and another for x32 bit systems.it should have -m
elf_x86_64 and another one -m elf_x86 replace them like -m64 and -m32
respectively save it and again do the make bzImage
• First, Compile the kernel, only the code which is added statically
$ sudo make
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 19
• Compile the code of the kernel for the features which are added as modules
$ sudo make modules
• Install the compiled module object code into the compiled kernel. As root simply run
$ sudo make modules_install
• This installs all the compiled modules to their correct home under /lib/modules
• Now install your new kernel!
$ sudo make install
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 20
• Since initramfs usually needs to be customized for the particular
hardware/device configuration and kernel version, they are not included as a
part of any package, but are generated on the fly at kernel installation time. To
customize the initramfs for particular onfiguration and kernel version,
generated at the installation time use
$ sudo update-initramfs –c –d 2.6.31.5 ( if required)
$ sudo update-initramfs –c –k 2.6.31.5
• Once we installed the new kernel and its new modules, we need to tell the boot
loader about it.
$ sudo update-grub
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 21
• Once everything is set, reboot your machine.
• At the boot loader's prompt/menu, chose the new kernel.
• Now install the necessary software packages irda-utils and ircp-tray.
$ sudo apt-get install irda-utils ircp-tray
• Install setserial package
$ sudo apt-get install setserial
• Now run the below command to edit the irda-utils file
$ gksu gedit /etc/default/irda-utils
In the configuration file which opens up, change the line
reading DEVICE="/dev/ttyS1" to DEVICE="irda0“ and the line
reading SETSERIAL="" to SETSERIAL="/dev/ttyS1“
IrDA in the Kernel
M. S. Ramaiah School of Advanced Studies 22
• Two devices can communicate using IrDA. For this using the above method
build your Linux kernel with IrDA enable for both the devices that you want to
establish communication between using IrDA.
• SIR chips offer a UART interface to the host computer. For communicating in
SIR mode, attach the associated UART port (/dev/ttyS1 for example) of each
laptop to the IrDA stack:
$ sudo irattach /dev/ttyS1 –s
• Verify that IrDA kernel modules (irda.ko, sir_dev.ko, and irtty_sir.ko) are
loaded and that the irda_sir_wq kernel thread is running. The irda0 interface
should also have made an appearance in the ifconfig output. The -s option
to irattach triggers a search for IR activity in the neighborhood. If you slide the
laptops such that their IR transceivers lie within the range cone, they will be
able to spot each other:
$ sudo cat /proc/net/irda/discovery
IrLMP: Discovery log:
nickname: localhost, hint: 0x4400, saddr: 0x55529048, daddr:
0x8fefb350
Communicating using IrDA-SIR mode
M. S. Ramaiah School of Advanced Studies 23
• The other laptop makes a similar announcement, but with the source and destination
addresses (saddr and daddr) reversed.
• You may set the desired communication speed using stty on ttyS1. To set the baud rate to
19200, do this:
– $ sudo stty speed 19200 < /dev/ttyS1
• The easiest way to cull IR activity from the air is by using the debug tool, irdadump
$ sudo irdadump -i irda0
• You can also obtain debug information out of the IrDA stack by controlling the verbosity
level in /proc/sys/net/irda/debug
Communicating using IrDA-SIR mode
M. S. Ramaiah School of Advanced Studies 24
• To set the laptops in FIR mode, dissociate ttyS1 from the native serial driver
and instead attach it to the NSC FIR driver, nsc-ircc.ko:
$ sudo setserial /dev/ttyS1 uart none
$ sudo modprobe nsc-ircc dongle_id=0x09
$ sudo irattach irda0 -s
dongle_id depends on your IR hardware and can be found from your
hardware documentation. As you did for SIR, take a look
at /proc/net/irda/discovery to see whether things are okay thus far.
• Sometimes, FIR communication hangs at higher speeds. If irdadump shows a
communication freeze, then fix the code, or try lowering the negotiated speed
by tweaking/proc/sys/net/irda/max_baud_rate.
• For device example of IR dongle driver you can see the
file drivers/net/irda/tekram.c and drivers/net/irda/ep7211_ir.c.
Communicating using IrDA-FIR mode
M. S. Ramaiah School of Advanced Studies 25
• Transferring The Files
• Install the openobex-apps package.
$ sudo apt-get install openobex-apps
• Then open the terminal and type irxfer
$ irxfer XXXX.mp3
On successful it will say Put Successful
Communicating using IrDA-Transferring of Files
M. S. Ramaiah School of Advanced Studies 26
IrDA Sockets
• To develop custom applications over IrDA, use the IrSock interface. To create
a socket over TinyTP, do this:
int fd = socket(AF_IRDA, SOCK_STREAM, 0);
• For a datagram socket over IrLMP, do this:
int fd = socket(AF_IRDA, SOCK_DGRAM, 0);
• To get the list of device discovery and there info IrDA uses a structure to hold
the information in
• struct irda_device_list {
u_int32_t numDevice;
struct irda_device_info Device[1];};
• struct irda_device_info {
u_int32_t saddr; /* Address of local interface */
u_int32_t irdaDeviceID; /* Address of remote device */
char irdaDeviceName[22]; /* Description */
u_int8_t charset; /* Charset used for description */
u_int8_t hints[2]; /* Hint bits */ };
M. S. Ramaiah School of Advanced Studies 27
• The irda_device_info struct has a two byte hint array. The hint bits can give
info about that a given IrDA device is and what it supports. Here is a list of the
available bits from /usr/include/linux/irda.h
IrDA Sockets-Hint Bits
Hint bit positions for first hint byte Hint bit positions for second hint byte (first extension byte)
HINT_PNP HINT_TELEPHONY
HINT_PDA HINT_FILE_SERVER
HINT_COMPUTER HINT_COMM
HINT_PRINTER HINT_MESSAGE
HINT_MODEM HINT_HTTP
HINT_FAX HINT_OBEX
HINT_LAN
HINT_EXTENSION: If this is set the next byte is valid
M. S. Ramaiah School of Advanced Studies 28
IrDA Sockets- SOL_IRLMP Socket Options
Option Get Set Optval type Description
IRLMP_DISCOVERY_MODE
IRLMP_ENUMDEVICES yes DEVICELIST Returns a list of IrDA device IDs for IR capable
devices within range.
IRLMP_EXCLUSIVE_MODE DWORD (boolean) Sets socket to bypass TinyTP layer to directly
communicate with IrLMP.
IRLMP_IAS_QUERY yes IAS_QUERY Queries IAS on a given service and class name for
its attributes.
IRLMP_IAS_SET yes IAS_SET Sets an attribute value for a given class name and
attribute into IAS.
IRLMP_IRLPT_MODE yes DWORD (boolean) Enables communication with IR capable printers.
IRLMP_PARAMETERS
IRLMP_SEND_PDU_LEN yes DWORD Retrieves the maximum PDU length required to
use IRLMP_9WIRE_MODE.
IRLMP_SHARP_MODE yes
IRLMP_TINYTP_MODE yes
IRLMP_9WIRE_MODE yes yes DWORD (boolean) Puts the IrDA socket into IrCOMM mode.
The following table describes SOL_IRLMP socket options that apply to sockets created for the
Infrared Data Association (IrDA) address family (AF_IRDA) and the InfraRed Link Management
Protocol (IRLMP)
M. S. Ramaiah School of Advanced Studies 29
Sample code to discover the device
fd = socket(AF_IRDA, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
exit(-1);
}
printf("sizeof(struct irda_device_list)=%dn",sizeof(struct
irda_device_list));
printf("sizeof(struct irda_device_info)=%dn",
sizeof(struct irda_device_info));
discover_devices(fd);
IrDA Sockets-Sample code to discover the device
M. S. Ramaiah School of Advanced Studies 30
struct irda_device_list *list;
len = sizeof(struct irda_device_list) +sizeof(struct irda_device_info) *
MAX_DEVICES;
buf = malloc(len);
list = (struct irda_device_list *) buf;
if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) {
perror("getsockopt");
exit(-1);
}
if (len > 0) {
printf("Discovered:n");
for (i=0;i<list->len;i++) {
printf(" name: %sn", list->dev[i].info);
printf(" daddr: %08xn", list->dev[i].daddr);
printf(" saddr: %08xn", list->dev[i].saddr);
printf("n");
}
IrDA Sockets-Sample code to discover the device
M. S. Ramaiah School of Advanced Studies 31
struct sockaddr_irda peer, self;
/* Create socket */
fd = socket(AF_IRDA, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
exit(-1);
}
/* Init self */
self.sir_family = AF_IRDA;
self.sir_lsap_sel = LSAP_ANY;
if (bind(fd, (struct sockaddr*) &self, sizeof(struct sockaddr_irda))) {
perror("bind");
return -1;
}if (listen(fd, 8)) {
perror("listen");
return -1; }
IrDA Sockets-Sample echo server
struct sockaddr_irda {
__kernel_sa_family_t sir_family; /* AF_IRDA */
__u8 sir_lsap_sel; /* LSAP selector */
__u32 sir_addr; /* Device address */
char sir_name[25]; /* Usually <service>:IrDA:TinyTP
*/
};
M. S. Ramaiah School of Advanced Studies 32
for (;;) { addrlen = sizeof(struct sockaddr_irda);
printf("Waiting for connection!n");
conn_fd = accept(fd, (struct sockaddr *) &peer, &addrlen);
if (conn_fd < 0) {
perror("accept");
return -1; }
printf("Connected!n");
do {
actual = recv(conn_fd, &buf, sizeof(buf), 0);
if (actual <= 0) break;
printf("Got %d bytesn", actual);
if (!discard) {
actual = send(conn_fd, &buf, actual, 0);
printf("Sent %d bytesn", actual);
} } while (actual > 0);
close(conn_fd);printf("Disconnected!n");
IrDA Sockets-Sample echo server
M. S. Ramaiah School of Advanced Studies 33
Conclusion
• The main reason for using IrDA has been wireless data transfer over the last
one meter using point and shoot principles. Main characteristics of this kind
of wireless optical communication is physically secure data transfer, Line-of-
Sight (LOS) and very low bit error rate (BER) that makes it very efficient.
This has been implemented in portable devices like mobile phones, laptops,
printers, cameras, medical devices and many more.
• Besides the advantages of IrDA, it has certain disadvantages like one device
at a time connection, transfer rate is 4Mbps,have to keep device stable while
transferring data, it is for short range and LOS should be clear.
• Because of the above disadvantages blue tooth came into picture. But still it
cannot overshadow the IrDA uses.
• However more can be done in IrDA for future works like supporting higher
baud rates for faster transmissions,one to many connections etc.
M. S. Ramaiah School of Advanced Studies 34
References
[1] Dumbill,E.,Jepson,B.,Weeks,R. (April 2004) “Linux Unwired”, 1st
Edition:O’Reilly
[2] Wikipedia. “Infrared Data Association”. [Online].Available from:
http://en.wikipedia.org/wiki/Infrared_Data_Association (Accessed:31 March
2014)
[3]Linux-IrDA project by Hewlitt Packard. “Linux-IrDA quick tutorial”[Online].
Available from: http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/
(Accesses:31 March 2014)

Más contenido relacionado

La actualidad más candente

Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
Sunil Thorat
 

La actualidad más candente (20)

Es 2 mark
Es 2 markEs 2 mark
Es 2 mark
 
Bm36382385
Bm36382385Bm36382385
Bm36382385
 
arm-cortex-a8
arm-cortex-a8arm-cortex-a8
arm-cortex-a8
 
Arm Processors Architectures
Arm Processors ArchitecturesArm Processors Architectures
Arm Processors Architectures
 
Chapter22
Chapter22Chapter22
Chapter22
 
ARM Processor Tutorial
ARM Processor Tutorial ARM Processor Tutorial
ARM Processor Tutorial
 
ARM 7 Detailed instruction set
ARM 7 Detailed instruction setARM 7 Detailed instruction set
ARM 7 Detailed instruction set
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 
Unit 3 devices&amp;buses
Unit 3 devices&amp;busesUnit 3 devices&amp;buses
Unit 3 devices&amp;buses
 
ARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introductionARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introduction
 
H344250
H344250H344250
H344250
 
STM32 L4 presentation
STM32 L4 presentation STM32 L4 presentation
STM32 L4 presentation
 
419 426
419 426419 426
419 426
 
MIPI DevCon 2016: MIPI I3C High Data Rate Modes
MIPI DevCon 2016: MIPI I3C High Data Rate ModesMIPI DevCon 2016: MIPI I3C High Data Rate Modes
MIPI DevCon 2016: MIPI I3C High Data Rate Modes
 
Arm
ArmArm
Arm
 
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardProgramming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
 
Comparison between RISC architectures: MIPS, ARM and SPARC
Comparison between RISC architectures: MIPS, ARM and SPARCComparison between RISC architectures: MIPS, ARM and SPARC
Comparison between RISC architectures: MIPS, ARM and SPARC
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architecture
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System Interface
 
Q4.11: ARM Technology Update Plenary
Q4.11: ARM Technology Update PlenaryQ4.11: ARM Technology Update Plenary
Q4.11: ARM Technology Update Plenary
 

Similar a Ir da in_linux_presentation

Bh fed-03-kaminsky
Bh fed-03-kaminskyBh fed-03-kaminsky
Bh fed-03-kaminsky
Dan Kaminsky
 

Similar a Ir da in_linux_presentation (20)

To Infiniband and Beyond
To Infiniband and BeyondTo Infiniband and Beyond
To Infiniband and Beyond
 
BASIC OF ROUTERS,ROUTER IOS AND ROUTING PROTOCOLS
BASIC OF ROUTERS,ROUTER IOS AND ROUTING PROTOCOLSBASIC OF ROUTERS,ROUTER IOS AND ROUTING PROTOCOLS
BASIC OF ROUTERS,ROUTER IOS AND ROUTING PROTOCOLS
 
2017 - LISA - LinkedIn's Distributed Firewall (DFW)
2017 - LISA - LinkedIn's Distributed Firewall (DFW)2017 - LISA - LinkedIn's Distributed Firewall (DFW)
2017 - LISA - LinkedIn's Distributed Firewall (DFW)
 
Update on IRATI technical work after month 6
Update on IRATI technical work after month 6Update on IRATI technical work after month 6
Update on IRATI technical work after month 6
 
Exp2
Exp2Exp2
Exp2
 
chapter 1 &2 RIPv1&2.ppt
chapter 1 &2 RIPv1&2.pptchapter 1 &2 RIPv1&2.ppt
chapter 1 &2 RIPv1&2.ppt
 
Renaissance of sparc UKOUG 2014
Renaissance of sparc UKOUG 2014Renaissance of sparc UKOUG 2014
Renaissance of sparc UKOUG 2014
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDK
 
pps Matters
pps Matterspps Matters
pps Matters
 
Basic Introduction to Technology (networking).pdf
Basic Introduction to Technology (networking).pdfBasic Introduction to Technology (networking).pdf
Basic Introduction to Technology (networking).pdf
 
InfiniBand in the Lab (vSphere 5.5) VMworld 2013 Barcelona vBrownbag Tech Talk
InfiniBand in the Lab (vSphere 5.5) VMworld 2013 Barcelona vBrownbag Tech TalkInfiniBand in the Lab (vSphere 5.5) VMworld 2013 Barcelona vBrownbag Tech Talk
InfiniBand in the Lab (vSphere 5.5) VMworld 2013 Barcelona vBrownbag Tech Talk
 
hakin9_6-2006_str22-33_snort_EN
hakin9_6-2006_str22-33_snort_ENhakin9_6-2006_str22-33_snort_EN
hakin9_6-2006_str22-33_snort_EN
 
Bh fed-03-kaminsky
Bh fed-03-kaminskyBh fed-03-kaminsky
Bh fed-03-kaminsky
 
Accelerating Shuffle: A Tailor-Made RDMA Solution for Apache Spark with Yuval...
Accelerating Shuffle: A Tailor-Made RDMA Solution for Apache Spark with Yuval...Accelerating Shuffle: A Tailor-Made RDMA Solution for Apache Spark with Yuval...
Accelerating Shuffle: A Tailor-Made RDMA Solution for Apache Spark with Yuval...
 
5G Cellular D2D RDMA Clusters
5G Cellular D2D RDMA Clusters5G Cellular D2D RDMA Clusters
5G Cellular D2D RDMA Clusters
 
High performance content hosting
High performance content hosting High performance content hosting
High performance content hosting
 
Kira128i
Kira128iKira128i
Kira128i
 
Rac on NFS
Rac on NFSRac on NFS
Rac on NFS
 
CCNA Industrial Training Presentation
CCNA Industrial Training PresentationCCNA Industrial Training Presentation
CCNA Industrial Training Presentation
 
IBTA Releases Updated Specification for RoCEv2
IBTA Releases Updated Specification for RoCEv2IBTA Releases Updated Specification for RoCEv2
IBTA Releases Updated Specification for RoCEv2
 

Más de Anshuman Biswal

Bangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagyaBangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagya
Anshuman Biswal
 
Six Sigma and/For Software Engineering
Six Sigma and/For Software EngineeringSix Sigma and/For Software Engineering
Six Sigma and/For Software Engineering
Anshuman Biswal
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grails
Anshuman Biswal
 

Más de Anshuman Biswal (12)

भक्ति वृक्षा – CHAPTER 1 (1).pptx
भक्ति वृक्षा – CHAPTER 1 (1).pptxभक्ति वृक्षा – CHAPTER 1 (1).pptx
भक्ति वृक्षा – CHAPTER 1 (1).pptx
 
Wireless Networking Security
Wireless Networking SecurityWireless Networking Security
Wireless Networking Security
 
Pervasive Computing
Pervasive ComputingPervasive Computing
Pervasive Computing
 
Observer Pattern
Observer PatternObserver Pattern
Observer Pattern
 
Undecidabality
UndecidabalityUndecidabality
Undecidabality
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Array Processor
Array ProcessorArray Processor
Array Processor
 
Bangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagyaBangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagya
 
Six Sigma and/For Software Engineering
Six Sigma and/For Software EngineeringSix Sigma and/For Software Engineering
Six Sigma and/For Software Engineering
 
SNMP
SNMPSNMP
SNMP
 
Fibonacci Heap
Fibonacci HeapFibonacci Heap
Fibonacci Heap
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grails
 

Último

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

Ir da in_linux_presentation

  • 1. M. S. Ramaiah School of Advanced Studies 1 CSN2503 NP Presentation IrDA in Linux Kernel Anshuman Biswal PT 2012 Batch, Reg. No.: CJB0412001 M. Sc. (Engg.) in Computer Science and Networking Module Leader: Rinki Sharma Module Name: Network Programming Module Code : CSN2503
  • 2. M. S. Ramaiah School of Advanced Studies 2 Presentation Outline • Introduction – IrDA – Security and Operating Range • Linux architecture with IrDA • IrDA Stack • IrDA in the Linux Kernel • Communicating using IrDA – SIR mode – FIR mode – Transferring of Files • IrDA sockets – Hint Bits – Socket options – Sample code to discover IrDA devices – Sample code of simple echo server • Conclusion • References
  • 3. M. S. Ramaiah School of Advanced Studies 3 Introduction - Infrared • Infrared is a legacy technology. It has lousy range and can be a hassle to set up, but sometimes, it's the only common communications medium between your Linux box and something you want to talk to. • Infrared is a wireless communication technology that makes use of the invisible spectrum of light that is just beyond red in the visible spectrum. • It's suitable for applications that require short- range, point-to-point data transfer. Because it uses light, line of sight is a prerequisite for using infrared. • In terms of operating range, infrared devices can communicate up to one or two meters. Depending on the implementation, if a device uses a lower power version, the range can be stepped down to a mere 20 to 30 cm. This is crucial for low-power devices.
  • 4. M. S. Ramaiah School of Advanced Studies 4 Introduction- IrDA • Founded in 1993 as a nonprofit organization, the Infrared Data Association (IrDA) is an international organization that creates and promotes interoperable, low-cost infrared data interconnection standards that allow users to transfer data from one device to another. The term IrDA is typically used to refer to the protocols for infrared communications, not exclusively to the nonprofit body. • There are currently four versions of IrDA; their differences are mainly in the transfer speed: Serial Infrared (SIR)- The original standard with a transfer speed of up to 115 kbps Medium Infrared (MIR)- Improved transfer speed of 1.152 Mbps; it is not widely implemented Fast Infrared (FIR)- Speed of up to 4 Mbps; most new computers implement this standard Very Fast Infrared (VFIR)-Speed of up to 16 Mbps; it is not widely implemented yet • When two devices with two different IrDA implementations communicate, one steps down to the lower transfer speed.
  • 5. M. S. Ramaiah School of Advanced Studies 5 Introduction-Security and Operating Range • A Cyclic Redundancy Check (CRC), which uses a number derived from the transmitted data to verify its integrity, protects all exchanged data packets. CRC-16 is used for speeds up to 1.152 Mbps, and CRC-32 is used for speeds up to 4 Mbps. The IrDA also defines a bi-directional communication for infrared communications. • An infrared connection operates at a range of 0 to 1 meter, with peak intensity within a 30-degree cone. With more power, a longer operating range is possible with a reduction in transfer speed. In addition, an infrared connection requires a visual line of sight in order to work, so there cannot be any direct obstruction between the two communicating devices.
  • 6. M. S. Ramaiah School of Advanced Studies 6 Linux Architecture with IrDA
  • 7. M. S. Ramaiah School of Advanced Studies 7 • Linux supports IR communication on two planes: • Intelligent data-transfer via protocols specified by the Infrared Data Association (IrDA). This is implemented by the Linux-IrDA project. • Controlling applications via a remote control. This is implemented by the Linux Infrared Remote Control (LIRC) project. • Device drivers constitute the bottom layer. SIR chipsets that are 16550-compatible uses the native Linux serial driver after porting it using the IrDA line discipline with IrTTY. An alternative to this combo is the IrPort driver. FIR chipsets have their own special drivers. • Next comes the core protocol stack. This consists of the IR Link Access Protocol (IrLAP), IR Link Management protocol (IrLMP), Tiny Transport Protocol (TinyTP), and the IrDA socket (IrSock) interface. • Higher regions of the stack join IrDA to data-transfer applications. IrLAN and IrNET enable networking, while IrComm allows serial communication. • openobex which implements the OBject EXchange (OBEX) protocol is used to exchange objects such as documents and visiting cards. • To configure Linux-IrDA, you need the irda-utils. This provides tools such as irattach, irdadump, and irdaping. Linux Architecture with IrDA
  • 8. M. S. Ramaiah School of Advanced Studies 8 IrDA Stack The IrDA protocol consist manily of three diffrent layers:
  • 9. M. S. Ramaiah School of Advanced Studies 9 • Physical layer - • first layer from bottom up in hierarchical stack • deals directly with – bit encoding – error checking and correction – transmiting and receiving data • Network Layer: Link Access Protocol (IrLAP) • second layer on hierarchical stack • uses services provided by physical layer • defines services provided by the protocol • sets vocabulary, encoding and procedures rules • provides a reliable transport as well as the state machine to discover neighboring devices IrDA Stack
  • 10. M. S. Ramaiah School of Advanced Studies 10 • Transport layer: Link Management Protocol (IrLMP) • support walk-up and point to point connection between IrDA devices • provides and supports for multiple software applications • allows entities to operate independently • IrLMP is a multiplexer over IrLAP • TinyTP provides segmentation, reassembly, and flow control. • IrSock offers a socket interface over IrLMP and TinyTP. IrDA Stack
  • 11. M. S. Ramaiah School of Advanced Studies 11 IrDA in the Kernel • If your hardware supports SIR mode, this is usually straightforward. FIR configuration is still somewhat difficult, unless you have a system that's supported right out of the box. • Most modern notebooks support FIR by default, but you can often go into the BIOS setup and change it to SIR. Even if you want FIR to work, be sure to try SIR first, because it's usually the simplest. • Most modern kernels have all the support that you need to get infrared to work. If you build your own kernel, make sure that you've enabled infrared support. Most of the infrared support is configured under the IrDA (Infrared) Support section that appears in the kernel configuration. • To enable IrDA support in your Kernel first get the kernel source from http://kernel.org/pub/linux/kernel • To know your current kernel version you can type in the command uname –r . So to upgrade the kernel download the version above the current version from the above site. • The kernel tar ball is distributed in both GNU zip (gzip) and bzip2 (better compressed) format. • The Linux kernel tar ball in bzip2 format is named linux-x.y.z.tar.bz2, where x.y.z is the version of that particular release of the kernel source.
  • 12. M. S. Ramaiah School of Advanced Studies 12 • After downloading the source, uncompressing and un tarring it. • If your tar ball is compressed with bzip2, run • $ tar xvjf linux-x.y.z.tar.bz2 • If it is compressed with GNU zip, run • $ tar xvzf linux-x.y.z.tar.gz • This un tars the source to the directory linux-x.y.z. • Before we do anything with the sources, we should make sure the source tree does not contain any old object files or configuration information...That got there accidentally. • This is especially true for distribution kernels-they tend to contain various stale files. • To do this, go into the source directory and run the command: $ sudo make mrproper $sudo make clean IrDA in the Kernel
  • 13. M. S. Ramaiah School of Advanced Studies 13 • Several configuration programs are supported by the kernel. But best is to use $ sudo make menuconfig . If you get error while running this command because of nCurses library then install the library as – sudo apt-get install libncurses5-dev before running make menuconfig IrDA in the Kernel
  • 14. M. S. Ramaiah School of Advanced Studies 14 • IrDA is a network protocol, so it can be found under the networking main menu in the menuconfig. IrDA in the Kernel
  • 15. M. S. Ramaiah School of Advanced Studies 15 IrDA in the Kernel
  • 16. M. S. Ramaiah School of Advanced Studies 16 • Save the menuconfig IrDA in the Kernel
  • 17. M. S. Ramaiah School of Advanced Studies 17 • Once configured, Compiling the kernel is easy. • To compile the kernel's main part $ sudo make bzImage If the make is success you will get the output as IrDA in the Kernel
  • 18. M. S. Ramaiah School of Advanced Studies 18 • SYSCALL arch/i386/kernel/vsyscall-int80.so gcc: error: elf_i386: No such file or directory make[1]: if you get this error while doing a make bzImage then go to arch/x86/vdso/Makefile and search for word VDSO_LDFLAGS there exists two lines one for x64 and another for x32 bit systems.it should have -m elf_x86_64 and another one -m elf_x86 replace them like -m64 and -m32 respectively save it and again do the make bzImage • First, Compile the kernel, only the code which is added statically $ sudo make IrDA in the Kernel
  • 19. M. S. Ramaiah School of Advanced Studies 19 • Compile the code of the kernel for the features which are added as modules $ sudo make modules • Install the compiled module object code into the compiled kernel. As root simply run $ sudo make modules_install • This installs all the compiled modules to their correct home under /lib/modules • Now install your new kernel! $ sudo make install IrDA in the Kernel
  • 20. M. S. Ramaiah School of Advanced Studies 20 • Since initramfs usually needs to be customized for the particular hardware/device configuration and kernel version, they are not included as a part of any package, but are generated on the fly at kernel installation time. To customize the initramfs for particular onfiguration and kernel version, generated at the installation time use $ sudo update-initramfs –c –d 2.6.31.5 ( if required) $ sudo update-initramfs –c –k 2.6.31.5 • Once we installed the new kernel and its new modules, we need to tell the boot loader about it. $ sudo update-grub IrDA in the Kernel
  • 21. M. S. Ramaiah School of Advanced Studies 21 • Once everything is set, reboot your machine. • At the boot loader's prompt/menu, chose the new kernel. • Now install the necessary software packages irda-utils and ircp-tray. $ sudo apt-get install irda-utils ircp-tray • Install setserial package $ sudo apt-get install setserial • Now run the below command to edit the irda-utils file $ gksu gedit /etc/default/irda-utils In the configuration file which opens up, change the line reading DEVICE="/dev/ttyS1" to DEVICE="irda0“ and the line reading SETSERIAL="" to SETSERIAL="/dev/ttyS1“ IrDA in the Kernel
  • 22. M. S. Ramaiah School of Advanced Studies 22 • Two devices can communicate using IrDA. For this using the above method build your Linux kernel with IrDA enable for both the devices that you want to establish communication between using IrDA. • SIR chips offer a UART interface to the host computer. For communicating in SIR mode, attach the associated UART port (/dev/ttyS1 for example) of each laptop to the IrDA stack: $ sudo irattach /dev/ttyS1 –s • Verify that IrDA kernel modules (irda.ko, sir_dev.ko, and irtty_sir.ko) are loaded and that the irda_sir_wq kernel thread is running. The irda0 interface should also have made an appearance in the ifconfig output. The -s option to irattach triggers a search for IR activity in the neighborhood. If you slide the laptops such that their IR transceivers lie within the range cone, they will be able to spot each other: $ sudo cat /proc/net/irda/discovery IrLMP: Discovery log: nickname: localhost, hint: 0x4400, saddr: 0x55529048, daddr: 0x8fefb350 Communicating using IrDA-SIR mode
  • 23. M. S. Ramaiah School of Advanced Studies 23 • The other laptop makes a similar announcement, but with the source and destination addresses (saddr and daddr) reversed. • You may set the desired communication speed using stty on ttyS1. To set the baud rate to 19200, do this: – $ sudo stty speed 19200 < /dev/ttyS1 • The easiest way to cull IR activity from the air is by using the debug tool, irdadump $ sudo irdadump -i irda0 • You can also obtain debug information out of the IrDA stack by controlling the verbosity level in /proc/sys/net/irda/debug Communicating using IrDA-SIR mode
  • 24. M. S. Ramaiah School of Advanced Studies 24 • To set the laptops in FIR mode, dissociate ttyS1 from the native serial driver and instead attach it to the NSC FIR driver, nsc-ircc.ko: $ sudo setserial /dev/ttyS1 uart none $ sudo modprobe nsc-ircc dongle_id=0x09 $ sudo irattach irda0 -s dongle_id depends on your IR hardware and can be found from your hardware documentation. As you did for SIR, take a look at /proc/net/irda/discovery to see whether things are okay thus far. • Sometimes, FIR communication hangs at higher speeds. If irdadump shows a communication freeze, then fix the code, or try lowering the negotiated speed by tweaking/proc/sys/net/irda/max_baud_rate. • For device example of IR dongle driver you can see the file drivers/net/irda/tekram.c and drivers/net/irda/ep7211_ir.c. Communicating using IrDA-FIR mode
  • 25. M. S. Ramaiah School of Advanced Studies 25 • Transferring The Files • Install the openobex-apps package. $ sudo apt-get install openobex-apps • Then open the terminal and type irxfer $ irxfer XXXX.mp3 On successful it will say Put Successful Communicating using IrDA-Transferring of Files
  • 26. M. S. Ramaiah School of Advanced Studies 26 IrDA Sockets • To develop custom applications over IrDA, use the IrSock interface. To create a socket over TinyTP, do this: int fd = socket(AF_IRDA, SOCK_STREAM, 0); • For a datagram socket over IrLMP, do this: int fd = socket(AF_IRDA, SOCK_DGRAM, 0); • To get the list of device discovery and there info IrDA uses a structure to hold the information in • struct irda_device_list { u_int32_t numDevice; struct irda_device_info Device[1];}; • struct irda_device_info { u_int32_t saddr; /* Address of local interface */ u_int32_t irdaDeviceID; /* Address of remote device */ char irdaDeviceName[22]; /* Description */ u_int8_t charset; /* Charset used for description */ u_int8_t hints[2]; /* Hint bits */ };
  • 27. M. S. Ramaiah School of Advanced Studies 27 • The irda_device_info struct has a two byte hint array. The hint bits can give info about that a given IrDA device is and what it supports. Here is a list of the available bits from /usr/include/linux/irda.h IrDA Sockets-Hint Bits Hint bit positions for first hint byte Hint bit positions for second hint byte (first extension byte) HINT_PNP HINT_TELEPHONY HINT_PDA HINT_FILE_SERVER HINT_COMPUTER HINT_COMM HINT_PRINTER HINT_MESSAGE HINT_MODEM HINT_HTTP HINT_FAX HINT_OBEX HINT_LAN HINT_EXTENSION: If this is set the next byte is valid
  • 28. M. S. Ramaiah School of Advanced Studies 28 IrDA Sockets- SOL_IRLMP Socket Options Option Get Set Optval type Description IRLMP_DISCOVERY_MODE IRLMP_ENUMDEVICES yes DEVICELIST Returns a list of IrDA device IDs for IR capable devices within range. IRLMP_EXCLUSIVE_MODE DWORD (boolean) Sets socket to bypass TinyTP layer to directly communicate with IrLMP. IRLMP_IAS_QUERY yes IAS_QUERY Queries IAS on a given service and class name for its attributes. IRLMP_IAS_SET yes IAS_SET Sets an attribute value for a given class name and attribute into IAS. IRLMP_IRLPT_MODE yes DWORD (boolean) Enables communication with IR capable printers. IRLMP_PARAMETERS IRLMP_SEND_PDU_LEN yes DWORD Retrieves the maximum PDU length required to use IRLMP_9WIRE_MODE. IRLMP_SHARP_MODE yes IRLMP_TINYTP_MODE yes IRLMP_9WIRE_MODE yes yes DWORD (boolean) Puts the IrDA socket into IrCOMM mode. The following table describes SOL_IRLMP socket options that apply to sockets created for the Infrared Data Association (IrDA) address family (AF_IRDA) and the InfraRed Link Management Protocol (IRLMP)
  • 29. M. S. Ramaiah School of Advanced Studies 29 Sample code to discover the device fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } printf("sizeof(struct irda_device_list)=%dn",sizeof(struct irda_device_list)); printf("sizeof(struct irda_device_info)=%dn", sizeof(struct irda_device_info)); discover_devices(fd); IrDA Sockets-Sample code to discover the device
  • 30. M. S. Ramaiah School of Advanced Studies 30 struct irda_device_list *list; len = sizeof(struct irda_device_list) +sizeof(struct irda_device_info) * MAX_DEVICES; buf = malloc(len); list = (struct irda_device_list *) buf; if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { perror("getsockopt"); exit(-1); } if (len > 0) { printf("Discovered:n"); for (i=0;i<list->len;i++) { printf(" name: %sn", list->dev[i].info); printf(" daddr: %08xn", list->dev[i].daddr); printf(" saddr: %08xn", list->dev[i].saddr); printf("n"); } IrDA Sockets-Sample code to discover the device
  • 31. M. S. Ramaiah School of Advanced Studies 31 struct sockaddr_irda peer, self; /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Init self */ self.sir_family = AF_IRDA; self.sir_lsap_sel = LSAP_ANY; if (bind(fd, (struct sockaddr*) &self, sizeof(struct sockaddr_irda))) { perror("bind"); return -1; }if (listen(fd, 8)) { perror("listen"); return -1; } IrDA Sockets-Sample echo server struct sockaddr_irda { __kernel_sa_family_t sir_family; /* AF_IRDA */ __u8 sir_lsap_sel; /* LSAP selector */ __u32 sir_addr; /* Device address */ char sir_name[25]; /* Usually <service>:IrDA:TinyTP */ };
  • 32. M. S. Ramaiah School of Advanced Studies 32 for (;;) { addrlen = sizeof(struct sockaddr_irda); printf("Waiting for connection!n"); conn_fd = accept(fd, (struct sockaddr *) &peer, &addrlen); if (conn_fd < 0) { perror("accept"); return -1; } printf("Connected!n"); do { actual = recv(conn_fd, &buf, sizeof(buf), 0); if (actual <= 0) break; printf("Got %d bytesn", actual); if (!discard) { actual = send(conn_fd, &buf, actual, 0); printf("Sent %d bytesn", actual); } } while (actual > 0); close(conn_fd);printf("Disconnected!n"); IrDA Sockets-Sample echo server
  • 33. M. S. Ramaiah School of Advanced Studies 33 Conclusion • The main reason for using IrDA has been wireless data transfer over the last one meter using point and shoot principles. Main characteristics of this kind of wireless optical communication is physically secure data transfer, Line-of- Sight (LOS) and very low bit error rate (BER) that makes it very efficient. This has been implemented in portable devices like mobile phones, laptops, printers, cameras, medical devices and many more. • Besides the advantages of IrDA, it has certain disadvantages like one device at a time connection, transfer rate is 4Mbps,have to keep device stable while transferring data, it is for short range and LOS should be clear. • Because of the above disadvantages blue tooth came into picture. But still it cannot overshadow the IrDA uses. • However more can be done in IrDA for future works like supporting higher baud rates for faster transmissions,one to many connections etc.
  • 34. M. S. Ramaiah School of Advanced Studies 34 References [1] Dumbill,E.,Jepson,B.,Weeks,R. (April 2004) “Linux Unwired”, 1st Edition:O’Reilly [2] Wikipedia. “Infrared Data Association”. [Online].Available from: http://en.wikipedia.org/wiki/Infrared_Data_Association (Accessed:31 March 2014) [3]Linux-IrDA project by Hewlitt Packard. “Linux-IrDA quick tutorial”[Online]. Available from: http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/ (Accesses:31 March 2014)