Disabling debug prints on console

Asked by Ashok Kumar on 2015-03-24

How to disable the debugging prints which appears on console? Is there anyway to do it as because I am working in a real-time system, its performance get affected by these prints. Such as the following,

Creating ROHC compressor......

 Enabling the Compression profilesplease define a callback for compressor traces
[rohc_comp.c:2304 rohc_comp_enable_profile()] ROHC compression profile (ID = 0) enabled
[rohc_comp.c:2304 rohc_comp_enable_profile()] ROHC compression profile (ID = 2) enabled
[rohc_comp.c:2304 rohc_comp_enable_profile()] ROHC compression profile (ID = 4) enabled

 Creating ROHC Decompressor.....
 Enabling the De-compression profilesplease define a callback for decompressor traces
[rohc_decomp.c:3424 rohc_decomp_enable_profile()] ROHC decompression profile (ID = 0) enabled
[rohc_decomp.c:3424 rohc_decomp_enable_profile()] ROHC decompression profile (ID = 2) enabled
[rohc_decomp.c:3424 rohc_decomp_enable_profile()] ROHC decompression profile (ID = 4) enabled

 Compressing the UDP/IP packet...

[rohc_comp.c:5033 rohc_feedback_get()] no feedback is available
[rohc_comp.c:5108 rohc_feedback_get()] add 0 byte(s) of feedback data
[net_pkt.c:75 net_pkt_parse()] outer IP header: 78 bytes
[net_pkt.c:77 net_pkt_parse()] outer IP header: version 4
[net_pkt.c:82 net_pkt_parse()] outer IP header: next header is of type 17
[net_pkt.c:87 net_pkt_parse()] outer IP header: next layer is of type 17
[rohc_comp.c:4608 c_get_profile_from_packet()] try to find the best profile for packet with transport protocol 17
[rohc_comp.c:4621 c_get_profile_from_packet()] skip disabled profile 'IP/UDP/RTP' (0x0001)
[rohc_comp.c:4813 rohc_comp_find_ctxt()] using profile 'IP/UDP' (0x0002)
[rohc_comp.c:4860 rohc_comp_find_ctxt()] no existing context found for packet, create a new one
[rohc_comp.c:4720 c_create_context()] take the first unused context (CID = 0)
[c_generic.c:502 c_generic_create()] new generic context required for a new stream
[c_generic.c:528 c_generic_create()] use shift parameter -1 for LSB-encoding of SN
[c_udp.c:145 c_udp_create()] initialize context(SN) = random() = 2988
[rohc_comp.c:4767 c_create_context()] context (CID = 0) created (num_used = 1)
[rohc_comp.c:1435 rohc_compress4()] compress the packet #1
[c_generic.c:1217 c_generic_detect_changes()] SN = 2989
[c_generic.c:6292 detect_ip_id_behaviour()] no previous IP-ID, consider non-random/static and NBO
[c_generic.c:6356 detect_ip_id_behaviour()] NBO = 1, RND = 0, SID = 0
[c_generic.c:6185 detect_changed_fields()] TTL/HL changed from 0x00 to 0x80
[c_generic.c:6193 detect_changed_fields()] Protocol/NH changed from 0x00 to 0x11
[c_generic.c:5901 changed_static_one_hdr()] protocol_count 3
[c_generic.c:5931 changed_dynamic_both_hdr()] check for changed fields in the outer IP header
[c_generic.c:6009 changed_dynamic_one_hdr()] TTL/HL changed in the current packet
[c_generic.c:6070 changed_dynamic_one_hdr()] NBO changed (0x0 -> 0x1) in the current packet
[c_generic.c:1282 c_generic_detect_changes()] send_static = 1, send_dynamic = 2
[c_udp.c:410 udp_decide_state()] go back to IR state because UDP checksum behaviour changed in the last few packets
[c_generic.c:6426 encode_uncomp_fields()] compressor is in state 1
[c_generic.c:6431 encode_uncomp_fields()] new SN = 2989 / 0xbad
[c_generic.c:6439 encode_uncomp_fields()] IR state: force using 16 bits to encode new SN
[c_generic.c:6454 encode_uncomp_fields()] 16 bits are required to encode new SN
[c_generic.c:6475 encode_uncomp_fields()] new outer IP-ID delta = 0x582d / 22573 (NBO = 1, RND = 0, SID = 0)
[c_generic.c:6483 encode_uncomp_fields()] IR state: force using 16 bits to encode new outer IP-ID delta
[c_generic.c:6506 encode_uncomp_fields()] 16 bits are required to encode new outer IP-ID delta
[c_generic.c:1497 decide_packet()] decide packet in IR state
[c_generic.c:1542 decide_packet()] packet 'IR' chosen
[c_generic.c:1719 code_IR_packet()] code IR packet (CID = 0)
[c_generic.c:1738 code_IR_packet()] small CID 0 encoded on 0 byte(s)
[c_generic.c:1750 code_IR_packet()] type of packet + D flag = 0xfd
[c_generic.c:1762 code_IR_packet()] profile ID = 0x02
[c_generic.c:1768 code_IR_packet()] CRC = 0x00 for CRC calculation
[c_generic.c:2089 code_ipv4_static_part()] version = 0x40
[c_generic.c:2094 code_ipv4_static_part()] protocol = 0x11
[c_generic.c:2103 code_ipv4_static_part()] src addr = 0ab011bf (10.176.17.191)
[c_generic.c:2110 code_ipv4_static_part()] dst addr = 0ab011ff (10.176.17.255)
[c_udp.c:490 udp_code_static_udp_part()] UDP source port = 0x8900
[c_udp.c:495 udp_code_static_udp_part()] UDP dest port = 0x8900
[c_generic.c:2339 code_ipv4_dynamic_part()] TOS = 0x00
[c_generic.c:2346 code_ipv4_dynamic_part()] TTL = 0x80
[c_generic.c:2356 code_ipv4_dynamic_part()] IP-ID = 0x63 0xda
[c_generic.c:2377 code_ipv4_dynamic_part()] (DF = 0, RND = 0, NBO = 1, SID = 0) = 0x20
[c_generic.c:2389 code_ipv4_dynamic_part()] Generic extension header list = 0x00
[c_udp.c:538 udp_code_dynamic_udp_part()] UDP checksum = 0x23dd
[c_ip.c:508 c_ip_code_ir_remainder()] SN = 2989 -> 0x0bad
[c_generic.c:1808 code_IR_packet()] CRC (header length = 27, crc = 0x95)
[rohc_comp.c:1563 rohc_compress4()] copy full 50-byte payload
[rohc_comp.c:1573 rohc_compress4()] ROHC size = 77 bytes (header = 27, payload = 50), output buffer size = 2048
[rohc_comp.c:4437 __rohc_feedback_remove_locked()] 0 locked feedbacks removed

 ROHC packet after compression:
0xfd 0x02 0x95 0x40 0x11 0x0a 0xb0 0x11
0xbf 0x0a 0xb0 0x11 0xff 0x00 0x89 0x00
0x89 0x00 0x80 0x63 0xda 0x20 0x00 0xdd
0x23 0x0b 0xad 0x84 0xb6 0x01 0x10 0x00
0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x20
0x45 0x43 0x45 0x44 0x45 0x48 0x45 0x4a
0x44 0x42 0x44 0x48 0x44 0x46 0x43 0x41
0x43 0x41 0x43 0x41 0x43 0x41 0x43 0x41
0x43 0x41 0x43 0x41 0x43 0x41 0x42 0x4d
0x00 0x00 0x20 0x00 0x01

 Total number of bytes:77

 Decompressing the UDP/IP packet....
[rohc_decomp.c:1359 rohc_decompress3()] decompress the 77-byte packet #1
[rohc_decomp.c:3895 rohc_decomp_parse_padding()] skip 0 byte(s) of padding
[rohc_decomp.c:1751 d_decode_header()] decompressor received 0 bytes of feedback for the same-side associated compressor
[rohc_decomp.c:3831 rohc_decomp_decode_cid()] no add-CID found, CID defaults to 0
[rohc_decomp.c:1890 d_decode_header()] ROHC packet is an IR packet
[rohc_decomp.c:1912 d_decode_header()] profile with ID 0x0002 found in IR packet
[rohc_decomp.c:1931 d_decode_header()] context with CID 0 either does not already exist or does not match profile 0x0002 found in IR packet
[rohc_decomp.c:2032 d_decode_header()] decode packet as 'IR'
[d_generic.c:778 parse_ir()] CRC-8 found in packet = 0x95
[d_generic.c:1034 parse_static_part_ipv4()] IP Version = 4
[d_generic.c:1041 parse_static_part_ipv4()] Protocol = 0x11
[d_generic.c:1049 parse_static_part_ipv4()] Source Address = 0ab011bf (10.176.17.191)
[d_generic.c:1057 parse_static_part_ipv4()] Destination Address = 0ab011ff (10.176.17.255)
[d_udp.c:268 udp_parse_static_udp()] UDP source port = 0x0089 (137)
[d_udp.c:276 udp_parse_static_udp()] UDP destination port = 0x0089 (137)
[d_generic.c:1236 parse_dynamic_part_ipv4()] TOS = 0x00
[d_generic.c:1243 parse_dynamic_part_ipv4()] TTL = 0x80
[d_generic.c:1251 parse_dynamic_part_ipv4()] IP-ID = 0xda63
[d_generic.c:1272 parse_dynamic_part_ipv4()] DF = 0, RND = 0, NBO = 1, SID = 0
[d_udp.c:346 udp_parse_dynamic_udp()] UDP checksum = 0xdd23
[d_ip.c:218 ip_parse_dynamic_ip()] SN = 2989 (0x0bad)
[d_generic.c:1447 d_generic_decode()] ROHC payload (length = 50 bytes) starts at offset 27
[d_generic.c:5707 check_ir_crc()] CRC-8 on compressed 27-byte ROHC header = 0x95
[d_generic.c:6039 decode_values_from_bits()] decoded SN = 2989 / 0xbad (nr bits = 16, bits = 2989 / 0xbad)
[d_generic.c:6209 decode_ip_values_from_bits()] decoded outer TOS/TC = 0
[d_generic.c:6222 decode_ip_values_from_bits()] decoded outer TTL/HL = 128
[d_generic.c:6236 decode_ip_values_from_bits()] decoded outer protocol/NH = 17
[d_generic.c:6252 decode_ip_values_from_bits()] decoded outer NBO = 1
[d_generic.c:6265 decode_ip_values_from_bits()] decoded outer RND = 0
[d_generic.c:6278 decode_ip_values_from_bits()] decoded outer SID = 0
[d_generic.c:6337 decode_ip_values_from_bits()] decoded outer IP-ID = 0x63da (rnd = 0, nbo = 1, sid = 0, nr bits = 16, bits = 0xda63)
[d_generic.c:6350 decode_ip_values_from_bits()] decoded outer DF = 0
[d_generic.c:6366 decode_ip_values_from_bits()] decoded outer src address = 0ab011bf (10.176.17.191)
[d_generic.c:6382 decode_ip_values_from_bits()] decoded outer dst address = 0ab011ff (10.176.17.255)
[d_udp.c:486 udp_decode_values_from_bits()] decoded UDP source port = 0x0089
[d_udp.c:501 udp_decode_values_from_bits()] decoded UDP destination port = 0x0089
[d_udp.c:528 udp_decode_values_from_bits()] decoded UDP checksum = 0xdd23 (checksum present = 1)
[d_generic.c:5405 build_uncomp_hdrs()] length of transport header = 8 bytes
[d_generic.c:5563 build_uncomp_ipv4()] Total Length = 0x004e (IHL * 4 + 58)
[d_generic.c:5567 build_uncomp_ipv4()] IP checksum = 0x9da7
[d_udp.c:565 udp_build_uncomp_udp()] UDP checksum = 0xdd23
[d_udp.c:569 udp_build_uncomp_udp()] UDP length = 0x003a
[d_generic.c:1532 d_generic_decode()] CRC is correct
[d_generic.c:1671 d_generic_decode()] uncompressed packet length = 78 bytes
[d_generic.c:1687 d_generic_decode()] change from state 1 to state 3
[rohc_decomp.c:1376 rohc_decompress3()] d_decode_header returned code 0
[rohc_decomp.c:1494 rohc_decompress3()] packet decompression succeeded
[rohc_decomp.c:1515 rohc_decompress3()] feedback curr -12
[rohc_decomp.c:1525 rohc_decompress3()] feedback curr 0
[rohc_decomp.c:2197 d_optimistic_feedback()] send an ACK feedback
[rohc_decomp.c:996 rohc_decompress()] failed to piggyback the feedback

 IP packet after Decompression:

0x45 0x00 0x00 0x4e 0x63 0xda 0x00 0x00
0x80 0x11 0x9d 0xa7 0x0a 0xb0 0x11 0xbf
0x0a 0xb0 0x11 0xff 0x00 0x89 0x00 0x89
0x00 0x3a 0xdd 0x23 0x84 0xb6 0x01 0x10
0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00
0x20 0x45 0x43 0x45 0x44 0x45 0x48 0x45
0x4a 0x44 0x42 0x44 0x48 0x44 0x46 0x43
0x41 0x43 0x41 0x43 0x41 0x43 0x41 0x43
0x41 0x43 0x41 0x43 0x41 0x43 0x41 0x42
0x4d 0x00 0x00 0x20 0x00 0x01

 Total number of bytes:78

My essential details(Total bytes: Compressed/Decompressed) are seems to be hindering with this.....

Question information

Language:
English Edit question
Status:
Solved
For:
rohc Edit question
Assignee:
No assignee Edit question
Solved by:
Didier Barvaux
Solved:
2015-03-27
Last query:
2015-03-27
Last reply:
2015-03-25
Nayar Joolfoo (nayar) said : #1

What if you pipe it to /dev/null?

iprohc_server > /dev/null 2>&1

Ashok Kumar (ashokkm-9) said : #2

Hi,

    It doesn't seems to work.. I am getting this

bcg@BCGA53:~/Desktop/study/ROHC/RawUDP$ gcc -o mytest5-RAWUDP $(pkg-config rohc --cflags) mytest5-RAWUDP.c $(pkg-config rohc --libs) /dev/null 2>&1
mytest5-RAWUDP.c: In function ‘main’:
mytest5-RAWUDP.c:170: warning: ‘rohc_compress2’ is deprecated (declared at /usr/include/rohc/rohc_comp.h:413)
mytest5-RAWUDP.c:197: warning: ‘rohc_decompress’ is deprecated (declared at /usr/include/rohc/rohc_decomp.h:287)
/dev/null: file not recognized: File truncated
collect2: ld returned 1 exit status
bcg@BCGA53:~/Desktop/study/ROHC/RawUDP$ sudo ./mytest5-RAWUDP /dev/null 2>&1
sudo: ./mytest5-RAWUDP: command not found

Hello,

The redirection to /dev/null to hide the debug content is a trick, but there is a better way to perform this with the library itself.

For the /dev/null redirection to work however, you have to:
 - apply it on the program that you run (not on the compiler gcc)
 - you have to use the correct syntax, ie. : yourprogamname yourarguments > /dev/null 2>&1
    (your examples miss the > character before /dev/null)

Now, back on the proper way to hide the output. The ROHC library used to print the debug traces on stdout. That was a bad habit inherited from the early versions. As of 1.5.0 or 1.6.0 (I'm not sure of the exact version), I added a way for the programs to handle the library traces itself. However, to avoid changing the library behavior in the 1.x.y versions, I kept the default behavior to "print traces on stdout by default". This will change in the future 2.0.0 version that will leave behind compatibility with the 1.x.y versions.

In short:
 - with the future 2.0.0 version, you'll have nothing to do.
 - with the current 1.7.x versions, you need to use the rohc_comp_set_traces_cb2() and rohc_decomp_set_traces_cb2() functions. To disable all traces, specify NULL as callback.

Short examples:
   rohc_comp_set_traces_cb2(compressor, NULL);
   rohc_decomp_set_traces_cb2(decompressor, NULL);

Longer examples:
  see the examples/rtp_detection.c example in the sources.

API documentation for those functions:
  https://rohc-lib.org/support/documentation/API/rohc-doc-1.7.0/group__rohc__comp.html#ga1d473a3062db32a17c76ab142410c541
  https://rohc-lib.org/support/documentation/API/rohc-doc-1.7.0/group__rohc__decomp.html#ga9bcd25e2a96356a83cc87b34cc8fa73a

Regards,
Didier

Ashok Kumar (ashokkm-9) said : #4

Thanks Didier,
                                if(!rohc_comp_set_traces_cb2(compressor,NULL,NULL))
                                {
                                        DEBUG_MSG("CE: Failed to set the callback for traces on compressor\n");
                                        rohc_comp_free(compressor);
                                }

                               if(!rohc_decomp_set_traces_cb2(decompressor,NULL,NULL))
                               {
                                       DEBUG_MSG("CE: Failed to set the callback for traces on De-Compressor\n");
                                       rohc_decomp_free(decompressor);
                               }

the above two solved my problem......