コード例 #1
0
ファイル: pktgen-seq.c プロジェクト: AdunSG/Pktgen-DPDK
void
pktgen_page_seq(uint32_t pid)
{
    uint32_t    i, row, col;
    port_info_t * info;
    pkt_seq_t   * pkt;
    char buff[64];

    display_topline("** Sequence Page **");

    info = &pktgen.info[pid];

    row = PORT_STATE_ROW;
    col = 1;
    wr_scrn_printf(row++, col, "Port: %2d, Sequence Count: %2d of %2d  ", pid, info->seqCnt, NUM_SEQ_PKTS);
    wr_scrn_printf(row++, col, "%*s %*s%*s%*s%*s%*s%*s%*s",
            6, "Seq:",
            COLUMN_WIDTH_0, "Dst MAC",
            COLUMN_WIDTH_0, "Src MAC",
            COLUMN_WIDTH_0, "Dst IP",
            COLUMN_WIDTH_0+2, "Src IP",
            12, "Port S/D",
            15, "Protocol:VLAN",
            5, "Size");
    for(i = 0; i < NUM_SEQ_PKTS; i++) {
        col = 1;
        pkt = &info->seq_pkt[i];

        if ( i >= info->seqCnt ) {
        	wr_scrn_eol_pos(row++, col);
        	continue;
        }

        wr_scrn_printf(row, col, "%5d:", i);
        col += 7;
        wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1, inet_mtoa(buff, sizeof(buff), &pkt->eth_dst_addr));
        col += COLUMN_WIDTH_1;
        wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1, inet_mtoa(buff, sizeof(buff), &pkt->eth_src_addr));
        col += COLUMN_WIDTH_1;
        wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1, inet_ntop4(buff, sizeof(buff), htonl(pkt->ip_dst_addr), 0xFFFFFFFF));
        col += COLUMN_WIDTH_1;
        wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1+2, inet_ntop4(buff, sizeof(buff), htonl(pkt->ip_src_addr), pkt->ip_mask));
        col += COLUMN_WIDTH_1+2;

        snprintf(buff, sizeof(buff), "%d/%d", pkt->sport, pkt->dport);
        wr_scrn_printf(row, col, "%*s", 12, buff);
        col += 12;
        snprintf(buff, sizeof(buff), "%s/%s:%04x", (pkt->ethType == ETHER_TYPE_IPv4)? "IPv4" :
                                                      (pkt->ethType == ETHER_TYPE_IPv6)? "IPv6" : "Other",
                                                      (pkt->ipProto == PG_IPPROTO_TCP)? "TCP" :
                                                      (pkt->ipProto == PG_IPPROTO_ICMP)? "ICMP" : "UDP",
                                                    		  pkt->vlanid);
        wr_scrn_printf(row, col, "%*s", 15, buff);
        col += 15;
        wr_scrn_printf(row, col, "%5d", pkt->pktSize+FCS_SIZE);
        row++;
    }

    display_dashline(row+2);
}
コード例 #2
0
ファイル: mcos_main.c プロジェクト: alegacy/Pktgen-DPDK
static void
mcos_page_stats(void)
{
	int			row, col, i, j;
	info_t	  * info;
	saved_t	  * save;

    if ( mcos.flags & PRINT_LABELS_FLAG ) {
    	row = 1;
    	col = 1;
    	display_topline("**** Multicore OS ****");
    	scrn_printf(row+1, col, "Duration:");
    	scrn_printf(row+2, col, "Solution:");

   		for(j=0; j<MAX_PHILS; j++) {
   			scrn_printf(j+5, 1, "Philosopher %2d:", j + 1);
   		}

   		col = COLUMN_WIDTH_0;
   		for(i=0; i<mcos.nb_lcores; i++) {
			info = infos[mcos.map_idx2lcores[i]][0];
			if ( info == NULL )
				continue;
			j = i-1;
			scrn_printf(2, col, "%s", info->duration ? "  Fixed" : "  Forever");
			scrn_printf(3, col, "%s", info->solution == CLAIM_BASED ? "  Claim-Based" : "  Ticket-Based");
			scrn_printf(4, col, "  --- lcore %d ---", mcos.map_idx2lcores[i]-1);
			col += COLUMN_WIDTH_1;
   		}
   		mcos.last_row += 2;
   		display_dashline(mcos.last_row);
    }
    mcos.flags &= ~PRINT_LABELS_FLAG;

    col = COLUMN_WIDTH_0;
	for(i=0; i<mcos.nb_lcores; i++) {
		for(j=0; j<MAX_PHILS; j++) {
			info = infos[mcos.map_idx2lcores[i]][j];
			if ( info == NULL )
				continue;
			save = &saved[i][j];

			// Only change the screen if the value has changed.
			if ( save->doing != info->doing ) {
				scrn_printf(j+5, col, "%s", doing_str[info->doing]);
				save->doing = info->doing;
			}
			scrn_printf(j+5, col, "%c", "!@#$%^&*"[save->count]);
		}
		if ( info )
			col += COLUMN_WIDTH_1;
	}
}
コード例 #3
0
static void
pktgen_print_pcap(uint16_t pid)
{
	uint32_t i, row, col, max_pkts, len;
	uint16_t type, vlan, skip;
	uint8_t proto;
	port_info_t *info;
	pkt_hdr_t   *hdr;
	pcap_info_t *pcap;
	pcaprec_hdr_t pcap_hdr;
	char buff[64];
	char pkt_buff[2048];

	display_topline("<PCAP Page>");
	wr_scrn_printf(1, 3, "Port %d of %d", pid, pktgen.nb_ports);

	info = &pktgen.info[pid];
	pcap = info->pcap;

	row = PORT_STATE_ROW;
	col = 1;
	if (pcap == NULL) {
		wr_scrn_center(10, pktgen.scrn->ncols, "** Port does not have a PCAP file assigned **");
		row = 28;
		goto leave;
	}

	wr_scrn_eol_pos(row, col);
	wr_scrn_printf(row++, col, "Port: %d, PCAP Count: %d of %d",
	               pid, pcap->pkt_idx, pcap->pkt_count);
	wr_scrn_printf(row++, col, "%*s %*s%*s%*s%*s%*s%*s%*s",
	               5, "Seq",
	               COLUMN_WIDTH_0, "Dst MAC",
	               COLUMN_WIDTH_0, "Src MAC",
	               COLUMN_WIDTH_0, "Dst IP",
	               COLUMN_WIDTH_0 + 2, "Src IP",
	               12, "Port S/D",
	               15, "Protocol:VLAN",
	               9, "Size-FCS");

	max_pkts = pcap->pkt_idx + PCAP_PAGE_SIZE;
	if (max_pkts > pcap->pkt_count)
		max_pkts = pcap->pkt_count;

	wr_pcap_skip(pcap, pcap->pkt_idx);

	for (i = pcap->pkt_idx; i < max_pkts; i++) {
		col = 1;
		skip = 0;

		len = wr_pcap_read(pcap, &pcap_hdr, pkt_buff, sizeof(pkt_buff));
		if (len == 0)
			break;

		/* Skip any jumbo packets larger then buffer. */
		if (pcap_hdr.incl_len > sizeof(pkt_buff) ) {
			i--;
			skip++;
		}
		/* Skip packets that are not normal IP packets. */
		type = ntohs( ((uint16_t *)pkt_buff)[6]);
		if (unlikely(type == ETHER_TYPE_VLAN) )
			type = ntohs( ((uint16_t *)pkt_buff)[8]);

		if (unlikely(type < MAX_ETHER_TYPE_SIZE) )
			skip++;

		hdr = (pkt_hdr_t *)&pkt_buff[0];

		wr_scrn_eol_pos(row, col);

		wr_scrn_printf(row, col, "%5d:", i);
		col += 7;
		wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1, inet_mtoa(buff, sizeof(buff), &hdr->eth.d_addr));
		col += COLUMN_WIDTH_1;
		wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1, inet_mtoa(buff, sizeof(buff), &hdr->eth.s_addr));
		col += COLUMN_WIDTH_1;

		type = ntohs(hdr->eth.ether_type);
		proto = hdr->u.ipv4.proto;
		vlan = 0;
		if (type == ETHER_TYPE_VLAN) {
			vlan = ntohs( ((uint16_t *)&hdr->eth.ether_type)[1]);
			type = ntohs( ((uint16_t *)&hdr->eth.ether_type)[2]);
			proto = ((ipHdr_t *)((char *)&hdr->u.ipv4 + 4))->proto;
		}

		if (type == ETHER_TYPE_IPv4) {
			wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1, inet_ntop4(buff, sizeof(buff), hdr->u.ipv4.dst, 0xFFFFFFFF));
			col += COLUMN_WIDTH_1;
			wr_scrn_printf(row, col, "%*s", COLUMN_WIDTH_1 + 2, inet_ntop4(buff, sizeof(buff), hdr->u.ipv4.src, 0xFFFFFFFF));
			col += COLUMN_WIDTH_1 + 2;

			snprintf(buff, sizeof(buff), "%d/%d", ntohs(hdr->u.uip.udp.sport), ntohs(hdr->u.uip.udp.dport));
			wr_scrn_printf(row, col, "%*s", 12, buff);
			col += 12;
		} else {
			skip++;
			col += ((2 * COLUMN_WIDTH_1) + 2 + 12);
		}
		snprintf(buff, sizeof(buff), "%s/%s:%4d", (type == ETHER_TYPE_IPv4) ? "IPv4" :
		         (type == ETHER_TYPE_IPv6) ? "IPv6" : "Other",
		         (type == PG_IPPROTO_TCP) ? "TCP" :
		         (proto == PG_IPPROTO_ICMP) ? "ICMP" : "UDP",
		         (vlan & 0xFFF));
		wr_scrn_printf(row, col, "%*s", 15, buff);
		col += 15;
		wr_scrn_printf(row, col, "%5d", len);

		if (skip && (type < ETHER_TYPE_IPv4) )
			wr_scrn_printf(row, col + 7, "<<< Skip %04x", type);
		else if (skip && (type != ETHER_TYPE_IPv4) )
			wr_scrn_printf(row, col + 7, " EthType %04x", type);
		row++;
	}
leave:
	display_dashline(row + 2);

	pktgen.flags &= ~PRINT_LABELS_FLAG;
}
コード例 #4
0
/* Display log page on the screen */
void
pktgen_page_log(uint32_t print_labels)
{
	/* Maximum number of log lines to display */
#define MAX_PAGE_LINES 28

	uint32_t row, curr_msg, output_lines, curr_char;
	int curr_line;
	char lines[MAX_PAGE_LINES][LOG_MAX_LINE];

	if (!print_labels && !log_history.need_refresh)
		return;

	display_topline("<Logged messages>");
	row = 2;

	/* Header line */
	wr_scrn_printf(row++, 1, "%1s %8s %-32s %s",
	               "L", "Time", "Function", "Message");

	curr_line = output_lines = 0;
	curr_msg = log_history.head;
	while ((curr_msg != log_history.tail) && (output_lines < MAX_PAGE_LINES)) {
		/* Go backwards and wrap around */
		curr_msg = (curr_msg + LOG_HISTORY - 1) % LOG_HISTORY;

		snprintf(lines[curr_line], LOG_MAX_LINE, "%s",
		         pktgen_format_msg_page(&log_history.msg[curr_msg]));

		/* Count number of lines occupied by current log entry. Line wrapping
		 * because of screen width is not counted, \n's embedded in the log
		 * message are counted.
		 */
		for (curr_char = 0; lines[curr_line][curr_char] != '\0'; ++curr_char)
			if (lines[curr_line][curr_char] == '\n')
				++output_lines;

		++output_lines;	/* First line before possible \n's */

		++curr_line;
	}

	/* The lines[] array contains the messages to print on the screen, with
	 * the most recent message first.
	 * Iterating backwards gives the messages in chronological order.
	 * curr_line points 1 beyond the last entry in lines[].
	 */
	for (--curr_line; curr_line >= 0; --curr_line) {
		wr_scrn_printf(row++, 1, "%s", lines[curr_line]);

		/* Increase row for each embedded \n */
		for (curr_char = 0; lines[curr_line][curr_char] != '\0'; ++curr_char)
			if (lines[curr_line][curr_char] == '\n')
				++row;
	}

	if (row < MAX_PAGE_LINES)
		row = MAX_PAGE_LINES;

	display_dashline(++row);
	log_history.need_refresh = 0;

#undef MAX_PAGE_LINES
}
コード例 #5
0
ファイル: pktgen-seq.c プロジェクト: sivaramakrishnansr/SENSS
void
pktgen_page_seq(uint32_t pid)
{
	uint32_t i, row, col;
	port_info_t *info;
	pkt_seq_t   *pkt;
	char buff[64];

	display_topline("<Sequence Page>");

	info = &pktgen.info[pid];

	row = PORT_STATE_ROW;
	col = 1;
	scrn_printf(row, col, "Port: %2d, Sequence Count: %2d of %2d  ",
	               pid, info->seqCnt, NUM_SEQ_PKTS);
    scrn_fgcolor(SCRN_BLUE, SCRN_BOLD);
    scrn_printf(row++, col + 111, "GTPu");
	scrn_printf(row++, col, "%*s %*s%*s%*s%*s%*s%*s%*s%*s%*s%*s",
	               6, "Seq:",
	               18, "Dst MAC",
	               18, "Src MAC",
	               16, "Dst IP",
	               18, "Src IP",
	               12, "Port S/D",
	               14, "Protocol:VLAN",
	               4,  "CoS",
	               4,  "ToS",
	               6, "Size",
	               6, "TEID");
    scrn_fgcolor(SCRN_DEFAULT_FG, SCRN_NO_ATTR);
	for (i = 0; i < NUM_SEQ_PKTS; i++) {
		pkt = &info->seq_pkt[i];

		if (i >= info->seqCnt) {
			scrn_eol_pos(row++, col);
			continue;
		}

        col = 1;
		scrn_printf(row, col, "%c%4d:", pkt->seq_enabled ? '*' : ' ', i);
        col += 7;

		scrn_printf(row, col, "%*s", 18,
		               inet_mtoa(buff, sizeof(buff),
		                         &pkt->eth_dst_addr));
		col += 18;

		scrn_printf(row, col, "%*s", 18,
		               inet_mtoa(buff, sizeof(buff),
		                         &pkt->eth_src_addr));
		col += 18;

		scrn_printf(row, col, "%*s", 16,
		               inet_ntop4(buff, sizeof(buff),
		                          htonl(pkt->ip_dst_addr.addr.ipv4.s_addr),
		                          0xFFFFFFFF));
		col += 16;

		scrn_printf(row, col, "%*s", 16 + 2,
		               inet_ntop4(buff, sizeof(buff),
		                          htonl(pkt->ip_src_addr.addr.ipv4.s_addr),
		                          pkt->ip_mask));
		col += 18;

		snprintf(buff, sizeof(buff), "%d/%d", pkt->sport, pkt->dport);
		scrn_printf(row, col, "%*s", 12, buff);
        col += 12;

		snprintf(buff, sizeof(buff), "%s/%s:%04x",
		         (pkt->ethType == ETHER_TYPE_IPv4) ? "IPv4" :
		         (pkt->ethType == ETHER_TYPE_IPv6) ? "IPv6" : "Other",
		         (pkt->ipProto == PG_IPPROTO_TCP) ? "TCP" :
		         (pkt->ipProto == PG_IPPROTO_ICMP) ? "ICMP" : "UDP",
		         pkt->vlanid);
		scrn_printf(row, col, "%*s", 14, buff);
		col += 14;

		scrn_printf(row, col, "%3d", pkt->cos);
		col += 4;

		scrn_printf(row, col, "%3d", pkt->tos);
		col += 4;

		scrn_printf(row, col, "%5d", pkt->pktSize + FCS_SIZE);
		col += 6;

		scrn_printf(row, col, "%5d", pkt->gtpu_teid);
		row++;
	}

	display_dashline(row + 2);
}