Skip to main content

Developer tools, tricks

 Developer Tips

------------ create cscope and tags to source code --------------

Create CTAGS, CREATE FILE LIST [cscope.files], start cscope where the cscope.file exist.

cscope steps - ctags -R . ; find . -name *.[CchH] > cscope.files ; cscope # ready to start using cscope.


Using Ctrl+] Ctril+T for moving forward/ backwards.

----------------------------------------------------------

Setting up messages file log rotation on linux

1. # su - $ change to root account

2. # go to /etc/logrotate.d

   # delete the line (/var/log/messages) from file syslog

sed "/message/d" /etc/logrotate.d/syslog > /tmp/tmpsyslog && mv /tmp/tmpsyslog /etc/logrotate.d/syslog OR

grep -v "message" /etc/logrotate.d/syslog > /tmp/tmpsyslog && mv /tmp/tmpsyslog /etc/logrotate.d/syslog

3. #create new file and add below content to limit the file rotate on 20M file size or weekly once which is satisfied

cat <<EOF > /etc/logrotate.d/messageslog

/var/log/messages

{

    weekly

    rotate 13

    size 20M

    missingok

    dateext

    dateformat -%Y%m%d-%s

    notifempty

}

EOF


4. #Make entry to file /etc/cron.d/0hourly - run the logrotate for messages every 4 hrs at 2 min time

02 */4 * * * root logrotate /etc/logrotate.d/messageslog

OR

add above entry to crontab using command

crontab -e


to run the script at 5th min of each hour

05 * * * * root logrotate /etc/logrotate.d/messageslog


For running every few seconds (running lesser than 1 min duration) As the cron allows the granularity set upto 1 min only, below is the example to run the log rotation every 30 sec (2 times) or 15 secs (3 times)

* * * * * root logrotate /etc/logrotate.d/messageslog && sleep 30; logrotate /etc/logrotate.d/messageslog

* * * * * root for i in 0 1 2; do logrotate /etc/logrotate.d/messageslog & sleep 15; done;

-----------------------------

# script to fill up the messages file under /var/log folder

create a file with 777 permissions in /tmp

touch /tmp/nonstop.txt

# execute logger command to start dumping content of this file into the /var/log/messages file

logger -f /tmp/nonstop.txt


# run the script to write into /tmp/nonstop.txt file

test it by executing - sudo echo "Hello Test" > /tmp/nonstop.txt

================notstop.sh START ================

#!/bin/bash

counter=0

while true

do

sudo echo "$counter - testing non stop logs to messages file" >  /tmp/nonstop.txt

counter=$(( counter + 1 ))

sleep 1

# -n option, omits the new line after echo

echo -n '.'

done

================notstop.sh END================

linux kernel source

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/net/ipv4/tcp_input.c?h=linux-4.0.y

file - /net/ipv4/tcp_input.c

RFC - https://tools.ietf.org/html/rfc5827#section-3

https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt

-----------------------------


Comments

Popular posts from this blog

NSSF - an 5G network function to support the network slicing

NSSF - Network Slice Selector Function The 5G System architecture (3GPP TS 23.501: 5G SA; Stage 2) consists of the following network functions (NF). - Authentication Server Function (AUSF) - Core Access and Mobility Management Function (AMF) - Data network (DN), e.g. operator services, Internet access or 3rd party services - Structured Data Storage network function (SDSF) - Unstructured Data Storage network function (UDSF) - Network Exposure Function (NEF) - NF Repository Function (NRF) - Network Slice Selection Function (NSSF) ======>>> our focus - Policy Control function (PCF) - Session Management Function (SMF) - Unified Data Management (UDM) - Unified Data Repository (UDR) - User plane Function (UPF) - Application Function (AF) - User Equipment (UE) - (Radio) Access Network ((R)AN)

SCTP - A new transport protocol

SCTP is a new transport protocol, also used for LTE Signalling S1-MME interface between eNB and MME (core network) and MME -HSS (Diameter / SCTP). 1 SCTP Protocol SCTP Packet is located after the MAC/ IP header. The basic SCTP Header consist of Source / Destination Ports (16 bits each), Verification Tag (32 bits) and check sum (32 bits) Verification Tag is used by the receiver to validate the senders authenticity, this get published by each endpoint to remote end duing the 4 way handshake done initially for setting up SCTP association. 1.1 4-Way handshake Msgs 1.1.1 INIT - Contains Initiate Tag, receiver window, in/out bound streams, initial TSN 1.1.2 INIT-ACK - Contains all params same as INIT msg also contains the State Cookie 1.1.3 COOKIE-ECHO - Contains Cookie same as received in INIT-ACK 1.1.4 COOKIE-ACK - Contains nothing, used to acknowledge receipt of COOKIE-ECHO Completion of above 4 SCTP msgs bring the SCTP association to an established stat...