'Linux API'에 해당되는 글 111건

  1. 2022.09.21 ipc 성능 비교
  2. 2022.09.21 posix message queue
  3. 2022.09.20 zeroMQ
  4. 2022.07.14 kms - Kernel Mode Setting
  5. 2022.07.13 v4l2 debug
  6. 2022.07.06 v4l2-ctl 밝기 조절
  7. 2022.06.15 linux force feedback
  8. 2022.06.09 AF_PACKET로 link layer 열기
  9. 2022.05.11 linux tcp server listen accept connect
  10. 2022.03.25 ssl socket 예제
Linux API/linux2022. 9. 21. 19:08

zmq는 이런데서는 확 떨어지는 구나

 

Shared Memory > MQ > UDS > FIFO > Pipe > TCP 이런식인데

POSIX Message Queue가 생각외로 성능이 잘 나와서 놀랍다.

IPC Message rate
Pipe 36539 msg/s
FIFOs (named pipes)  26246 msg/s
Message Queue  67920 msg/s
Shared Memory  3821893 msg/s
TCP sockets 22483 msg/s
Unix domain sockets  40683 msg/s
ZeroMQ  15414 msg/s

 

[링크 : https://stackoverflow.com/questions/50171306/message-queue-vs-tcp-ip-socket-which-ipc-is-faster-in-linux]

'Linux API > linux' 카테고리의 다른 글

posix message queue  (0) 2022.09.21
zeroMQ  (0) 2022.09.20
파일 존재유무 확인하기  (0) 2022.02.11
select, poll, epoll  (0) 2021.11.02
Unhandled fault: external abort on non-linefetch  (0) 2021.05.25
Posted by 구차니

댓글을 달아 주세요

Linux API/linux2022. 9. 21. 19:01

4세대 벤치에서는 mq가 udp sock보다 빠르다고

https://the-linux-channel.the-toffee-project.org/index.php?page=8-tutorials-research-socket-overhead-in-linux-vs-message-queues-and-benchmarking

https://reakwon.tistory.com/m/209

'Linux API > linux' 카테고리의 다른 글

ipc 성능 비교  (0) 2022.09.21
zeroMQ  (0) 2022.09.20
파일 존재유무 확인하기  (0) 2022.02.11
select, poll, epoll  (0) 2021.11.02
Unhandled fault: external abort on non-linefetch  (0) 2021.05.25
Posted by 구차니

댓글을 달아 주세요

Linux API/linux2022. 9. 20. 14:43

ZMQ 혹은 0MQ 라고도 쓰는것 같은데 접속 모델부터 좀 찾아 보는 중

 

REQ-REP는 단순(?)한 요청-응답 모델이고

PUB-SUB는 서버에 의한 broadcast 모델 pipeline은 아직 모르겠다.

REQuest-REPly
PUBlisher - SUBscriber
PUSH- PULL (pipeline)

[링크 : https://soooprmx.com/zmq의-기본-개념들/]

[링크 : https://makersweb.net/opensource/19422]

[링크 : https://zeromq.org/]

 

Figure 2 - Request-Reply Figure 4 - Publish-Subscribe Figure 5 - Parallel Pipeline
Figure 6 - Fair Queuing    
   

[링크 : https://zguide.zeromq.org/docs/chapter1/]

 

Shared Queue (DEALER and ROUTER sockets)
In the Hello World client/server application, we have one client that talks to one service. However, in real cases we usually need to allow multiple services as well as multiple clients. This lets us scale up the power of the service (many threads or processes or nodes rather than just one). The only constraint is that services must be stateless, all state being in the request or in some shared storage such as a database.

[링크 : https://zguide.zeromq.org/docs/chapter2/]

 

Request-Reply Combinations
We have four request-reply sockets, each with a certain behavior. We’ve seen how they connect in simple and extended request-reply patterns. But these sockets are building blocks that you can use to solve many problems.

These are the legal combinations:

REQ to REP
DEALER to REP
REQ to ROUTER
DEALER to ROUTER
DEALER to DEALER
ROUTER to ROUTER

[링크 : https://zguide.zeromq.org/docs/chapter3/]

 

Messaging Patterns

Underneath the brown paper wrapping of ZeroMQ’s socket API lies the world of messaging patterns. ZeroMQ patterns are implemented by pairs of sockets with matching types.
The built-in core ZeroMQ patterns are:
  • Request-reply, which connects a set of clients to a set of services. This is a remote procedure call and task distribution pattern.
  • Pub-sub, which connects a set of publishers to a set of subscribers. This is a data distribution pattern.
  • Pipeline, which connects nodes in a fan-out/fan-in pattern that can have multiple steps and loops. This is a parallel task distribution and collection pattern.
  • Exclusive pair, which connects two sockets exclusively. This is a pattern for connecting two threads in a process, not to be confused with “normal” pairs of sockets.
XPUB socket
Same as PUB except that you can receive subscriptions from the peers in form of incoming messages. Subscription message is a byte 1 (for subscriptions) or byte 0 (for unsubscriptions) followed by the subscription body. Messages without a sub/unsub prefix are also received, but have no effect on subscription status.
XSUB socket
Same as SUB except that you subscribe by sending subscription messages to the socket. Subscription message is a byte 1 (for subscriptions) or byte 0 (for unsubscriptions) followed by the subscription body. Messages without a sub/unsub prefix may also be sent, but have no effect on subscription status.

[링크 : https://zeromq.org/socket-api/]

 

int zmq_device (int device, const void *frontend, const void *backend);
ZMQ_QUEUE starts a queue device
ZMQ_FORWARDER starts a forwarder device
ZMQ_STREAMER starts a streamer device

Queue device
ZMQ_QUEUE creates a shared queue that collects requests from a set of clients, and distributes these fairly among a set of services. Requests are fair-queued from frontend connections and load-balanced between backend connections. Replies automatically return to the client that made the original request.

This device is part of the request-reply pattern. The frontend speaks to clients and the backend speaks to services. You should use ZMQ_QUEUE with a ZMQ_XREP socket for the frontend and a ZMQ_XREQ socket for the backend. Other combinations are not documented.

Refer to zmq_socket(3) for a description of these socket types.

Forwarder device
ZMQ_FORWARDER collects messages from a set of publishers and forwards these to a set of subscribers. You will generally use this to bridge networks, e.g. read on TCP unicast and forward on multicast.

This device is part of the publish-subscribe pattern. The frontend speaks to publishers and the backend speaks to subscribers. You should use ZMQ_FORWARDER with a ZMQ_SUB socket for the frontend and a ZMQ_PUB socket for the backend. Other combinations are not documented.

Refer to zmq_socket(3) for a description of these socket types.

Streamer device
ZMQ_STREAMER collects tasks from a set of pushers and forwards these to a set of pullers. You will generally use this to bridge networks. Messages are fair-queued from pushers and load-balanced to pullers.

This device is part of the pipeline pattern. The frontend speaks to pushers and the backend speaks to pullers. You should use ZMQ_STREAMER with a ZMQ_PULL socket for the frontend and a ZMQ_PUSH socket for the backend. Other combinations are not documented.

Refer to zmq_socket(3) for a description of these socket types.

[링크 : http://api.zeromq.org/2-1:zmq-device]

'Linux API > linux' 카테고리의 다른 글

ipc 성능 비교  (0) 2022.09.21
posix message queue  (0) 2022.09.21
파일 존재유무 확인하기  (0) 2022.02.11
select, poll, epoll  (0) 2021.11.02
Unhandled fault: external abort on non-linefetch  (0) 2021.05.25
Posted by 구차니

댓글을 달아 주세요

Linux API2022. 7. 14. 17:44

linux drm(direct render mode)에서 나오는 용어인데 관계가 어떻게 되는진 모르겠다.

[링크 : https://www.kernel.org/doc/html/v4.15/gpu/drm-kms.html]

'Linux API' 카테고리의 다른 글

syslog c api(?)  (0) 2021.02.17
libescp  (0) 2019.01.03
cups api  (0) 2018.12.20
system wait stdout  (0) 2018.10.22
ncurse  (0) 2015.04.27
Posted by 구차니

댓글을 달아 주세요

Linux API/v4l2022. 7. 13. 19:47

v4l2 디버깅을 위해서는 아래와 같이 설정해주면 dmesg에 출력되게 된다.

# echo 0x1f > /sys/class/video4linux/video1/dev_debug

[링크 : https://stackoverflow.com/questions/24330671/v4l2-kernel-space-debugging]

 

guvcview 유틸리티를 이용해서 테스트.

하단의 exposure, auto / (absolute) / Auto Priority 관련 설정을 바꿀때 나오는 값 확인

 

Exposure, Auto - Aperture Priority Mode

[ 1041.346246] video2: VIDIOC_DQEVENT: type=0x3, pending=0, sequence=13, id=10094850, timestamp=1040.623934215
[ 1041.346259] changes=0x3, type=1, value=3216, flags=0x10, minimum=39, maximum=10000, step=1, default_value=156
[ 1041.346272] video2: VIDIOC_DQEVENT: error -2: type=0x0, pending=0, sequence=0, id=0, timestamp=0.000000000

 

Exposure, Auto - Manual / 3216

[ 1128.312839] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0901/0x3
[ 1128.312866] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0901/0x3

 

Exposure (Absolute)

[  621.732496] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xe55
[  621.733321] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xe55
[  621.749803] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xe56
[  621.750586] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xe56
[  621.784790] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xcbf
[  621.785731] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xcbf
[  621.802333] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xcc0
[  621.803150] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xcc0
[  621.833353] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xc90
[  621.834204] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xc90
[  621.849972] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xc90
[  621.850772] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0902/0xc90

 

Exposure, Auto Priority (선택)

[ 1464.855961] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0903/0x1
[ 1464.855989] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0903/0x1

 

Exposure, Auto Priority (미선택)

[ 1519.669796] video2: VIDIOC_S_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0903/0x0
[ 1519.669856] video2: VIDIOC_G_EXT_CTRLS: which=0x9a0000, count=1, error_idx=0, request_fd=0, id/val=0x9a0903/0x0

 

'Linux API > v4l' 카테고리의 다른 글

v4l2-ctl 밝기 조절  (0) 2022.07.06
v4l2 timestamp  (0) 2017.04.19
uv4l  (0) 2015.09.13
리눅스에 웹캠 연결시 인식  (5) 2009.12.06
Posted by 구차니

댓글을 달아 주세요

Linux API/v4l2022. 7. 6. 15:21

 

$ v4l2-ctl

General/Common options:
  --all              display all information available
  -C, --get-ctrl=<ctrl>[,<ctrl>...]
                     get the value of the controls [VIDIOC_G_EXT_CTRLS]
  -c, --set-ctrl=<ctrl>=<val>[,<ctrl>=<val>...]
                     set the value of the controls [VIDIOC_S_EXT_CTRLS]
  -D, --info         show driver info [VIDIOC_QUERYCAP]
  -d, --device=<dev> use device <dev> instead of /dev/video0
                     if <dev> starts with a digit, then /dev/video<dev> is used
  -e, --out-device=<dev> use device <dev> for output streams instead of the
                     default device as set with --device
                     if <dev> starts with a digit, then /dev/video<dev> is used
  -h, --help         display this help message
  --help-all         all options
  --help-io          input/output options
  --help-misc        miscellaneous options
  --help-overlay     overlay format options
  --help-sdr         SDR format options
  --help-selection   crop/selection options
  --help-stds        standards and other video timings options
  --help-streaming   streaming options
  --help-tuner       tuner/modulator options
  --help-vbi         VBI format options
  --help-vidcap      video capture format options
  --help-vidout      vidout output format options
  --help-edid        edid handling options
  -k, --concise      be more concise if possible.
  -l, --list-ctrls   display all controls and their values [VIDIOC_QUERYCTRL]
  -L, --list-ctrls-menus
                     display all controls and their menus [VIDIOC_QUERYMENU]
  -r, --subset=<ctrl>[,<offset>,<size>]+
                     the subset of the N-dimensional array to get/set for control <ctrl>,
                     for every dimension an (<offset>, <size>) tuple is given.
  -w, --wrapper      use the libv4l2 wrapper library.
  --list-devices     list all v4l devices
  --log-status       log the board status in the kernel log [VIDIOC_LOG_STATUS]
  --get-priority     query the current access priority [VIDIOC_G_PRIORITY]
  --set-priority=<prio>
                     set the new access priority [VIDIOC_S_PRIORITY]
                     <prio> is 1 (background), 2 (interactive) or 3 (record)
  --silent           only set the result code, do not print any messages
  --sleep=<secs>     sleep <secs>, call QUERYCAP and close the file handle
  --verbose          turn on verbose ioctl status reporting

 

$ v4l2-ctl -l -d /dev/video2
                     brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0
                       contrast 0x00980901 (int)    : min=0 max=95 step=1 default=5 value=5
                     saturation 0x00980902 (int)    : min=0 max=100 step=1 default=60 value=60
                            hue 0x00980903 (int)    : min=-2000 max=2000 step=1 default=0 value=0
 white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
                          gamma 0x00980910 (int)    : min=100 max=300 step=1 default=100 value=100
                           gain 0x00980913 (int)    : min=1 max=8 step=1 default=1 value=1
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=2
      white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
                      sharpness 0x0098091b (int)    : min=1 max=7 step=1 default=2 value=2
         backlight_compensation 0x0098091c (int)    : min=0 max=1 step=1 default=1 value=1
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=1
              exposure_absolute 0x009a0902 (int)    : min=10 max=626 step=1 default=156 value=25

 

v4l2-ctl -d /dev/video2 -c exposure_absolute=70
v4l2-ctl -d /dev/video2 -c exposure_absolute=600

[링크 : https://thirdnsov.tistory.com/107]

'Linux API > v4l' 카테고리의 다른 글

v4l2 debug  (0) 2022.07.13
v4l2 timestamp  (0) 2017.04.19
uv4l  (0) 2015.09.13
리눅스에 웹캠 연결시 인식  (5) 2009.12.06
Posted by 구차니

댓글을 달아 주세요

Linux API/joystick2022. 6. 15. 13:19

예전에 리눅스를 통해 어떻게 쓰나 찾을때는 안나왔던것 같은데 이제 발견

 

% fftest /dev/input/eventXX

[링크 : https://www.kernel.org/doc/html/latest/input/ff.html]

 

해당 유틸리티 실행하려니 joystick이라는 패키지를 설치하라고 한다.

$ fftest

Command 'fftest' not found, but can be installed with:

sudo apt install joystick

'Linux API > joystick' 카테고리의 다른 글

linux/joystick.h 파일  (0) 2012.02.05
리눅스에서 조이스틱 값 읽어오기  (0) 2012.02.04
Posted by 구차니

댓글을 달아 주세요

Linux API/network2022. 6. 9. 11:17

etherCAT 이라는 사악한(?) 프로토콜 때문에 해당 장비 개발자에게 주워들은 이야기

 

AF_PACKET 이라는걸로 열면 link layer로 열려서 통신이 가능해서

etherCAT 이라고 특별한 드라이버를 설치하는건 아니라고 한다.

 

AF_INET 를 주로 사용했지 다른걸 찾아볼 생각을 안했구나..

Name Purpose Man page
AF_UNIX, AF_LOCAL Local communication unix(7)
AF_INET IPv4 Internet protocols ip(7)
AF_INET6 IPv6 Internet protocols ipv6(7)
AF_IPX IPX - Novell protocols
AF_NETLINK Kernel user interface device netlink(7)
AF_X25 ITU-T X.25 / ISO-8208 protocol x25(7)
AF_AX25 Amateur radio AX.25 protocol
AF_ATMPVC Access to raw ATM PVCs
AF_APPLETALK Appletalk ddp(7)
AF_PACKET Low level packet interface packet(7)

[링크 : https://linux.die.net/man/2/socket]

[링크 : https://iplab.naist.jp/class/2018/materials/hands-on/layer-2-raw-socket/]

'Linux API > network' 카테고리의 다른 글

linux tcp server listen accept connect  (0) 2022.05.11
ssl socket 예제  (0) 2022.03.25
TCP timeout  (0) 2020.09.29
UDS (Unix Domain Socket)  (0) 2020.09.01
raw socker과 promiscous mode  (0) 2019.07.03
Posted by 구차니

댓글을 달아 주세요

Linux API/network2022. 5. 11. 15:20

서버 사이드 listen + accept

클라이언트 사이드 connect

[링크 : https://charsyam.wordpress.com/2018/01/09/입-개발-ipv4-tcp-socket-listen-에서-accept-까지/]

 

[링크 : https://www.ibm.com/docs/en/i/7.2?topic=designs-example-nonblocking-io-select]

[링크 : https://velog.io/@jyongk/TCP-Socket-Blocking-Non-Blocking]

[링크 : https://ospace.tistory.com/189]

 

accept poll 처리

accept 시에 돌려받는 fd로 io를 처리하면 accept 역시 poll로 처리가 가능해진다.

listen 포트는 그대로 둔채, accept 하고 나서 다른 포트로 통신하게 되는 이유가 이거였나..

[링크 : https://www.crocus.co.kr/544]

[링크 : https://www.joinc.co.kr/w/Site/Network_Programing/Documents/Poll]

'Linux API > network' 카테고리의 다른 글

AF_PACKET로 link layer 열기  (0) 2022.06.09
ssl socket 예제  (0) 2022.03.25
TCP timeout  (0) 2020.09.29
UDS (Unix Domain Socket)  (0) 2020.09.01
raw socker과 promiscous mode  (0) 2019.07.03
Posted by 구차니

댓글을 달아 주세요

Linux API/network2022. 3. 25. 14:12

복붙하면 "와 ' 가 문제가 생기고

우분투 18.04 에서 빌드하면 client 쪽의 소스에서

SSLv3_client_method() 함수가 없다고 나오니, SSLv23_client_method 으로 바꾸어 주어야 한다.

[링크 : http://pchero21.com/?p=603]

 

실행하면 보안인증서 경로 문제로 실행이 안되는데 인증서는 어떻게 생성해야 하려나..

[링크 : https://m.blog.naver.com/espeniel/221845133507]

 

 

+ 빌드

$ sudo apt-get install libssl-dev

[링크 : https://stackoverflow.com/questions/43131708/fatal-error-openssl-rsa-h-no-such-file-or-directory]

 

-lssl 옵션을 주고 빌드하는데 아래와 같은 에러 발생시에는

/usr/bin/ld: /tmp/ccHIcKux.o: undefined reference to symbol 'ERR_print_errors_fp@@OPENSSL_1_1_0'
//usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

 

-lcrytpo 까지 추가해주면 해결!

% gcc -o test test.c -L/usr/lib -lssl -lcrypto

[링크 : https://stackoverflow.com/questions/12917731/linking-issues-using-openssl-in-ubuntu]

 

+

nc 테스트

접속시 connection from이 뜨고

sadf를 입력하니 error가 나오며 접속이 종료된다.

$ ./srv
Enter PEM pass phrase:
Connection from 100007f, port 96c5
140278452101568:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../ssl/record/ssl3_record.c:332:

 

$ nc localhost 1111

sadf

'Linux API > network' 카테고리의 다른 글

AF_PACKET로 link layer 열기  (0) 2022.06.09
linux tcp server listen accept connect  (0) 2022.05.11
TCP timeout  (0) 2020.09.29
UDS (Unix Domain Socket)  (0) 2020.09.01
raw socker과 promiscous mode  (0) 2019.07.03
Posted by 구차니

댓글을 달아 주세요