2014년 7월 21일 월요일

OAM 관련용어 정의

명칭 정의
in-service OAM
"In-service OAM refers to OAM actions which are carried out while
the data traffic is not interrupted with an expectation that data traffic
remains transparent to OAM actions."

on-demand OAM
"On-demand OAM refers to OAM actions which are initiated via manual
intervention for a limited time to carry out diagnostics.
On-demand OAM can result in singular or periodic OAM actions during
 the diagnostics time interval."

out-of-service OAM
"Out-of-service OAM refers to OAM actions which are carried out while
the data traffic is interrupted."

proactive OAM
"Proactive OAM refers to OAM actions which are carried out continuously
 to permit proactive reporting of fault and/or performance results."

1DM One-way Delay Measurement
AIS Alarm Indication Signal
AP Access Point
APS Automatic Protection Switching
CCM Continuity Check Message
CE Customer Edge
CoS Class of Service
CP Connection Point
DA Destination MAC Address
DMM Delay Measurement Message
DMR Delay Measurement Reply
ETH Ethernet MAC layer network
ETH-AIS Ethernet Alarm Indication Signal function
ETH-APS Ethernet Automatic Protection Switching function
ETH-CC Ethernet Continuity Check function
ETH-DM Ethernet Delay Measurement function
ETH-EXP Ethernet Experimental OAM function
ETH_FP Ethernet Flow Point
ETH-LB Ethernet LoopBack function
ETH-LCK Ethernet Lock signal function
ETH-LM Ethernet Loss Measurement function
ETH-LT Ethernet Link Trace function
ETH-MCC Ethernet Maintenance Communication Channel function
ETH-RDI Ethernet Remote Defect Indication function
ETH-Test Ethernet Test function
ETH-TFP Ethernet Termination Flow Point
ETH-VSP Ethernet Vendor-Specific OAM function
ETY Ethernet PHY layer network
EXM Experimental operations, administration and management Message
EXR Experimental operations, administration and management Reply
FD Flow Domain
FP Flow Point
FPP Flow Point Pool
FT Flow Termination
ICC ITU Carrier Code
LBM LoopBack Message
LBR LoopBack Reply
LCK Locked
LMI Local Management Interface
LMM Loss Measurement Message
LMR Loss Measurement Reply
LOC Loss of Continuity
LTM Link Trace Message
LTR Link Trace Reply
MAC Media Access Control
MC Media Converter
MCC Maintenance Communication Channel
ME Maintenance Entity
MEG Maintenance Entity Group
MEL MEG Level
MEP MEG End Point
MIB Management Information Base
MIP MEG Intermediate Point
NMS Network Management System
NNI Network Node Interface
NT Network Termination
OAM Operations, Administration and Maintenance
OSS Operations Support System
OTN Optical Transport Network
OUI Organizationally Unique Identifier
PDU Protocol Data Unit
PE Provider Edge
PHY Ethernet PHYsical layer entity
PRBS Pseudo-Random Bit Sequence
RDI Remote Defect Indication
SA Source MAC Address
SES Severely Errored Seconds
SLA Service level Agreement
SRV Server
STP Spanning Tree Protocol
TC Traffic Conditioning
TCI Tag Control Information
TFP Termination Flow Point
TFPP Termination Flow Point Pool
TLV Type, Length, Value
TrCP Traffic Conditioning Point
TST Test PDU
TTL Time To Live
UMC Unique MEG ID Code
UNI User Network Interface
UNI-C Customer side of UNI
UNI-N Network side of UNI
VID VLAN Identifier
VLAN Virtual LAN
VSM Vendor-Specific OAM Message
VSR Vendor-Specific OAM Reply

2014년 6월 24일 화요일

C 언어 에러 삽질 방지

오늘부터 자주 보는 에러에 대한 나의 삽질내역을 기록하겠다.


warning: implicit declaration of function '함수'
1.발생 이유: 함수선언을 다른 곳, 현재 코드보다 아래에 해두고 가져다 쓸 때 
2.해결방법 : 사용하는 위치 보다 아래에 정의된 함수를 가져다 쓸 때는 해당 파일 또는 include 하는 헤더파일에다가 함수 원형을 선언해두자. 다른 파일에 있다면 extern 하여 사용 하자.
3.여담: 워닝인 이유는 컴파일러가 알아서 찾아주기때문. 컴파일러가 구리면 error로 띄워주는듯 하다.

warning: nested extern declaration of '함수명'
1.발생이유: 이제껏 상위 implicit declaration of function  의 여파로 생겨 났던 것 밖에 없다.
2.해결방법 : 위의 워닝을 해결하라
3.여담: 찾아도 잘안나오네 ㅠㅠ

warning: label 'defualt' defined but not used
1.발생 이유: 스위치 문에서 default를 defualt로 적어서 나는 워닝
2.해결방법 : 오타를 수정하자 무지막지하게 부끄러운 일이다..(*-_-*)
3.여담: 이걸 상사에게 물어봤다가 얼굴이 빨개졌다. 부끄러워서...

warning: return makes integer from pointer without a cast
1.발생 이유: 리턴 값이 int인 함수내에서 다른 자료형으로 리턴을 했을 때
2.해결방법 : 꼭 리턴해야 하는 의미있는 값일경우(unsigned 라던지) return (int)변수명;
return NULL; <- 이런걸 적어놨다면 그냥 -1로 리턴하고 해당 함수 콜 하는 부분 다음에 
if(ret < 0) 를 사용하여 예외처리를 하자(ret는 보통 return 의 줄임말. return 예약어니까 변수명으로 쓸수 없다)
3.여담: 막코딩하다보니 return NULL; 해놓고 바로아래 int형으로 리턴을 적어뒀더라....

warning: pointer targets in passing argument 2 of 'sprintf' differ in signedness
1.발생 이유: sprintf라는 함수를 사용하는 데 안에 들어가는 아규먼트(파라미터?)가 부호값을 상실했네
 sprintf(char * a, const char *b , ....) 뭐 이런식인데 sprintf(char * a,const u_int8_t *b , ....) 
이렇게 넣은거
2.해결방법 : 변수를 바로 쑤셔박지말고 sprintf(받는놈 , " % 자료형형형",  *b) 요런식으로 바끄야할듯

warning: type defaults to 'int' in declaration of '함수명'
1.발생 이유: 필자는 extern 함수 여기서 에러가 났엇다. 함수 원형은 int형인데 왜 int 안적냐는 워닝
2.해결방법: 컴파일러가 모르게 extern int 함수 이렇게 바꾸고 모르는척 컴파일다시하자

warning: case label value exceeds maximum value for type

1.발생 이유: switch 비교문에서 case 가 음수로 가는 경우
2.해결방법: 음수 비교를 하지 말거나, 나는 음수를 안쓴다 싶으면 unsigned를 넣든지


계속 추가할 계획이다. 시간남을때..





2014년 6월 20일 금요일

notepad++ MIB plugin 노트패드++ snmp 플러그인

심심해서 만들어 봤어요.

사용자 지정에서 입맛에 맞게 바꿔 쓰세요.

아래 내용을 복사한 뒤 mib.xml로 저장하여 사용.

파일 업로드가 안되네요.

<NotepadPlus>
   <UserLang name="MIB" ext="MIB" udlVersion="2.1">
       <Settings>
           <Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="yes" forcePureLC="0" decimalSeparator="0" />
           <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
       </Settings>
       <KeywordLists>
           <Keywords name="Comments"></Keywords>
           <Keywords name="Numbers, prefix1"></Keywords>
           <Keywords name="Numbers, prefix2"></Keywords>
           <Keywords name="Numbers, extras1"></Keywords>
           <Keywords name="Numbers, extras2"></Keywords>
           <Keywords name="Numbers, suffix1"></Keywords>
           <Keywords name="Numbers, suffix2"></Keywords>
           <Keywords name="Numbers, range"></Keywords>
           <Keywords name="Operators1"></Keywords>
           <Keywords name="Operators2"></Keywords>
           <Keywords name="Folders in code1, open"></Keywords>
           <Keywords name="Folders in code1, middle"></Keywords>
           <Keywords name="Folders in code1, close"></Keywords>
           <Keywords name="Folders in code2, open"></Keywords>
           <Keywords name="Folders in code2, middle"></Keywords>
           <Keywords name="Folders in code2, close"></Keywords>
           <Keywords name="Folders in comment, open"></Keywords>
           <Keywords name="Folders in comment, middle"></Keywords>
           <Keywords name="Folders in comment, close"></Keywords>
           <Keywords name="Keywords1">OBJECT-TYPE</Keywords>
           <Keywords name="Keywords2"></Keywords>
           <Keywords name="Keywords3"></Keywords>
           <Keywords name="Keywords4"></Keywords>
           <Keywords name="Keywords5"></Keywords>
           <Keywords name="Keywords6"></Keywords>
           <Keywords name="Keywords7"></Keywords>
           <Keywords name="Keywords8"></Keywords>
           <Keywords name="Delimiters"></Keywords>
       </KeywordLists>
       <Styles>
           <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="@Bitstream Vera Sans Mono" fontStyle="0" fontSize="10" nesting="0" />
           <WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="LINE COMMENTS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="KEYWORDS1" fgColor="FF8080" bgColor="FFFFFF" fontName="@Bitstream Vera Sans Mono" fontStyle="1" fontSize="12" nesting="0" />
           <WordsStyle name="KEYWORDS2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="OPERATORS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
           <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
       </Styles>
   </UserLang>
</NotepadPlus>

2014년 3월 18일 화요일

quagga (zebra) 설치 사용법

사용OS: 리눅스


quagga를 받습니다.

어떻게든 받아봅니다. 여기선 설치와 사용법만 다루니까요. 


참고로 저는 quagga-0.99.20.tar.gz라는 파일을 받았네요.


사용자 디렉토리 안에다가 다운로드를 받고 폴더를 하나 만듭니다.

 경로상
 ~/만들폴더 
혹은
/home/사용자id/만들폴더 
가 되겠습니다.

폴더이름은 멋지게 quagga로 해두지요.
 $cd ~/ 
 $mkdir quagga 

이왕이면 압축파일을 quagga폴더 안에 복사를 한 뒤에 작업을 해보도록하죠

quagga 압축파일이 있는 곳에가서 복사를 시도해봅니다. 파일이름을 quagga-0.99.20.tar.gz이라고 해두죠.

$cp quagga-0.99.20.tar.gz ~/quagga

순식간에 복사가 될겁니다.

이제 압축을 풉니다.

$cd ~/quagga
$tar zxvf quagga-0.99.20.tar.gz

쭈룩쭈룩 글이 올라옵니다.

기다려보죠

음~~

다됐나보네요.

어떻게 됬는지 확인을 해봅니다.

$ls

.....
quagga-0.99.20.tar.gz /quagga-0.99.20
폴더가 하나 더생겼네요

quagga-0.99.20 라는 폴더에 있는 내용물을 꺼내도록 하죠.. 폴더안에 폴더가 있으면 귀찮으니까요..

$cd quagga-0.99.20

$mv * ../

됐습니다.

내용을 꺼냈으니 압축폴더와 quagga-0.99.20 폴더를 지우도록 하죠.

$cd ..
$rm -rf quagga-0.99.20.tar.gz quagga-0.99.20

이제좀 낫군요..

이제 쉘스크립트 파일을 만들어서 설치를 쉽게 하도록 하죠.(~/quagga 안에 쉘파일 생성하세요)

$vim config.sh

-----내용입니다----

#!/bin/bash

 ./configure --enable-user=사용자이름을적으세요 --enable-group=사용자이름을적으세요 --prefix=/home/사용자이름을적으세요/quagga --enable-vtysh --disable-ipv6 --disable-capabilities


-----내용 끝---
사용자이름을적으세요 라고 적힌곳에는 user id를 적도록 하세요
모르겠다면 일단 vim 을 종료 후에
$id
라고적으면 유저 이름을 확인할수 있씀당

암튼 여차저차 쉘스크립트 파일생성까지 다되었다면

$chmod 775 config.sh

로 권한 바꿔 두세요..

자..

한가지 더 해야하는 작업이 있네요.
$mkdir etc
etc 폴더를 만들어야하는데 이미 만들어져있다면 패스

이제 쉘스크립트를 실행해봅니다.

$./config.sh

쭈룩쭈룩 뭔가 올라옵니다.


끝났네요.

zebra폴더와 vtysh폴더가 생성되었습니다(원래 있는건지 이때 생성되는지는 기억이 안나네요)

일단 zebra 폴더로 들어갑니다.

$cd zebra

그런다음에 zebra.conf.example 파일을 etc에 복사를 해둡시다.

$cp zebra.conf.example ../etc/zebra.conf

.example은 일부러 뺀거니 신경쓰지마세용.

그런다음

zebra를 실행시킵니다.

$./zebra&

엔터한번 쳐주고요

$cd ..
$cd vtysh

vtysh폴더로 이동 후 vtysh파일을 실행

$./vtysh

하면!!!

실행이 잘됩니다.

그럼 안뇽









2014년 1월 23일 목요일

LINUX 에코 서버 & 파일 전송 c소스

먼저 클라이언트부분
  
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
int main(){
 int file;
 int sockfd;
 int len;
 int buf;
 struct sockaddr_in address;
 int result;
 char put_string[255]={0};
 sockfd = socket(AF_INET, SOCK_STREAM, 0);
 address.sin_family = AF_INET;
 address.sin_addr.s_addr = inet_addr("192.168.123.99"); 
 address.sin_port = htons(9734);
 len = sizeof(address);
 result = connect(sockfd, (struct sockaddr *)&address, len);

 if(result == -1) {
  perror("oops: client1");
  exit(1);
 }
 while(strcmp(put_string,"end")){
  char get_string[255];
  scanf(" %s",put_string); 
  write(sockfd, put_string, sizeof(put_string));

  if(!strcmp("put",put_string)){
   printf("file name?\n");
   scanf(" %s",put_string);
   write(sockfd, put_string, sizeof(put_string));
   file=open(put_string,O_RDONLY);
   if(file<1 data-blogger-escaped-buf="" data-blogger-escaped-close="" data-blogger-escaped-continue="" data-blogger-escaped-done="" data-blogger-escaped-error="" data-blogger-escaped-exit="" data-blogger-escaped-file="" data-blogger-escaped-get_string="" data-blogger-escaped-memset="" data-blogger-escaped-pre="" data-blogger-escaped-put_string="" data-blogger-escaped-read="" data-blogger-escaped-sizeof="" data-blogger-escaped-sockfd="" data-blogger-escaped-while="" data-blogger-escaped-write=""> 
서버 부분
  
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define FLAG_NORMAL 0
#define FLAG_IS_FLIE_EXIST 1
#define FLAG_TRANSFER 2
int main()
{
 int server_sockfd, client_sockfd;
 int flag=FLAG_NORMAL;
 int file;
 int buf;
 int server_len, client_len;
 char file_name[100],remove[103];
 struct sockaddr_in server_address;
 struct sockaddr_in client_address;
 int result;
 fd_set readfds, testfds;

  char message[255]={0};
 /*socket creat & naming*/
 server_sockfd= socket(AF_INET, SOCK_STREAM,0);
 server_address.sin_family = AF_INET;
 server_address.sin_addr.s_addr = htonl(INADDR_ANY);
 server_address.sin_port = htons(9734);
 server_len = sizeof(server_address);

 /*bind*/
 bind(server_sockfd, (struct sockaddr *)&server_address, server_len);

 /*listen*/
 listen(server_sockfd, 5);

 FD_ZERO(&readfds);
 FD_SET(server_sockfd, &readfds);

 while(1){
  int fd;
  int nread;
  testfds=readfds;

  result=select(FD_SETSIZE, &testfds, (fd_set *)0 ,(fd_set *)0, (struct timeval *)0);

  if(result < 1)
  {
   perror("server error:");
   exit(1);
  }
  for(fd =0; fd < FD_SETSIZE; fd++)
  {
   if(FD_ISSET(fd,&testfds)){
    if(fd == server_sockfd){
     client_len = sizeof(client_address);
     client_sockfd = accept(server_sockfd,(struct sockaddr *)&client_address, &client_len);
     FD_SET(client_sockfd, &readfds);
     printf("adding client on fd %d\n", client_sockfd);
    }
    else
    {
     ioctl(fd, FIONREAD, &nread);

     if(nread ==0)
     {
      close(fd);
      FD_CLR(fd, &readfds);
      printf("removing client on fd %d\n",fd);
     }
     else
     {
      memset(message,0,sizeof(message));
      read(fd, message, sizeof(message));
      printf("%s\n",message);
      if(strncmp("put",message,strlen(message))==0){
        read(fd, message, sizeof(message));
        file=open(message,O_WRONLY|O_CREAT|O_TRUNC,S_IRWXU);
        strcpy(file_name,message);
        if(file<1 data-blogger-escaped-6="" data-blogger-escaped-break="" data-blogger-escaped-buf="" data-blogger-escaped-close="" data-blogger-escaped-done="" data-blogger-escaped-else="" data-blogger-escaped-error="" data-blogger-escaped-fd="" data-blogger-escaped-file="" data-blogger-escaped-file_name="" data-blogger-escaped-if="" data-blogger-escaped-isolation="" data-blogger-escaped-memset="" data-blogger-escaped-message="" data-blogger-escaped-n="" data-blogger-escaped-pre="" data-blogger-escaped-printf="" data-blogger-escaped-remove="" data-blogger-escaped-rm="" data-blogger-escaped-s="" data-blogger-escaped-sizeof="" data-blogger-escaped-sprintf="" data-blogger-escaped-strcmp="" data-blogger-escaped-strlen="" data-blogger-escaped-system="" data-blogger-escaped-while="" data-blogger-escaped-write="">  
많은 예외처리를 무시했지만 동작은 되니까 ..ㅎㅎ

2014년 1월 2일 목요일

c++를 이용한 beep음 내기


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <windows.h>
 
using namespace std;
 
int main()
{
    //ascending pitch beep
    for (int i=0; i<3000; i+=10){
    Beep (i,100);
    }
    //descending pitch beep
    for (int i=3000; i>0; i-=10){
    Beep (i,100);
    }
 
}

c++을 이용하여 비프음으로 연주하기 (소리를 낮추세용)

#include <iostream>
#include <windows.h>
using namespace std;
//twinkle twinkle
//CC GG AA G
//FF EE DD C
//GG FF EE D
//GG FF EE D
//CC GG AA G
//FF EE DD C
void playnote (char g, float l)
{

char n = g;

if (n == 'A'||'a'){
Beep(2750,l*1000);
cout <<n;
}
else if(n == 'B'||'b'){
Beep(3087,l*1000);
cout << n;
}
else if(n == 'C'||'c'){
Beep(1637,l*1000);
cout << n;
}
else if(n == 'D'||'d'){
Beep(1835,l*1000);
cout << n;
}
else if(n == 'E'||'e'){
Beep(2060,l*1000);
cout << n;
}
else if(n == 'F'||'f'){
Beep(2183,l*1000);
cout << n;
}
else if(n == 'G'||'g'){
Beep(2450,l*1000);
cout << n;
}
}
 
int main() {

playnote('C', 0.4);
playnote('C', 0.4);
playnote('G', 0.4);
playnote('G', 0.4);
playnote('A', 0.4);
playnote('A', 0.4);
playnote('G', 0.4);
Sleep(400);
cout<<endl;
playnote('F', 0.4);
playnote('F', 0.4);
playnote('E', 0.4);
playnote('E', 0.4);
playnote('D', 0.4);
playnote('D', 0.4);
playnote('C', 0.4);
Sleep(400);
cout<<endl;
playnote('G', 0.4);
playnote('G', 0.4);
playnote('F', 0.4);
playnote('F', 0.4);
playnote('E', 0.4);
playnote('D', 0.4);
playnote('G', 0.4);
Sleep(400);
cout<<endl;
playnote('G', 0.4);
playnote('F', 0.4);
playnote('F', 0.4);
playnote('E', 0.4);
playnote('D', 0.4);
playnote('C', 0.4);
playnote('C', 0.4);
Sleep(400);
cout<<endl;
playnote('G', 0.4);
playnote('G', 0.4);
playnote('A', 0.4);
playnote('A', 0.4);
playnote('G', 0.4);
playnote('F', 0.4);
playnote('F', 0.4);
Sleep(400);
cout<<endl;
playnote('E', 0.4);
playnote('E', 0.4);
playnote('D', 0.4);
playnote('D', 0.4);
playnote('C', 0.4);
cout<<endl;
cout << "thanks for listening <3";

return 0;
 
}