搜尋此網誌

2023年3月27日 星期一

用nmcli指令來管理無線網路

 Ubuntu desktop 預設是使用 network manager 來管理網路.

相對應的指令是 nmcli

本文介紹如何使用nmcli 來管理無線網路

1. 顯示無線基地台列表(Site Survery)

nmcli d wifi


Serach with keyword:

nmcli d wifi |grep 0A

2. 顯示連線狀況
nmcli d


3. 連上特定無線基地台

nmcli d wifi c ESSID password PWD
for example,
nmcli d wifi c my-home password abcd1234

重新安裝 MAC Mini 的 OS

 之前手上有一台MAC mini 2014, 規格為 Intel Core i5 @2.6GHz DDR3 8G RAM.

原本的作業系統為 macOS Big Sur ,後來升級到 macOS Monterey.

但就跑不太動了. 於是重新安裝回上一個版本 macOS big sur, 過程如下

1. 為 macOS 製作可開機安裝磁碟

參考底下apple 官方說明: https://support.apple.com/zh-tw/HT201372

2. 用製作好的USB碟安裝MAC OS  big sur

a. Alt 鍵開機.

      b. Install mac OS 

3. 使用情況

a.  使用一陣子後系統越來越慢, 最終決定改裝 linux ubuntu desktop


安裝Linux ubuntu Desktop

1. 準備ubuntu desktop USB

2.  該USB碟 開機

a. Alt 鍵開機
b. efi boot, =>install ubuntu

3.  注意事項

a. 安裝無法回到MACoS, 網路上有提供雙系統的作法, 但還沒實作出來.
b. 有些驅動可能需要自行安裝. (我沒遇到)


Install vlc server on ubuntu server

vlc server 支援 Ipv4 multicast/unicast streaming 和 IPv6 multicast streaming. 
 本篇文章紀錄如何在linux ubuntu server 上安娤和設定 vlc 
 Installation: 
apt update 
apt install vlc -y 

設定:
1. Run vlc as root:
預設是不能以root 執行,用sed更改vlc 權限:
sed -i 's/geteuid/getppid/' /usr/bin/vlc

2. 指定網卡:
如果有雙網卡, vlc 會根據路由優先權發送streaming. 
有時需指定路由, 底下指定IPv6 multicast 由網卡enp4s0 優先送出
ip route add multicast ff00::/8 dev enp4s0 table local metric 100

ip -6 route show type multicast table local


Running:
IPv4 multicast:
cvlc  /root/test.mp4 --sout '#duplicate{dst=rtp{mux=ts,dst='239.0.0.101',sdp=sap,name="Stream1"}}' --sout-keep --sout-all --loop --ttl=10

IPv6 multicast:

cvlc  /root/test.mp4 --sout '#duplicate{dst=rtp{mux=ts,dst='[ff3e::9c00:0]',sdp=sap,name="Stream1"}}' --sout-keep --sout-all --loop --ttl=10 &

Client:
用vlc client 



URL: rtp://[ff3e::9c00:0] or rtp://239.0.0.101




2017年9月25日 星期一

小魚舖大奇蹟 讀後心得


這本書主要是在介紹西雅圖舉世聞名派克魚舖的工作哲學
裡面有許多派克魚鋪員工的實際經驗分享。
主要的核心概念從一句”全在於你自己”開始。
講到”全在於你自己”就讓我想起 佛經裡面講的一句相由心生 以前我老媽 常跟我提到相由心生什麼的,我總是很 不以為然 ,心裡想難到別人揍我一拳, 痛的我愛愛叫,也是心理作用嗎?
隨著年紀漸長對許多事情的理解也有所不同,所謂的全在於你自己,其實講的就是每個人都可以做自己的主人 ,遇到一件事情,會有不同的感受,有高興難過悲傷快樂,但我們的心可以去選擇 要如何 去面對 這樣的事情。 這也就是所謂全在於你自己 別人的 所作所為你可能無法改變,但是至少你可以改變你自己。
書中的另一個重要的觀念就是所謂的目標與承諾 訂定目標勇敢承諾 可以 讓你的眼光變得不同。就如同派克魚舖 ,他們的目標是 要讓派克魚舖成為舉世聞名的魚舖,於是團隊中的每個人都徹底的投入以成為舉世聞名的目標而努力 。一旦有了這個目標, 讓許多好的事情開始發生, 彷彿宇宙 也聽到他們的聲音,新的機會也隨著出現。
仔細想想 從小到大都是跟著別人的要求過日子, 從來沒有仔細想過自己的目標是什麼,只是隨波逐流。 現在開始可以為自己訂立一個目標,勇於承諾,活在當下。

2017年9月15日 星期五

面對問題時該有的態度和方法

工作上總會遇到問題和困難,這時保持正確態度和方法就非常重要.
底下是看完 "沒了名片,你還剩下什麼?"書後再搭配工作經驗得到的一些感想.
1. 樂觀面對,相信問題一定有解決的方法
2. 跳脫舊有思維,換個角度看問題.
3. 尋求他人協助
4. 讓問題飛一會
5. 別急著找戰犯,一味的追究責任是無法解決問題的.
以上若想再深入了解,坊間有許多書籍可以參考.
建議大家平常有空可以去書局或圖書館逛逛~
或許有意想不到的收穫~

2017年8月22日 星期二

利用sipp 模擬voip client

一般VoIP閘道器常遇到和不同SIP伺服器之間有相容性的問題.

若無法透過遠端解決,常需要在本地端進行分析
常用的方式是請客戶抓包,再用wireshark 去解析.
但若看不出所以然,就需要去模擬客戶的行為.
sipp是一個蠻簡單的工具,可以去模擬UAC 或 UAS的行為.
把需要的scenario, header等寫入script ,再去執行即可.

安裝和基本教學在官網裏有詳細的介紹,這裏就不多說了.
http://sipp.sourceforge.net/

底下是以sipp模擬UAC,也就是一般俗稱的CALLER(發話端)

命令如下:
sipp [remote_ip]:[remote_port] -i [local_ip] -p [local_port] -s [service] -sf xxx.xml -l 1
其中 remote_ip為受話IP,可以是SIP SERVER,或CALLEE(受話端)
local ip則為 UAC本身的ip
-s 則為UAC的電話號碼
-sf 則為 script file,
-l 1 指的是執行一次.



<?xml version="1.0" encoding="ISO-8859-1" ?>

<!--  Start Register -->
<!-- usage: sipp [remote_ip]:[remote_port] -i [local_ip] -p [local_port] -s [service] -sf xxx.xml -l 1 -->
<!-- usage: sipp 10.10.10.100:5060 -i 10.10.10.100 -p 5061 -s 5422818 -sf UAC_BasicCaller.xml -r 1 -m 1-->

<scenario name="BasicCaller">  
    <send>
        <![CDATA[
            INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
            Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
            From: <sip:7010@[local_ip]:[local_port]>;tag=[call_number]
            To: <sip:[service]@[remote_ip]:[remote_port]>
            Call-ID: [call_id]
            CSeq: [cseq] INVITE
            Contact: <sip:7010@[local_ip]:[local_port]>
            Max-Forwards: 70
            User-Agent: fredspqa
            Content-Type: application/sdp
            Content-Length: [len]

            v=0
            o=SIPP 31094920 31094920 IN IP4 [local_ip]
            s=Session
            c=IN IP4 [local_ip]
            t=0 0
            m=audio 33302 RTP/AVP 8
            a=rtpmap:8 PCMA/8000
      ]]>
    </send>
   
    <recv response="100" rtd="true">
    </recv>
   
    <recv response="180" optional="true">
    </recv>

    <recv response="183" optional="true">
    </recv>

    <recv response="200" rtd="true">
        <action>
            <ereg regexp=".*" search_in="hdr" header="To:" assign_to="2"/>
            <ereg regexp=".*" search_in="hdr" header="From:" assign_to="3"/>
            <ereg regexp=".*" search_in="hdr" header="Via:" assign_to="4"/>
        </action>
    </recv>   
   
    <send>
        <![CDATA[
            ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
            Via:[$4]
            From: [$2]
            To: [$3]
            Call-ID: [call_id]
            CSeq: [cseq] ACK
            Contact: <sip:7010@[local_ip]:[local_port]>
            Max-Forwards: 70
            User-Agent: fredspqa
            Content-Length: 0
        ]]>
    </send>
   
   
    <!-- wait another port ready        --> 
    <pause milliseconds="3000">
    </pause>
   
    <send retrans="30000">
        <![CDATA[
            BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
            Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
            From: <sip:7010@[local_ip]:[local_port]>;tag=[call_number]
            To: <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
            Call-ID: [call_id]
            CSeq: [cseq] BYE
            Contact: <sip:7010@[local_ip]:[local_port]>
            Max-Forwards: 70
            User-Agent: fredspqa
            Content-Length:  [len]
            Content-Type: application/PulseCharge+xml

            <?xml version="1.0"?>
            <charging-info state="stop">
            </charging-info>
        ]]>
    </send>
   
    <recv response="200">
    </recv>

</scenario>


底下範例則為 以 sipp 當為UAS(受話端或 SIP server)
 命令為
sipp -i 10.10.10.10 -sf uas.xml

這個scenario一開始會持續的等待INVITE.
收到INVITE後會回180RING,
等0.5SEC後回 200 OK
最後再送BYE模擬掛電話的動作


<?xml version="1.0" encoding="windows-1252"?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- usage:                                                                         -->
<!-- sipp 10.10.10.10:5060 -i 10.10.10.10 -p 5061 -sf register.xml -r 1 -m 1    -->
<!-- sipp -i 10.10.10.10 -sf uas.xml                                          -->
<!--                                                                    -->
<scenario name="Basic UAS responder">
  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
  <!-- are saved and used for following messages sent. Useful to test   -->
  <!-- against stateful SIP proxies/B2BUAs.                             -->
  <recv request="INVITE" crlf="true">
  </recv>

  <!-- The '[last_*]' keyword is replaced automatically by the          -->
  <!-- specified header if it was present in the last message received  -->
  <!-- (except if it was a retransmission). If the header was not       -->
  <!-- present or if no message has been received, the '[last_*]'       -->
  <!-- keyword is discarded, and all bytes until the end of the line    -->
  <!-- are also discarded.                                              -->
  <!--                                                                  -->
  <!-- If the specified header was present several times in the         -->
  <!-- message, all occurences are concatenated (CRLF seperated)        -->
  <!-- to be used in place of the '[last_*]' keyword.                   -->

  <send>
    <![CDATA[

      SIP/2.0 180 Ringing
      [last_Via:]
      [last_From:]
      [last_To:];tag=[call_number]
      [last_Call-ID:]
      [last_CSeq:]
      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
      Content-Length: 0

    ]]>
  </send>

  <send retrans="500">
    <![CDATA[

      SIP/2.0 200 OK
      [last_Via:]
      [last_From:]
      [last_To:];tag=[call_number]
      [last_Call-ID:]
      [last_CSeq:]
      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
      Content-Type: application/sdp
      Content-Length: [len]

      v=0
      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
      s=-
      c=IN IP[media_ip_type] [media_ip]
      t=0 0
      m=audio [media_port] RTP/AVP 0
      a=rtpmap:0 PCMU/8000

    ]]>
  </send>

  <recv request="ACK" optional="true" rtd="true" crlf="true">
  </recv>

  <recv request="BYE">
  </recv>

  <send>
    <![CDATA[

      SIP/2.0 200 OK
      [last_Via:]
      [last_From:]
      [last_To:]
      [last_Call-ID:]
      [last_CSeq:]
      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
      Content-Length: 0

    ]]>
  </send>

  <!-- Keep the call open for a while in case the 200 is lost to be     -->
  <!-- able to retransmit it if we receive the BYE again.               -->
  <pause milliseconds="4000"/>


  <!-- definition of the response time repartition table (unit is ms)   -->
  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

  <!-- definition of the call length repartition table (unit is ms)     -->
  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

</scenario>