# class SwitchBuffer

*Defined at src/network/switch/switch_buffer.h#22*

## Members

protected Simulator *const _sim

protected NetworkSwitch *const _owner

protected SwitchBufferType _type

protected Bytes _buffer_bytes

protected uint16_t _port_cnt

protected vector _egress_links

protected vector _drain_scheduled

protected vector _per_port_bytes

protected vector _sched

protected uint8_t _share_ctrl

protected uint8_t _share_mice

protected uint8_t _share_ele



## Records

PerPortSched

Queued



## Functions

### enqueue_packet

*public bool enqueue_packet(const Packet & pkt, PortId egress, FlowPriority prio)*

### drain_one

*public bool drain_one(PortId port)*

### buffer_size

*public Bytes buffer_size()*

### type

*public SwitchBufferType type()*

### port_cnt

*public uint16_t port_cnt()*

### port_buffered

*public Bytes port_buffered(PortId p)*

### ports_buffered

*public const std::vector<Bytes> & ports_buffered()*

### share_ctrl

*public uint8_t share_ctrl()*

### share_mice

*public uint8_t share_mice()*

### share_elephant

*public uint8_t share_elephant()*

### set_share_ctrl

*public void set_share_ctrl(uint8_t pct)*

### set_share_mice

*public void set_share_mice(uint8_t pct)*

### set_share_elephant

*public void set_share_elephant(uint8_t pct)*

### simulator

*public const Simulator * simulator()*

### owner

*public const NetworkSwitch * owner()*

### set_egress_links

*public void set_egress_links(const std::vector<Link *> & links)*

### SwitchBuffer

*protected void SwitchBuffer(Simulator *const sim, NetworkSwitch *const owner, SwitchBufferType t, Bytes total_bytes, uint16_t ports)*

### drain_one_common

*protected bool drain_one_common(PortId port)*

### schedule_drain_if_needed

*protected void schedule_drain_if_needed(PortId port)*

### drain_once

*protected void drain_once(PortId port)*

### queues_for

*protected std::array<std::deque<Queued>, PRI_COUNT> & queues_for(PortId p)*

### queues_for

*protected const std::array<std::deque<Queued>, PRI_COUNT> & queues_for(PortId p)*

### on_enqueue_cap_check

*protected bool on_enqueue_cap_check(PortId port, Bytes sz)*

### on_enqueue_commit

*protected void on_enqueue_commit(PortId port, Bytes sz)*

### on_dequeue_commit

*protected void on_dequeue_commit(PortId port, Bytes sz)*

### ~SwitchBuffer

*public void ~SwitchBuffer()*

*Defined at src/network/switch/switch_buffer.h#32*

### to_idx

*protected int to_idx(FlowPriority p)*

*Defined at src/network/switch/switch_buffer.h#83*

### try_reserve_and_send

*protected std::optional<Time> try_reserve_and_send(PortId port, Queued & q)*

### queued_bytes_total

*protected Bytes queued_bytes_total()*

### queued_bytes_port

*protected Bytes queued_bytes_port(PortId p)*



